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()