mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 08:26:53 +08:00
fix exists_local
This commit is contained in:
@@ -65,6 +65,14 @@ class MediaServerItem(Base):
|
|||||||
@classmethod
|
@classmethod
|
||||||
@db_query
|
@db_query
|
||||||
def exists_by_title(cls, db: Session, title: str, mtype: str, year: str):
|
def exists_by_title(cls, db: Session, title: str, mtype: str, year: str):
|
||||||
|
if not mtype and not year:
|
||||||
|
return db.query(cls).filter(cls.title == title).first()
|
||||||
|
elif not year:
|
||||||
|
return db.query(cls).filter(cls.title == title,
|
||||||
|
cls.item_type == mtype).first()
|
||||||
|
elif not mtype:
|
||||||
|
return db.query(cls).filter(cls.title == title,
|
||||||
|
cls.year == str(year)).first()
|
||||||
return db.query(cls).filter(cls.title == title,
|
return db.query(cls).filter(cls.title == title,
|
||||||
cls.item_type == mtype,
|
cls.item_type == mtype,
|
||||||
cls.year == str(year)).first()
|
cls.year == str(year)).first()
|
||||||
@@ -85,7 +93,16 @@ class MediaServerItem(Base):
|
|||||||
@classmethod
|
@classmethod
|
||||||
@async_db_query
|
@async_db_query
|
||||||
async def async_exists_by_title(cls, db: AsyncSession, title: str, mtype: str, year: str):
|
async def async_exists_by_title(cls, db: AsyncSession, title: str, mtype: str, year: str):
|
||||||
result = await db.execute(select(cls).filter(cls.title == title,
|
if not mtype and not year:
|
||||||
|
result = await db.execute(select(cls).filter(cls.title == title))
|
||||||
|
elif not year:
|
||||||
|
result = await db.execute(select(cls).filter(cls.title == title,
|
||||||
|
cls.item_type == mtype))
|
||||||
|
elif not mtype:
|
||||||
|
result = await db.execute(select(cls).filter(cls.title == title,
|
||||||
|
cls.year == str(year)))
|
||||||
|
else:
|
||||||
|
result = await db.execute(select(cls).filter(cls.title == title,
|
||||||
cls.item_type == mtype,
|
cls.item_type == mtype,
|
||||||
cls.year == str(year)))
|
cls.year == str(year)))
|
||||||
return result.scalars().first()
|
return result.scalars().first()
|
||||||
|
|||||||
Reference in New Issue
Block a user