fix subscribe files

This commit is contained in:
jxxghp
2025-05-10 20:10:13 +08:00
parent 7d8dd12131
commit e6cdd337c3
2 changed files with 12 additions and 11 deletions
+9 -9
View File
@@ -1,7 +1,7 @@
import time import time
from typing import Optional from typing import Optional
from sqlalchemy import Column, Integer, String, Sequence, JSON from sqlalchemy import Column, Integer, String, Sequence, JSON, or_
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from app.db import db_query, db_update, Base from app.db import db_query, db_update, Base
@@ -65,8 +65,8 @@ class DownloadHistory(Base):
@staticmethod @staticmethod
@db_query @db_query
def get_by_mediaid(db: Session, tmdbid: int, doubanid: str): def get_by_mediaid(db: Session, tmdbid: int, doubanid: str):
return db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, return db.query(DownloadHistory).filter(or_(DownloadHistory.tmdbid == tmdbid,
DownloadHistory.doubanid == doubanid).all() DownloadHistory.doubanid == doubanid)).all()
@staticmethod @staticmethod
@db_query @db_query
@@ -97,18 +97,18 @@ class DownloadHistory(Base):
DownloadHistory.type == mtype, DownloadHistory.type == mtype,
DownloadHistory.seasons == season, DownloadHistory.seasons == season,
DownloadHistory.episodes == episode).order_by( DownloadHistory.episodes == episode).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
# 电视剧某季 # 电视剧某季
elif season: elif season:
result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid,
DownloadHistory.type == mtype, DownloadHistory.type == mtype,
DownloadHistory.seasons == season).order_by( DownloadHistory.seasons == season).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
else: else:
# 电视剧所有季集/电影 # 电视剧所有季集/电影
result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid,
DownloadHistory.type == mtype).order_by( DownloadHistory.type == mtype).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
# 标题 + 年份 # 标题 + 年份
elif title and year: elif title and year:
# 电视剧某季某集 # 电视剧某季某集
@@ -117,18 +117,18 @@ class DownloadHistory(Base):
DownloadHistory.year == year, DownloadHistory.year == year,
DownloadHistory.seasons == season, DownloadHistory.seasons == season,
DownloadHistory.episodes == episode).order_by( DownloadHistory.episodes == episode).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
# 电视剧某季 # 电视剧某季
elif season: elif season:
result = db.query(DownloadHistory).filter(DownloadHistory.title == title, result = db.query(DownloadHistory).filter(DownloadHistory.title == title,
DownloadHistory.year == year, DownloadHistory.year == year,
DownloadHistory.seasons == season).order_by( DownloadHistory.seasons == season).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
else: else:
# 电视剧所有季集/电影 # 电视剧所有季集/电影
result = db.query(DownloadHistory).filter(DownloadHistory.title == title, result = db.query(DownloadHistory).filter(DownloadHistory.title == title,
DownloadHistory.year == year).order_by( DownloadHistory.year == year).order_by(
DownloadHistory.id.desc()).all() DownloadHistory.id.desc()).all()
if result: if result:
return list(result) return list(result)
+2 -1
View File
@@ -1311,7 +1311,8 @@ class FileManagerModule(_ModuleBase):
if media_files: if media_files:
for media_file in media_files: for media_file in media_files:
if f".{media_file.extension.lower()}" in settings.RMT_MEDIAEXT: if f".{media_file.extension.lower()}" in settings.RMT_MEDIAEXT:
ret_fileitems.append(media_file) if media_file not in ret_fileitems:
ret_fileitems.append(media_file)
return ret_fileitems return ret_fileitems
def media_exists(self, mediainfo: MediaInfo, **kwargs) -> Optional[ExistMediaInfo]: def media_exists(self, mediainfo: MediaInfo, **kwargs) -> Optional[ExistMediaInfo]: