mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 08:26:53 +08:00
fix oper
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, String, Sequence, JSON, or_
|
from sqlalchemy import Column, Integer, String, Sequence, JSON
|
||||||
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
|
||||||
@@ -74,8 +74,7 @@ class DownloadHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30):
|
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30):
|
||||||
result = db.query(DownloadHistory).offset((page - 1) * count).limit(count).all()
|
return db.query(DownloadHistory).offset((page - 1) * count).limit(count).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -91,50 +90,47 @@ class DownloadHistory(Base):
|
|||||||
据tmdbid、season、season_episode查询下载记录
|
据tmdbid、season、season_episode查询下载记录
|
||||||
tmdbid + mtype 或 title + year
|
tmdbid + mtype 或 title + year
|
||||||
"""
|
"""
|
||||||
result = None
|
|
||||||
# TMDBID + 类型
|
# TMDBID + 类型
|
||||||
if tmdbid and mtype:
|
if tmdbid and mtype:
|
||||||
# 电视剧某季某集
|
# 电视剧某季某集
|
||||||
if season and episode:
|
if season and episode:
|
||||||
result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid,
|
return db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid,
|
||||||
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,
|
return 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,
|
return 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:
|
||||||
# 电视剧某季某集
|
# 电视剧某季某集
|
||||||
if season and episode:
|
if season and episode:
|
||||||
result = db.query(DownloadHistory).filter(DownloadHistory.title == title,
|
return db.query(DownloadHistory).filter(DownloadHistory.title == title,
|
||||||
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,
|
return 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,
|
return 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:
|
|
||||||
return list(result)
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -144,13 +140,12 @@ class DownloadHistory(Base):
|
|||||||
查询某用户某时间之后的下载历史
|
查询某用户某时间之后的下载历史
|
||||||
"""
|
"""
|
||||||
if username:
|
if username:
|
||||||
result = db.query(DownloadHistory).filter(DownloadHistory.date < date,
|
return db.query(DownloadHistory).filter(DownloadHistory.date < date,
|
||||||
DownloadHistory.username == username).order_by(
|
DownloadHistory.username == username).order_by(
|
||||||
DownloadHistory.id.desc()).all()
|
DownloadHistory.id.desc()).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(DownloadHistory).filter(DownloadHistory.date < date).order_by(
|
return db.query(DownloadHistory).filter(DownloadHistory.date < date).order_by(
|
||||||
DownloadHistory.id.desc()).all()
|
DownloadHistory.id.desc()).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -173,12 +168,11 @@ class DownloadHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_type(db: Session, mtype: str, days: int):
|
def list_by_type(db: Session, mtype: str, days: int):
|
||||||
result = db.query(DownloadHistory) \
|
return db.query(DownloadHistory) \
|
||||||
.filter(DownloadHistory.type == mtype,
|
.filter(DownloadHistory.type == mtype,
|
||||||
DownloadHistory.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
DownloadHistory.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
||||||
time.localtime(time.time() - 86400 * int(days)))
|
time.localtime(time.time() - 86400 * int(days)))
|
||||||
).all()
|
).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
|
|
||||||
class DownloadFiles(Base):
|
class DownloadFiles(Base):
|
||||||
@@ -205,12 +199,10 @@ class DownloadFiles(Base):
|
|||||||
@db_query
|
@db_query
|
||||||
def get_by_hash(db: Session, download_hash: str, state: Optional[int] = None):
|
def get_by_hash(db: Session, download_hash: str, state: Optional[int] = None):
|
||||||
if state:
|
if state:
|
||||||
result = db.query(DownloadFiles).filter(DownloadFiles.download_hash == download_hash,
|
return db.query(DownloadFiles).filter(DownloadFiles.download_hash == download_hash,
|
||||||
DownloadFiles.state == state).all()
|
DownloadFiles.state == state).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(DownloadFiles).filter(DownloadFiles.download_hash == download_hash).all()
|
return db.query(DownloadFiles).filter(DownloadFiles.download_hash == download_hash).all()
|
||||||
|
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -225,8 +217,7 @@ class DownloadFiles(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_by_savepath(db: Session, savepath: str):
|
def get_by_savepath(db: Session, savepath: str):
|
||||||
result = db.query(DownloadFiles).filter(DownloadFiles.savepath == savepath).all()
|
return db.query(DownloadFiles).filter(DownloadFiles.savepath == savepath).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_update
|
@db_update
|
||||||
|
|||||||
@@ -37,7 +37,4 @@ class Message(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30):
|
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30):
|
||||||
result = db.query(Message).order_by(Message.reg_time.desc()).offset((page - 1) * count).limit(
|
return db.query(Message).order_by(Message.reg_time.asc()).offset((page - 1) * count).limit(count).all()
|
||||||
count).all()
|
|
||||||
result.sort(key=lambda x: x.reg_time, reverse=False)
|
|
||||||
return list(result)
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class PluginData(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_plugin_data(db: Session, plugin_id: str):
|
def get_plugin_data(db: Session, plugin_id: str):
|
||||||
result = db.query(PluginData).filter(PluginData.plugin_id == plugin_id).all()
|
return db.query(PluginData).filter(PluginData.plugin_id == plugin_id).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -37,5 +36,4 @@ class PluginData(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_plugin_data_by_plugin_id(db: Session, plugin_id: str):
|
def get_plugin_data_by_plugin_id(db: Session, plugin_id: str):
|
||||||
result = db.query(PluginData).filter(PluginData.plugin_id == plugin_id).all()
|
return db.query(PluginData).filter(PluginData.plugin_id == plugin_id).all()
|
||||||
return list(result)
|
|
||||||
|
|||||||
@@ -62,20 +62,17 @@ class Site(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_actives(db: Session):
|
def get_actives(db: Session):
|
||||||
result = db.query(Site).filter(Site.is_active == 1).all()
|
return db.query(Site).filter(Site.is_active == 1).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_order_by_pri(db: Session):
|
def list_order_by_pri(db: Session):
|
||||||
result = db.query(Site).order_by(Site.pri).all()
|
return db.query(Site).order_by(Site.pri).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_domains_by_ids(db: Session, ids: list):
|
def get_domains_by_ids(db: Session, ids: list):
|
||||||
result = db.query(Site.domain).filter(Site.id.in_(ids)).all()
|
return [r[0] for r in db.query(Site.domain).filter(Site.id.in_(ids)).all()]
|
||||||
return [r[0] for r in result]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_update
|
@db_update
|
||||||
|
|||||||
+14
-19
@@ -104,12 +104,10 @@ class Subscribe(Base):
|
|||||||
def get_by_state(db: Session, state: str):
|
def get_by_state(db: Session, state: str):
|
||||||
# 如果 state 为空或 None,返回所有订阅
|
# 如果 state 为空或 None,返回所有订阅
|
||||||
if not state:
|
if not state:
|
||||||
result = db.query(Subscribe).all()
|
return db.query(Subscribe).all()
|
||||||
else:
|
else:
|
||||||
# 如果传入的状态不为空,拆分成多个状态
|
# 如果传入的状态不为空,拆分成多个状态
|
||||||
states = state.split(',')
|
return db.query(Subscribe).filter(Subscribe.state.in_(state.split(','))).all()
|
||||||
result = db.query(Subscribe).filter(Subscribe.state.in_(states)).all()
|
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -123,11 +121,10 @@ class Subscribe(Base):
|
|||||||
@db_query
|
@db_query
|
||||||
def get_by_tmdbid(db: Session, tmdbid: int, season: Optional[int] = None):
|
def get_by_tmdbid(db: Session, tmdbid: int, season: Optional[int] = None):
|
||||||
if season:
|
if season:
|
||||||
result = db.query(Subscribe).filter(Subscribe.tmdbid == tmdbid,
|
return db.query(Subscribe).filter(Subscribe.tmdbid == tmdbid,
|
||||||
Subscribe.season == season).all()
|
Subscribe.season == season).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(Subscribe).filter(Subscribe.tmdbid == tmdbid).all()
|
return db.query(Subscribe).filter(Subscribe.tmdbid == tmdbid).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -170,26 +167,24 @@ class Subscribe(Base):
|
|||||||
def list_by_username(db: Session, username: str, state: Optional[str] = None, mtype: Optional[str] = None):
|
def list_by_username(db: Session, username: str, state: Optional[str] = None, mtype: Optional[str] = None):
|
||||||
if mtype:
|
if mtype:
|
||||||
if state:
|
if state:
|
||||||
result = db.query(Subscribe).filter(Subscribe.state == state,
|
return db.query(Subscribe).filter(Subscribe.state == state,
|
||||||
Subscribe.username == username,
|
Subscribe.username == username,
|
||||||
Subscribe.type == mtype).all()
|
Subscribe.type == mtype).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(Subscribe).filter(Subscribe.username == username,
|
return db.query(Subscribe).filter(Subscribe.username == username,
|
||||||
Subscribe.type == mtype).all()
|
Subscribe.type == mtype).all()
|
||||||
else:
|
else:
|
||||||
if state:
|
if state:
|
||||||
result = db.query(Subscribe).filter(Subscribe.state == state,
|
return db.query(Subscribe).filter(Subscribe.state == state,
|
||||||
Subscribe.username == username).all()
|
Subscribe.username == username).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(Subscribe).filter(Subscribe.username == username).all()
|
return db.query(Subscribe).filter(Subscribe.username == username).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_type(db: Session, mtype: str, days: int):
|
def list_by_type(db: Session, mtype: str, days: int):
|
||||||
result = db.query(Subscribe) \
|
return db.query(Subscribe) \
|
||||||
.filter(Subscribe.type == mtype,
|
.filter(Subscribe.type == mtype,
|
||||||
Subscribe.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
Subscribe.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
||||||
time.localtime(time.time() - 86400 * int(days)))
|
time.localtime(time.time() - 86400 * int(days)))
|
||||||
).all()
|
).all()
|
||||||
return list(result)
|
|
||||||
|
|||||||
@@ -75,12 +75,11 @@ class SubscribeHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_type(db: Session, mtype: str, page: Optional[int] = 1, count: Optional[int] = 30):
|
def list_by_type(db: Session, mtype: str, page: Optional[int] = 1, count: Optional[int] = 30):
|
||||||
result = db.query(SubscribeHistory).filter(
|
return db.query(SubscribeHistory).filter(
|
||||||
SubscribeHistory.type == mtype
|
SubscribeHistory.type == mtype
|
||||||
).order_by(
|
).order_by(
|
||||||
SubscribeHistory.date.desc()
|
SubscribeHistory.date.desc()
|
||||||
).offset((page - 1) * count).limit(count).all()
|
).offset((page - 1) * count).limit(count).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
|
|||||||
@@ -63,35 +63,33 @@ class TransferHistory(Base):
|
|||||||
@db_query
|
@db_query
|
||||||
def list_by_title(db: Session, title: str, page: Optional[int] = 1, count: Optional[int] = 30, status: bool = None):
|
def list_by_title(db: Session, title: str, page: Optional[int] = 1, count: Optional[int] = 30, status: bool = None):
|
||||||
if status is not None:
|
if status is not None:
|
||||||
result = db.query(TransferHistory).filter(
|
return db.query(TransferHistory).filter(
|
||||||
TransferHistory.status == status
|
TransferHistory.status == status
|
||||||
).order_by(
|
).order_by(
|
||||||
TransferHistory.date.desc()
|
TransferHistory.date.desc()
|
||||||
).offset((page - 1) * count).limit(count).all()
|
).offset((page - 1) * count).limit(count).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(TransferHistory).filter(or_(
|
return db.query(TransferHistory).filter(or_(
|
||||||
TransferHistory.title.like(f'%{title}%'),
|
TransferHistory.title.like(f'%{title}%'),
|
||||||
TransferHistory.src.like(f'%{title}%'),
|
TransferHistory.src.like(f'%{title}%'),
|
||||||
TransferHistory.dest.like(f'%{title}%'),
|
TransferHistory.dest.like(f'%{title}%'),
|
||||||
)).order_by(
|
)).order_by(
|
||||||
TransferHistory.date.desc()
|
TransferHistory.date.desc()
|
||||||
).offset((page - 1) * count).limit(count).all()
|
).offset((page - 1) * count).limit(count).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30, status: bool = None):
|
def list_by_page(db: Session, page: Optional[int] = 1, count: Optional[int] = 30, status: bool = None):
|
||||||
if status is not None:
|
if status is not None:
|
||||||
result = db.query(TransferHistory).filter(
|
return db.query(TransferHistory).filter(
|
||||||
TransferHistory.status == status
|
TransferHistory.status == status
|
||||||
).order_by(
|
).order_by(
|
||||||
TransferHistory.date.desc()
|
TransferHistory.date.desc()
|
||||||
).offset((page - 1) * count).limit(count).all()
|
).offset((page - 1) * count).limit(count).all()
|
||||||
else:
|
else:
|
||||||
result = db.query(TransferHistory).order_by(
|
return db.query(TransferHistory).order_by(
|
||||||
TransferHistory.date.desc()
|
TransferHistory.date.desc()
|
||||||
).offset((page - 1) * count).limit(count).all()
|
).offset((page - 1) * count).limit(count).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -115,8 +113,7 @@ class TransferHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by_hash(db: Session, download_hash: str):
|
def list_by_hash(db: Session, download_hash: str):
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.download_hash == download_hash).all()
|
return db.query(TransferHistory).filter(TransferHistory.download_hash == download_hash).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -128,8 +125,7 @@ class TransferHistory(Base):
|
|||||||
TransferHistory.id.label('id')).filter(
|
TransferHistory.id.label('id')).filter(
|
||||||
TransferHistory.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
TransferHistory.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
||||||
time.localtime(time.time() - 86400 * days))).subquery()
|
time.localtime(time.time() - 86400 * days))).subquery()
|
||||||
result = db.query(sub_query.c.date, func.count(sub_query.c.id)).group_by(sub_query.c.date).all()
|
return db.query(sub_query.c.date, func.count(sub_query.c.id)).group_by(sub_query.c.date).all()
|
||||||
return list(result)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
@@ -153,70 +149,67 @@ class TransferHistory(Base):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def list_by(db: Session, mtype: Optional[str] = None, title: Optional[str] = None, year: Optional[str] = None, season: Optional[str] = None,
|
def list_by(db: Session, mtype: Optional[str] = None, title: Optional[str] = None, year: Optional[str] = None,
|
||||||
|
season: Optional[str] = None,
|
||||||
episode: Optional[str] = None, tmdbid: Optional[int] = None, dest: Optional[str] = None):
|
episode: Optional[str] = None, tmdbid: Optional[int] = None, dest: Optional[str] = None):
|
||||||
"""
|
"""
|
||||||
据tmdbid、season、season_episode查询转移记录
|
据tmdbid、season、season_episode查询转移记录
|
||||||
tmdbid + mtype 或 title + year 必输
|
tmdbid + mtype 或 title + year 必输
|
||||||
"""
|
"""
|
||||||
result = None
|
|
||||||
# TMDBID + 类型
|
# TMDBID + 类型
|
||||||
if tmdbid and mtype:
|
if tmdbid and mtype:
|
||||||
# 电视剧某季某集
|
# 电视剧某季某集
|
||||||
if season and episode:
|
if season and episode:
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
return db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
||||||
TransferHistory.type == mtype,
|
TransferHistory.type == mtype,
|
||||||
TransferHistory.seasons == season,
|
TransferHistory.seasons == season,
|
||||||
TransferHistory.episodes == episode,
|
TransferHistory.episodes == episode,
|
||||||
TransferHistory.dest == dest).all()
|
TransferHistory.dest == dest).all()
|
||||||
# 电视剧某季
|
# 电视剧某季
|
||||||
elif season:
|
elif season:
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
return db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
||||||
TransferHistory.type == mtype,
|
TransferHistory.type == mtype,
|
||||||
TransferHistory.seasons == season).all()
|
TransferHistory.seasons == season).all()
|
||||||
else:
|
else:
|
||||||
if dest:
|
if dest:
|
||||||
# 电影
|
# 电影
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
return db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
||||||
TransferHistory.type == mtype,
|
TransferHistory.type == mtype,
|
||||||
TransferHistory.dest == dest).all()
|
TransferHistory.dest == dest).all()
|
||||||
else:
|
else:
|
||||||
# 电视剧所有季集
|
# 电视剧所有季集
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
return db.query(TransferHistory).filter(TransferHistory.tmdbid == tmdbid,
|
||||||
TransferHistory.type == mtype).all()
|
TransferHistory.type == mtype).all()
|
||||||
# 标题 + 年份
|
# 标题 + 年份
|
||||||
elif title and year:
|
elif title and year:
|
||||||
# 电视剧某季某集
|
# 电视剧某季某集
|
||||||
if season and episode:
|
if season and episode:
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.title == title,
|
return db.query(TransferHistory).filter(TransferHistory.title == title,
|
||||||
TransferHistory.year == year,
|
TransferHistory.year == year,
|
||||||
TransferHistory.seasons == season,
|
TransferHistory.seasons == season,
|
||||||
TransferHistory.episodes == episode,
|
TransferHistory.episodes == episode,
|
||||||
TransferHistory.dest == dest).all()
|
TransferHistory.dest == dest).all()
|
||||||
# 电视剧某季
|
# 电视剧某季
|
||||||
elif season:
|
elif season:
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.title == title,
|
return db.query(TransferHistory).filter(TransferHistory.title == title,
|
||||||
TransferHistory.year == year,
|
TransferHistory.year == year,
|
||||||
TransferHistory.seasons == season).all()
|
TransferHistory.seasons == season).all()
|
||||||
else:
|
else:
|
||||||
if dest:
|
if dest:
|
||||||
# 电影
|
# 电影
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.title == title,
|
return db.query(TransferHistory).filter(TransferHistory.title == title,
|
||||||
TransferHistory.year == year,
|
TransferHistory.year == year,
|
||||||
TransferHistory.dest == dest).all()
|
TransferHistory.dest == dest).all()
|
||||||
else:
|
else:
|
||||||
# 电视剧所有季集
|
# 电视剧所有季集
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.title == title,
|
return db.query(TransferHistory).filter(TransferHistory.title == title,
|
||||||
TransferHistory.year == year).all()
|
TransferHistory.year == year).all()
|
||||||
# 类型 + 转移路径(emby webhook season无tmdbid场景)
|
# 类型 + 转移路径(emby webhook season无tmdbid场景)
|
||||||
elif mtype and season and dest:
|
elif mtype and season and dest:
|
||||||
# 电视剧某季
|
# 电视剧某季
|
||||||
result = db.query(TransferHistory).filter(TransferHistory.type == mtype,
|
return db.query(TransferHistory).filter(TransferHistory.type == mtype,
|
||||||
TransferHistory.seasons == season,
|
TransferHistory.seasons == season,
|
||||||
TransferHistory.dest.like(f"{dest}%")).all()
|
TransferHistory.dest.like(f"{dest}%")).all()
|
||||||
|
|
||||||
if result:
|
|
||||||
return list(result)
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user