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
950 B

from entity.DownloadInfoEntity import DownloadInfo
from common.Utils import getSession
from sqlalchemy import update
class DownloadInfoService:
def getOneNoFinish():
session = getSession()
downloadInfo = session.query(DownloadInfo).filter(
DownloadInfo.isFinished == 0, DownloadInfo.tryTime <= 2).first()
session.close()
return downloadInfo
def getOneByVideoId(videoId):
session = getSession()
downloadInfo = session.query(DownloadInfo).filter(
DownloadInfo.videoId == videoId).one_or_none()
session.close()
return downloadInfo
def updateIsFinishByVideoId(videoId, tryTime, isFinish):
session = getSession()
updateSql = update(DownloadInfo).where(
DownloadInfo.videoId == videoId).values(tryTime=tryTime, isFinish=isFinish)
resutl = session.execute(updateSql)
session.commit()
session.close()