You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.3 KiB

7 months ago
from Orm import DownloadInfo
class DownloadService:
def getOneByVideoId(videoId, downloadType):
return DownloadInfo.get(DownloadInfo.videoId == videoId, DownloadInfo.downloadType == downloadType)
def createOne(videoId, downloadType, tryTime, isFinished):
DownloadInfo.create(
videoId=videoId,
downloadType=downloadType,
tryTime=tryTime,
isFinished=isFinished
)
def updateInfoByVideoId(videoId, tryTime, isFinished, downloadType):
DownloadInfo.update(tryTime=tryTime, isFinished=isFinished).where(
DownloadInfo.videoId == videoId, DownloadInfo.downloadType == downloadType).execute()
def findNotFinishList():
return DownloadInfo.select().where(DownloadInfo.isFinished == 0, DownloadInfo.tryTime <= 5, DownloadInfo.downloadType == 1).limit(10).execute()
def changeDownloadType(videoId, tryTime, isFinished, downloadType, changeType):
DownloadInfo.update(tryTime=tryTime, isFinished=isFinished, downloadType=changeType).where(
DownloadInfo.videoId == videoId, DownloadInfo.downloadType == downloadType).execute()
def findNotFinishListTwo():
return DownloadInfo.select().where(DownloadInfo.isFinished == 0, DownloadInfo.tryTime <= 5, DownloadInfo.downloadType == 2).limit(10).execute()