diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index 8b39ea9a..d1653fdb 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -104,14 +104,14 @@ class DownloadHistory(Base): # TMDBID + 类型 if tmdbid and mtype: # 电视剧某季某集 - if season and episode: + if season is not None and episode: return db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, DownloadHistory.type == mtype, DownloadHistory.seasons == season, DownloadHistory.episodes == episode).order_by( DownloadHistory.id.desc()).all() # 电视剧某季 - elif season: + elif season is not None: return db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, DownloadHistory.type == mtype, DownloadHistory.seasons == season).order_by( @@ -124,14 +124,14 @@ class DownloadHistory(Base): # 标题 + 年份 elif title and year: # 电视剧某季某集 - if season and episode: + if season is not None and episode: return db.query(DownloadHistory).filter(DownloadHistory.title == title, DownloadHistory.year == year, DownloadHistory.seasons == season, DownloadHistory.episodes == episode).order_by( DownloadHistory.id.desc()).all() # 电视剧某季 - elif season: + elif season is not None: return db.query(DownloadHistory).filter(DownloadHistory.title == title, DownloadHistory.year == year, DownloadHistory.seasons == season).order_by( diff --git a/app/db/models/subscribe.py b/app/db/models/subscribe.py index 02a9f5e5..c4e58b5e 100644 --- a/app/db/models/subscribe.py +++ b/app/db/models/subscribe.py @@ -93,7 +93,7 @@ class Subscribe(Base): def exists(cls, db: Session, tmdbid: Optional[int] = None, doubanid: Optional[str] = None, season: Optional[int] = None): if tmdbid: - if season: + if season is not None: return db.query(cls).filter(cls.tmdbid == tmdbid, cls.season == season).first() return db.query(cls).filter(cls.tmdbid == tmdbid).first() @@ -106,7 +106,7 @@ class Subscribe(Base): async def async_exists(cls, db: AsyncSession, tmdbid: Optional[int] = None, doubanid: Optional[str] = None, season: Optional[int] = None): if tmdbid: - if season: + if season is not None: result = await db.execute( select(cls).filter(cls.tmdbid == tmdbid, cls.season == season) ) @@ -148,7 +148,7 @@ class Subscribe(Base): @classmethod @db_query def get_by_title(cls, db: Session, title: str, season: Optional[int] = None): - if season: + if season is not None: return db.query(cls).filter(cls.name == title, cls.season == season).first() return db.query(cls).filter(cls.name == title).first() @@ -156,7 +156,7 @@ class Subscribe(Base): @classmethod @async_db_query async def async_get_by_title(cls, db: AsyncSession, title: str, season: Optional[int] = None): - if season: + if season is not None: result = await db.execute( select(cls).filter(cls.name == title, cls.season == season) ) @@ -169,7 +169,7 @@ class Subscribe(Base): @classmethod @db_query def get_by_tmdbid(cls, db: Session, tmdbid: int, season: Optional[int] = None): - if season: + if season is not None: return db.query(cls).filter(cls.tmdbid == tmdbid, cls.season == season).all() else: @@ -178,7 +178,7 @@ class Subscribe(Base): @classmethod @async_db_query async def async_get_by_tmdbid(cls, db: AsyncSession, tmdbid: int, season: Optional[int] = None): - if season: + if season is not None: result = await db.execute( select(cls).filter(cls.tmdbid == tmdbid, cls.season == season) ) diff --git a/app/db/models/subscribehistory.py b/app/db/models/subscribehistory.py index 37d1ca66..bf9c7b3d 100644 --- a/app/db/models/subscribehistory.py +++ b/app/db/models/subscribehistory.py @@ -99,7 +99,7 @@ class SubscribeHistory(Base): def exists(cls, db: Session, tmdbid: Optional[int] = None, doubanid: Optional[str] = None, season: Optional[int] = None): if tmdbid: - if season: + if season is not None: return db.query(cls).filter(cls.tmdbid == tmdbid, cls.season == season).first() return db.query(cls).filter(cls.tmdbid == tmdbid).first() @@ -112,7 +112,7 @@ class SubscribeHistory(Base): async def async_exists(cls, db: AsyncSession, tmdbid: Optional[int] = None, doubanid: Optional[str] = None, season: Optional[int] = None): if tmdbid: - if season: + if season is not None: result = await db.execute( select(cls).filter(cls.tmdbid == tmdbid, cls.season == season) ) diff --git a/app/db/models/transferhistory.py b/app/db/models/transferhistory.py index 7399da6c..325bb8ff 100644 --- a/app/db/models/transferhistory.py +++ b/app/db/models/transferhistory.py @@ -266,14 +266,14 @@ class TransferHistory(Base): # TMDBID + 类型 if tmdbid and mtype: # 电视剧某季某集 - if season and episode: + if season is not None and episode: return db.query(cls).filter(cls.tmdbid == tmdbid, cls.type == mtype, cls.seasons == season, cls.episodes == episode, cls.dest == dest).all() # 电视剧某季 - elif season: + elif season is not None: return db.query(cls).filter(cls.tmdbid == tmdbid, cls.type == mtype, cls.seasons == season).all() @@ -290,14 +290,14 @@ class TransferHistory(Base): # 标题 + 年份 elif title and year: # 电视剧某季某集 - if season and episode: + if season is not None and episode: return db.query(cls).filter(cls.title == title, cls.year == year, cls.seasons == season, cls.episodes == episode, cls.dest == dest).all() # 电视剧某季 - elif season: + elif season is not None: return db.query(cls).filter(cls.title == title, cls.year == year, cls.seasons == season).all() @@ -312,7 +312,7 @@ class TransferHistory(Base): return db.query(cls).filter(cls.title == title, cls.year == year).all() # 类型 + 转移路径(emby webhook season无tmdbid场景) - elif mtype and season and dest: + elif mtype and season is not None and dest: # 电视剧某季 return db.query(cls).filter(cls.type == mtype, cls.seasons == season, diff --git a/app/db/subscribe_oper.py b/app/db/subscribe_oper.py index 0dd82f3c..ed1b902d 100644 --- a/app/db/subscribe_oper.py +++ b/app/db/subscribe_oper.py @@ -92,7 +92,7 @@ class SubscribeOper(DbOper): 判断是否存在 """ if tmdbid: - if season: + if season is not None: return True if Subscribe.exists(self._db, tmdbid=tmdbid, season=season) else False else: return True if Subscribe.exists(self._db, tmdbid=tmdbid) else False @@ -195,7 +195,7 @@ class SubscribeOper(DbOper): 判断是否存在订阅历史 """ if tmdbid: - if season: + if season is not None: return True if SubscribeHistory.exists(self._db, tmdbid=tmdbid, season=season) else False else: return True if SubscribeHistory.exists(self._db, tmdbid=tmdbid) else False