Skip to content

Commit

Permalink
Merge pull request #1541 from WangEdward/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Feb 25, 2024
2 parents 0233853 + a5b4221 commit a0af827
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
7 changes: 4 additions & 3 deletions app/api/endpoints/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def create_subscribe(
username=current_user.name,
best_version=subscribe_in.best_version,
save_path=subscribe_in.save_path,
search_imdbid=subscribe_in.search_imdbid,
exist_ok=True)
return schemas.Response(success=True if sid else False, message=message, data={
"id": sid
})
return schemas.Response(
success=bool(sid), message=message, data={"id": sid}
)


@router.put("/", summary="更新订阅", response_model=schemas.Response)
Expand Down
3 changes: 2 additions & 1 deletion app/chain/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def search(self, sid: int = None, state: str = 'N', manual: bool = False):
no_exists=no_exists,
sites=sites,
priority_rule=priority_rule,
filter_rule=filter_rule)
filter_rule=filter_rule,
area="imdbid" if subscribe.search_imdbid else "title")
if not contexts:
logger.warn(f'订阅 {subscribe.keyword or subscribe.name} 未搜索到资源')
self.finish_subscribe_or_not(subscribe=subscribe, meta=meta,
Expand Down
2 changes: 2 additions & 0 deletions app/db/models/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class Subscribe(Base):
current_priority = Column(Integer)
# 保存路径
save_path = Column(String)
# 是否使用 imdbid 搜索
search_imdbid = Column(Integer, default=0)

@staticmethod
@db_query
Expand Down
2 changes: 2 additions & 0 deletions app/schemas/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Subscribe(BaseModel):
current_priority: Optional[int] = None
# 保存路径
save_path: Optional[str] = None
# 是否使用 imdbid 搜索
search_imdbid: Optional[int] = 0

class Config:
orm_mode = True
30 changes: 30 additions & 0 deletions database/versions/127a25fdf0e8_1_0_13.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a0af827

Please sign in to comment.