Merge pull request #1234 from thsrite/main

This commit is contained in:
jxxghp 2023-12-14 06:28:50 +08:00 committed by GitHub
commit 995c359f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 3 deletions

View File

@ -82,6 +82,7 @@ def create_subscribe(
doubanid=subscribe_in.doubanid,
username=current_user.name,
best_version=subscribe_in.best_version,
save_path=subscribe_in.save_path,
exist_ok=True)
return schemas.Response(success=True if sid else False, message=message, data={
"id": sid

View File

@ -320,7 +320,8 @@ class SubscribeChain(ChainBase):
downloads, lefts = self.downloadchain.batch_download(
contexts=matched_contexts,
no_exists=no_exists,
username=subscribe.username
username=subscribe.username,
save_path=subscribe.save_path
)
# 判断是否应完成订阅
@ -674,8 +675,10 @@ class SubscribeChain(ChainBase):
# 开始批量择优下载
logger.info(f'{mediainfo.title_year} 匹配完成,共匹配到{len(_match_context)}个资源')
downloads, lefts = self.downloadchain.batch_download(contexts=_match_context, no_exists=no_exists,
username=subscribe.username)
downloads, lefts = self.downloadchain.batch_download(contexts=_match_context,
no_exists=no_exists,
username=subscribe.username,
save_path=subscribe.save_path)
# 判断是否要完成订阅
self.finish_subscribe_or_not(subscribe=subscribe, meta=meta, mediainfo=mediainfo,
downloads=downloads, lefts=lefts)

View File

@ -65,6 +65,8 @@ class Subscribe(Base):
best_version = Column(Integer, default=0)
# 当前优先级
current_priority = Column(Integer)
# 保存路径
save_path = Column(String)
@staticmethod
@db_query

View File

@ -57,6 +57,8 @@ class Subscribe(BaseModel):
best_version: Optional[int] = 0
# 当前优先级
current_priority: Optional[int] = None
# 保存路径
save_path: Optional[str] = None
class Config:
orm_mode = True

View 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