mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-05-09 22:13:00 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92cb066748 | ||
|
|
6c8ef4122b | ||
|
|
971b02ac8c | ||
|
|
d4a9643f47 | ||
|
|
e56d31fedc | ||
|
|
b9d91c5cd7 | ||
|
|
57cdb57331 | ||
|
|
0f7a7ef44f | ||
|
|
6267b3f670 | ||
|
|
82f77b4729 | ||
|
|
58da0ebb4f | ||
|
|
7a43e43478 | ||
|
|
e5ec02e043 | ||
|
|
2944c343a8 | ||
|
|
940cc566c8 | ||
|
|
db7b2cdcac | ||
|
|
8111cf5dc8 |
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -1,6 +1,11 @@
|
||||
name: MoviePilot Builder
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- version.py
|
||||
|
||||
jobs:
|
||||
Docker-build:
|
||||
|
||||
@@ -10,8 +10,7 @@ from ruamel.yaml import CommentedMap
|
||||
from transmission_rpc import File
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.context import Context
|
||||
from app.core.context import MediaInfo, TorrentInfo
|
||||
from app.core.context import Context, MediaInfo, TorrentInfo
|
||||
from app.core.event import EventManager
|
||||
from app.core.meta import MetaBase
|
||||
from app.core.module import ModuleManager
|
||||
@@ -79,6 +78,7 @@ class ChainBase(metaclass=ABCMeta):
|
||||
def run_module(self, method: str, *args, **kwargs) -> Any:
|
||||
"""
|
||||
运行包含该方法的所有模块,然后返回结果
|
||||
当kwargs包含命名参数raise_exception时,如模块方法抛出异常且raise_exception为True,则同步抛出异常
|
||||
"""
|
||||
|
||||
def is_result_empty(ret):
|
||||
@@ -117,6 +117,8 @@ class ChainBase(metaclass=ABCMeta):
|
||||
# 中止继续执行
|
||||
break
|
||||
except Exception as err:
|
||||
if kwargs.get("raise_exception"):
|
||||
raise
|
||||
logger.error(
|
||||
f"运行模块 {module_id}.{method} 出错:{str(err)}\n{traceback.format_exc()}")
|
||||
self.messagehelper.put(title=f"{module_name}发生了错误",
|
||||
@@ -166,7 +168,8 @@ class ChainBase(metaclass=ABCMeta):
|
||||
tmdbid=tmdbid, doubanid=doubanid, bangumiid=bangumiid, cache=cache)
|
||||
|
||||
def match_doubaninfo(self, name: str, imdbid: str = None,
|
||||
mtype: MediaType = None, year: str = None, season: int = None) -> Optional[dict]:
|
||||
mtype: MediaType = None, year: str = None, season: int = None,
|
||||
raise_exception: bool = False) -> Optional[dict]:
|
||||
"""
|
||||
搜索和匹配豆瓣信息
|
||||
:param name: 标题
|
||||
@@ -174,9 +177,10 @@ class ChainBase(metaclass=ABCMeta):
|
||||
:param mtype: 类型
|
||||
:param year: 年份
|
||||
:param season: 季
|
||||
:param raise_exception: 触发速率限制时是否抛出异常
|
||||
"""
|
||||
return self.run_module("match_doubaninfo", name=name, imdbid=imdbid,
|
||||
mtype=mtype, year=year, season=season)
|
||||
mtype=mtype, year=year, season=season, raise_exception=raise_exception)
|
||||
|
||||
def match_tmdbinfo(self, name: str, mtype: MediaType = None,
|
||||
year: str = None, season: int = None) -> Optional[dict]:
|
||||
@@ -214,14 +218,15 @@ class ChainBase(metaclass=ABCMeta):
|
||||
image_prefix=image_prefix, image_type=image_type,
|
||||
season=season, episode=episode)
|
||||
|
||||
def douban_info(self, doubanid: str, mtype: MediaType = None) -> Optional[dict]:
|
||||
def douban_info(self, doubanid: str, mtype: MediaType = None, raise_exception: bool = False) -> Optional[dict]:
|
||||
"""
|
||||
获取豆瓣信息
|
||||
:param doubanid: 豆瓣ID
|
||||
:param mtype: 媒体类型
|
||||
:return: 豆瓣信息
|
||||
:param raise_exception: 触发速率限制时是否抛出异常
|
||||
"""
|
||||
return self.run_module("douban_info", doubanid=doubanid, mtype=mtype)
|
||||
return self.run_module("douban_info", doubanid=doubanid, mtype=mtype, raise_exception=raise_exception)
|
||||
|
||||
def tvdb_info(self, tvdbid: int) -> Optional[dict]:
|
||||
"""
|
||||
|
||||
@@ -949,6 +949,11 @@ class TransferChain(ChainBase):
|
||||
for file in files:
|
||||
Path(file).unlink()
|
||||
logger.warn(f"文件 {path} 已删除")
|
||||
# 删除thumb图片
|
||||
thumb_file = path.parent / (path.stem + "-thumb.jpg")
|
||||
if thumb_file.exists():
|
||||
thumb_file.unlink()
|
||||
logger.info(f"文件 {thumb_file} 已删除")
|
||||
# 需要删除父目录
|
||||
elif str(path.parent) == str(path.root):
|
||||
# 根目录,不删除
|
||||
|
||||
@@ -241,6 +241,29 @@ class Settings(BaseSettings):
|
||||
# 服务器地址,对应 https://github.com/jxxghp/MoviePilot-Server 项目
|
||||
MP_SERVER_HOST: str = "https://movie-pilot.org"
|
||||
|
||||
# 【已弃用】刮削入库的媒体文件
|
||||
SCRAP_METADATA: bool = True
|
||||
# 【已弃用】下载保存目录,容器内映射路径需要一致
|
||||
DOWNLOAD_PATH: Optional[str] = None
|
||||
# 【已弃用】电影下载保存目录,容器内映射路径需要一致
|
||||
DOWNLOAD_MOVIE_PATH: Optional[str] = None
|
||||
# 【已弃用】电视剧下载保存目录,容器内映射路径需要一致
|
||||
DOWNLOAD_TV_PATH: Optional[str] = None
|
||||
# 【已弃用】动漫下载保存目录,容器内映射路径需要一致
|
||||
DOWNLOAD_ANIME_PATH: Optional[str] = None
|
||||
# 【已弃用】下载目录二级分类
|
||||
DOWNLOAD_CATEGORY: bool = False
|
||||
# 【已弃用】媒体库目录,多个目录使用,分隔
|
||||
LIBRARY_PATH: Optional[str] = None
|
||||
# 【已弃用】电影媒体库目录名
|
||||
LIBRARY_MOVIE_NAME: str = "电影"
|
||||
# 【已弃用】电视剧媒体库目录名
|
||||
LIBRARY_TV_NAME: str = "电视剧"
|
||||
# 【已弃用】动漫媒体库目录名,不设置时使用电视剧目录
|
||||
LIBRARY_ANIME_NAME: Optional[str] = None
|
||||
# 【已弃用】二级分类
|
||||
LIBRARY_CATEGORY: bool = True
|
||||
|
||||
@validator("SUBSCRIBE_RSS_INTERVAL",
|
||||
"COOKIECLOUD_INTERVAL",
|
||||
"MEDIASERVER_SYNC_INTERVAL",
|
||||
|
||||
@@ -15,6 +15,7 @@ from app.modules.douban.apiv2 import DoubanApi
|
||||
from app.modules.douban.douban_cache import DoubanCache
|
||||
from app.modules.douban.scraper import DoubanScraper
|
||||
from app.schemas import MediaPerson
|
||||
from app.schemas.exception import APIRateLimitException
|
||||
from app.schemas.types import MediaType
|
||||
from app.utils.common import retry
|
||||
from app.utils.http import RequestUtils
|
||||
@@ -147,11 +148,12 @@ class DoubanModule(_ModuleBase):
|
||||
|
||||
return None
|
||||
|
||||
def douban_info(self, doubanid: str, mtype: MediaType = None) -> Optional[dict]:
|
||||
def douban_info(self, doubanid: str, mtype: MediaType = None, raise_exception: bool = True) -> Optional[dict]:
|
||||
"""
|
||||
获取豆瓣信息
|
||||
:param doubanid: 豆瓣ID
|
||||
:param mtype: 媒体类型
|
||||
:param raise_exception: 触发速率限制时是否抛出异常
|
||||
:return: 豆瓣信息
|
||||
"""
|
||||
"""
|
||||
@@ -427,7 +429,10 @@ class DoubanModule(_ModuleBase):
|
||||
info = self.doubanapi.tv_detail(doubanid)
|
||||
if info:
|
||||
if "subject_ip_rate_limit" in info.get("msg", ""):
|
||||
logger.warn(f"触发豆瓣IP速率限制,错误信息:{info} ...")
|
||||
msg = f"触发豆瓣IP速率限制,错误信息:{info} ..."
|
||||
logger.warn(msg)
|
||||
if raise_exception:
|
||||
raise APIRateLimitException(msg)
|
||||
return None
|
||||
celebrities = self.doubanapi.tv_celebrities(doubanid)
|
||||
if celebrities:
|
||||
@@ -442,7 +447,10 @@ class DoubanModule(_ModuleBase):
|
||||
info = self.doubanapi.movie_detail(doubanid)
|
||||
if info:
|
||||
if "subject_ip_rate_limit" in info.get("msg", ""):
|
||||
logger.warn(f"触发豆瓣IP速率限制,错误信息:{info} ...")
|
||||
msg = f"触发豆瓣IP速率限制,错误信息:{info} ..."
|
||||
logger.warn(msg)
|
||||
if raise_exception:
|
||||
raise APIRateLimitException(msg)
|
||||
return None
|
||||
celebrities = self.doubanapi.movie_celebrities(doubanid)
|
||||
if celebrities:
|
||||
@@ -601,7 +609,8 @@ class DoubanModule(_ModuleBase):
|
||||
|
||||
@retry(Exception, 5, 3, 3, logger=logger)
|
||||
def match_doubaninfo(self, name: str, imdbid: str = None,
|
||||
mtype: MediaType = None, year: str = None, season: int = None) -> dict:
|
||||
mtype: MediaType = None, year: str = None, season: int = None,
|
||||
raise_exception: bool = False) -> dict:
|
||||
"""
|
||||
搜索和匹配豆瓣信息
|
||||
:param name: 名称
|
||||
@@ -609,6 +618,7 @@ class DoubanModule(_ModuleBase):
|
||||
:param mtype: 类型
|
||||
:param year: 年份
|
||||
:param season: 季号
|
||||
:param raise_exception: 触发速率限制时是否抛出异常
|
||||
"""
|
||||
if imdbid:
|
||||
# 优先使用IMDBID查询
|
||||
@@ -624,13 +634,19 @@ class DoubanModule(_ModuleBase):
|
||||
# 搜索
|
||||
logger.info(f"开始使用名称 {name} 匹配豆瓣信息 ...")
|
||||
result = self.doubanapi.search(f"{name} {year or ''}".strip())
|
||||
if not result or not result.get("items"):
|
||||
if not result:
|
||||
logger.warn(f"未找到 {name} 的豆瓣信息")
|
||||
return {}
|
||||
# 触发rate limit
|
||||
if "search_access_rate_limit" in result.values():
|
||||
logger.warn(f"触发豆瓣API速率限制 错误信息 {result} ...")
|
||||
raise Exception("触发豆瓣API速率限制")
|
||||
msg = f"触发豆瓣API速率限制,错误信息:{result} ..."
|
||||
logger.warn(msg)
|
||||
if raise_exception:
|
||||
raise APIRateLimitException(msg)
|
||||
return {}
|
||||
if not result.get("items"):
|
||||
logger.warn(f"未找到 {name} 的豆瓣信息")
|
||||
return {}
|
||||
for item_obj in result.get("items"):
|
||||
type_name = item_obj.get("type_name")
|
||||
if type_name not in [MediaType.TV.value, MediaType.MOVIE.value]:
|
||||
|
||||
@@ -690,6 +690,10 @@ class FileTransferModule(_ModuleBase):
|
||||
"doubanid": mediainfo.douban_id,
|
||||
# 季号
|
||||
"season": meta.season_seq,
|
||||
# 季年份根据season值获取
|
||||
"season_year": mediainfo.season_years.get(
|
||||
int(meta.season_seq),
|
||||
None) if (mediainfo.season_years and meta.season_seq) else None,
|
||||
# 集号
|
||||
"episode": meta.episode_seqs,
|
||||
# 季集 SxxExx
|
||||
|
||||
@@ -15,3 +15,4 @@ from .tmdb import *
|
||||
from .transfer import *
|
||||
from .file import *
|
||||
from .filetransfer import *
|
||||
from .exception import *
|
||||
|
||||
14
app/schemas/exception.py
Normal file
14
app/schemas/exception.py
Normal file
@@ -0,0 +1,14 @@
|
||||
class ImmediateException(Exception):
|
||||
"""
|
||||
用于立即抛出异常而不重试的特殊异常类。
|
||||
当不希望使用重试机制时,可以抛出此异常。
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class APIRateLimitException(ImmediateException):
|
||||
"""
|
||||
用于表示API速率限制的异常类。
|
||||
当API调用触发速率限制时,可以抛出此异常以立即终止操作并报告错误。
|
||||
"""
|
||||
pass
|
||||
@@ -6,6 +6,8 @@ from typing import Any
|
||||
from Crypto import Random
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
from app.schemas.exception import ImmediateException
|
||||
|
||||
|
||||
def retry(ExceptionToCheck: Any,
|
||||
tries: int = 3, delay: int = 3, backoff: int = 2, logger: Any = None):
|
||||
@@ -23,6 +25,8 @@ def retry(ExceptionToCheck: Any,
|
||||
while mtries > 1:
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except ImmediateException:
|
||||
raise
|
||||
except ExceptionToCheck as e:
|
||||
msg = f"{str(e)}, {mdelay} 秒后重试 ..."
|
||||
if logger:
|
||||
|
||||
30
database/versions/06abf3e7090b_1_0_11.py
Normal file
30
database/versions/06abf3e7090b_1_0_11.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1.0.11
|
||||
|
||||
Revision ID: 06abf3e7090b
|
||||
Revises: d633ca6cd572
|
||||
Create Date: 2023-10-27 12:22:56.213376
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '06abf3e7090b'
|
||||
down_revision = 'd633ca6cd572'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("downloadhistory") as batch_op:
|
||||
batch_op.add_column(sa.Column('username', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/127a25fdf0e8_1_0_13.py
Normal file
30
database/versions/127a25fdf0e8_1_0_13.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1.0.13
|
||||
|
||||
Revision ID: 127a25fdf0e8
|
||||
Revises: d71e624f0208
|
||||
Create Date: 2024-02-24 03:11:32.005540
|
||||
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '127a25fdf0e8'
|
||||
down_revision = 'd71e624f0208'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('search_imdbid', sa.Integer, nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
31
database/versions/14f1813ae8e3_1_0_1.py
Normal file
31
database/versions/14f1813ae8e3_1_0_1.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""1.0.1
|
||||
|
||||
Revision ID: 14f1813ae8e3
|
||||
Revises: 9f4edd55c2d4
|
||||
Create Date: 2023-07-27 12:34:57.839443
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '14f1813ae8e3'
|
||||
down_revision = '9f4edd55c2d4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('best_version', sa.Integer, nullable=True))
|
||||
batch_op.add_column(sa.Column('current_priority', sa.Integer, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/1e169250e949_1_0_4.py
Normal file
30
database/versions/1e169250e949_1_0_4.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1.0.4
|
||||
|
||||
Revision ID: 1e169250e949
|
||||
Revises: 52ab4930be04
|
||||
Create Date: 2023-09-01 09:56:33.907661
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1e169250e949'
|
||||
down_revision = '52ab4930be04'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('date', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
38
database/versions/232dfa044617_1_0_6.py
Normal file
38
database/versions/232dfa044617_1_0_6.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""1.0.6
|
||||
|
||||
Revision ID: 232dfa044617
|
||||
Revises: e734c7fe6056
|
||||
Create Date: 2023-09-19 21:34:41.994617
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '232dfa044617'
|
||||
down_revision = 'e734c7fe6056'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
# 搜索优先级
|
||||
op.execute("delete from systemconfig where key = 'SearchFilterRules';")
|
||||
op.execute(
|
||||
"insert into systemconfig(key, value) VALUES('SearchFilterRules', (select value from systemconfig where key= 'FilterRules'));")
|
||||
# 订阅优先级
|
||||
op.execute("delete from systemconfig where key = 'SubscribeFilterRules';")
|
||||
op.execute(
|
||||
"insert into systemconfig(key, value) VALUES('SubscribeFilterRules', (select value from systemconfig where key= 'FilterRules'));")
|
||||
# 洗版优先级
|
||||
op.execute("delete from systemconfig where key = 'BestVersionFilterRules';")
|
||||
op.execute(
|
||||
"insert into systemconfig(key, value) VALUES('BestVersionFilterRules', (select value from systemconfig where key= 'FilterRules2'));")
|
||||
# 删除旧的优先级规则
|
||||
op.execute("delete from systemconfig where key = 'FilterRules';")
|
||||
op.execute("delete from systemconfig where key = 'FilterRules2';")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
27
database/versions/30329639c12b_1_0_7.py
Normal file
27
database/versions/30329639c12b_1_0_7.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""1.0.7
|
||||
|
||||
Revision ID: 30329639c12b
|
||||
Revises: 232dfa044617
|
||||
Create Date: 2023-09-23 08:25:59.776488
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '30329639c12b'
|
||||
down_revision = '232dfa044617'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("delete from systemconfig where key = 'DefaultFilterRules';")
|
||||
op.execute(
|
||||
"insert into systemconfig(key, value) VALUES('DefaultFilterRules', (select value from systemconfig where key= 'DefaultIncludeExcludeFilter'));")
|
||||
op.execute("delete from systemconfig where key = 'DefaultIncludeExcludeFilter';")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
28
database/versions/52ab4930be04_1_0_3.py
Normal file
28
database/versions/52ab4930be04_1_0_3.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""1_0_3
|
||||
|
||||
Revision ID: 52ab4930be04
|
||||
Revises: ec5fb51fc300
|
||||
Create Date: 2023-08-28 13:21:45.152012
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '52ab4930be04'
|
||||
down_revision = 'ec5fb51fc300'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("delete from systemconfig where key = 'RssSites';")
|
||||
op.execute("insert into systemconfig(key, value) VALUES('RssSites', (select value from systemconfig where key= 'IndexerSites'));")
|
||||
op.execute("delete from systemconfig where key = 'SearchResults';")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
34
database/versions/5813aaa7cb3a_1_0_15.py
Normal file
34
database/versions/5813aaa7cb3a_1_0_15.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""1.0.15
|
||||
|
||||
Revision ID: 5813aaa7cb3a
|
||||
Revises: f94cd1217fd7
|
||||
Create Date: 2024-03-17 09:04:51.785716
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '5813aaa7cb3a'
|
||||
down_revision = 'f94cd1217fd7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("message") as batch_op:
|
||||
batch_op.add_column(sa.Column('note', sa.String, nullable=True))
|
||||
try:
|
||||
op.create_index('ix_message_reg_time', 'message', ['reg_time'], unique=False)
|
||||
except Exception as err:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
31
database/versions/735c01e0453d_1_0_18.py
Normal file
31
database/versions/735c01e0453d_1_0_18.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""1.0.18
|
||||
|
||||
Revision ID: 735c01e0453d
|
||||
Revises: 9cb3993e340e
|
||||
Create Date: 2024-04-29 19:40:38.375072
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '735c01e0453d'
|
||||
down_revision = '9cb3993e340e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("site") as batch_op:
|
||||
batch_op.add_column(sa.Column('apikey', sa.VARCHAR))
|
||||
batch_op.add_column(sa.Column('token', sa.VARCHAR))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/9cb3993e340e_1_0_17.py
Normal file
30
database/versions/9cb3993e340e_1_0_17.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1_0_17
|
||||
|
||||
Revision ID: 9cb3993e340e
|
||||
Revises: d146dea51516
|
||||
Create Date: 2024-03-28 14:36:35.588392
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9cb3993e340e'
|
||||
down_revision = 'd146dea51516'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("user") as batch_op:
|
||||
batch_op.add_column(sa.Column('is_otp', sa.BOOLEAN, server_default='0'))
|
||||
batch_op.add_column(sa.Column('otp_secret', sa.VARCHAR))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
32
database/versions/9f4edd55c2d4_1_0_0.py
Normal file
32
database/versions/9f4edd55c2d4_1_0_0.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""1.0.0
|
||||
|
||||
Revision ID: 9f4edd55c2d4
|
||||
Revises:
|
||||
Create Date: 2023-07-13 12:27:26.402317
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9f4edd55c2d4'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('sites', sa.Text, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
118
database/versions/a40261701909_1_0_20.py
Normal file
118
database/versions/a40261701909_1_0_20.py
Normal file
@@ -0,0 +1,118 @@
|
||||
"""1.0.20
|
||||
|
||||
Revision ID: a40261701909
|
||||
Revises: ae9d8ed8df97
|
||||
Create Date: 2024-05-22 19:16:21.374806
|
||||
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from alembic import op
|
||||
|
||||
from app.core.config import Settings
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a40261701909'
|
||||
down_revision = 'ae9d8ed8df97'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""
|
||||
升级目录配置
|
||||
"""
|
||||
# 实例化配置
|
||||
_settings = Settings(
|
||||
_env_file=Settings().CONFIG_PATH / "app.env",
|
||||
_env_file_encoding="utf-8"
|
||||
)
|
||||
# 下载目录配置升级
|
||||
download_dirs = []
|
||||
if _settings.DOWNLOAD_MOVIE_PATH:
|
||||
download_dirs.append({
|
||||
"type": "download",
|
||||
"name": "电影目录",
|
||||
"path": _settings.DOWNLOAD_MOVIE_PATH,
|
||||
"media_type": "电影",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.DOWNLOAD_CATEGORY else False,
|
||||
"priority": 1
|
||||
})
|
||||
if _settings.DOWNLOAD_TV_PATH:
|
||||
download_dirs.append({
|
||||
"type": "download",
|
||||
"name": "电视剧目录",
|
||||
"path": _settings.DOWNLOAD_TV_PATH,
|
||||
"media_type": "电视剧",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.DOWNLOAD_CATEGORY else False,
|
||||
"priority": 2
|
||||
})
|
||||
if _settings.DOWNLOAD_PATH:
|
||||
download_dirs.append({
|
||||
"type": "download",
|
||||
"name": "下载目录",
|
||||
"path": _settings.DOWNLOAD_PATH,
|
||||
"media_type": "",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.DOWNLOAD_CATEGORY else False,
|
||||
"priority": 4
|
||||
})
|
||||
|
||||
# 插入数据库,报错的话则更新
|
||||
if download_dirs:
|
||||
download_dirs_value = json.dumps(download_dirs)
|
||||
try:
|
||||
op.execute(f"INSERT INTO systemconfig (key, value) VALUES ('DownloadDirectories', '{download_dirs_value}');")
|
||||
except Exception as e:
|
||||
op.execute(f"UPDATE systemconfig SET value = '{download_dirs_value}' WHERE key = 'DownloadDirectories';")
|
||||
|
||||
# 媒体库目录配置升级
|
||||
library_dirs = []
|
||||
if _settings.LIBRARY_PATH:
|
||||
for library_path in _settings.LIBRARY_PATH.split(","):
|
||||
if _settings.LIBRARY_MOVIE_NAME:
|
||||
library_dirs.append({
|
||||
"type": "library",
|
||||
"name": "电影目录",
|
||||
"path": str(Path(library_path) / _settings.LIBRARY_MOVIE_NAME),
|
||||
"media_type": "电影",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.LIBRARY_CATEGORY else False,
|
||||
"scrape": True if _settings.SCRAP_METADATA else False,
|
||||
"priority": 1
|
||||
})
|
||||
if _settings.LIBRARY_TV_NAME:
|
||||
library_dirs.append({
|
||||
"type": "library",
|
||||
"name": "电视剧目录",
|
||||
"path": str(Path(library_path) / _settings.LIBRARY_TV_NAME),
|
||||
"media_type": "电视剧",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.LIBRARY_CATEGORY else False,
|
||||
"scrape": True if _settings.SCRAP_METADATA else False,
|
||||
"priority": 2
|
||||
})
|
||||
library_dirs.append({
|
||||
"type": "library",
|
||||
"name": "媒体库目录",
|
||||
"path": library_path,
|
||||
"media_type": "",
|
||||
"category": "",
|
||||
"auto_category": True if _settings.LIBRARY_CATEGORY else False,
|
||||
"scrape": True if _settings.SCRAP_METADATA else False,
|
||||
"priority": 4
|
||||
})
|
||||
# 插入数据库,报错的话则更新
|
||||
if library_dirs:
|
||||
library_dirs_value = json.dumps(library_dirs)
|
||||
try:
|
||||
op.execute(f"INSERT INTO systemconfig (key, value) VALUES ('LibraryDirectories', '{library_dirs_value}');")
|
||||
except Exception as e:
|
||||
op.execute(f"UPDATE systemconfig SET value = '{library_dirs_value}' WHERE key = 'LibraryDirectories';")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/a521fbc28b18_1_0_9.py
Normal file
30
database/versions/a521fbc28b18_1_0_9.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1_0_9
|
||||
|
||||
Revision ID: a521fbc28b18
|
||||
Revises: b2f011d3a8b7
|
||||
Create Date: 2023-09-28 13:37:16.479360
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a521fbc28b18'
|
||||
down_revision = 'b2f011d3a8b7'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("downloadhistory") as batch_op:
|
||||
batch_op.add_column(sa.Column('date', sa.String, nullable=True))
|
||||
batch_op.add_column(sa.Column('channel', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/ae9d8ed8df97_1_0_19.py
Normal file
30
database/versions/ae9d8ed8df97_1_0_19.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1.0.19
|
||||
|
||||
Revision ID: ae9d8ed8df97
|
||||
Revises: 735c01e0453d
|
||||
Create Date: 2024-05-16 14:21:46.108359
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ae9d8ed8df97'
|
||||
down_revision = '735c01e0453d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("site") as batch_op:
|
||||
batch_op.add_column(sa.Column('timeout', sa.INTEGER))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
29
database/versions/b2f011d3a8b7_1_0_8.py
Normal file
29
database/versions/b2f011d3a8b7_1_0_8.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""1_0_8
|
||||
|
||||
Revision ID: b2f011d3a8b7
|
||||
Revises: 30329639c12b
|
||||
Create Date: 2023-09-28 10:15:58.410003
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b2f011d3a8b7'
|
||||
down_revision = '30329639c12b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("downloadhistory") as batch_op:
|
||||
batch_op.add_column(sa.Column('userid', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
34
database/versions/d146dea51516_1_0_16.py
Normal file
34
database/versions/d146dea51516_1_0_16.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""1.0.16
|
||||
|
||||
Revision ID: d146dea51516
|
||||
Revises: 5813aaa7cb3a
|
||||
Create Date: 2024-03-18 18:13:38.099531
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd146dea51516'
|
||||
down_revision = '5813aaa7cb3a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('bangumiid', sa.Integer, nullable=True))
|
||||
try:
|
||||
op.create_index('ix_subscribe_bangumiid', 'subscribe', ['bangumiid'], unique=False)
|
||||
except Exception as err:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
32
database/versions/d633ca6cd572_1_0_10.py
Normal file
32
database/versions/d633ca6cd572_1_0_10.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""1.0.10
|
||||
|
||||
Revision ID: d633ca6cd572
|
||||
Revises: a521fbc28b18
|
||||
Create Date: 2023-10-12 08:54:49.728638
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd633ca6cd572'
|
||||
down_revision = 'a521fbc28b18'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('quality', sa.String, nullable=True))
|
||||
batch_op.add_column(sa.Column('resolution', sa.String, nullable=True))
|
||||
batch_op.add_column(sa.Column('effect', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
30
database/versions/d71e624f0208_1_0_12.py
Normal file
30
database/versions/d71e624f0208_1_0_12.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""1_0_12
|
||||
|
||||
Revision ID: d71e624f0208
|
||||
Revises: 06abf3e7090b
|
||||
Create Date: 2023-12-12 13:26:34.039497
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd71e624f0208'
|
||||
down_revision = '06abf3e7090b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('save_path', sa.String, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
27
database/versions/e734c7fe6056_1_0_5.py
Normal file
27
database/versions/e734c7fe6056_1_0_5.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""1.0.5
|
||||
|
||||
Revision ID: e734c7fe6056
|
||||
Revises: 1e169250e949
|
||||
Create Date: 2023-09-07 18:19:41.250957
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e734c7fe6056'
|
||||
down_revision = '1e169250e949'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
op.create_index('ix_transferhistory_tmdbid', 'transferhistory', ['tmdbid'], unique=False)
|
||||
except Exception as err:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
32
database/versions/ec5fb51fc300_1_0_2.py
Normal file
32
database/versions/ec5fb51fc300_1_0_2.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""1.0.2
|
||||
|
||||
Revision ID: ec5fb51fc300
|
||||
Revises: 14f1813ae8e3
|
||||
Create Date: 2023-08-12 17:55:06.509548
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ec5fb51fc300'
|
||||
down_revision = '14f1813ae8e3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
with op.batch_alter_table("transferhistory") as batch_op:
|
||||
batch_op.add_column(sa.Column('files', sa.String, nullable=True))
|
||||
with op.batch_alter_table("rss") as batch_op:
|
||||
batch_op.add_column(sa.Column('filter', sa.Integer, nullable=True))
|
||||
except Exception as e:
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
||||
31
database/versions/f94cd1217fd7_1_0_14.py
Normal file
31
database/versions/f94cd1217fd7_1_0_14.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""1_0_14
|
||||
|
||||
Revision ID: f94cd1217fd7
|
||||
Revises: 127a25fdf0e8
|
||||
Create Date: 2024-03-06 19:19:33.053186
|
||||
|
||||
"""
|
||||
import contextlib
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f94cd1217fd7'
|
||||
down_revision = '127a25fdf0e8'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with contextlib.suppress(Exception):
|
||||
with op.batch_alter_table("subscribe") as batch_op:
|
||||
batch_op.add_column(sa.Column('manual_total_episode', sa.Integer, nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
@@ -1 +1 @@
|
||||
APP_VERSION = 'v2.0.0-alpha'
|
||||
APP_VERSION = 'v1.9.10-1'
|
||||
|
||||
Reference in New Issue
Block a user