Skip to content

Commit

Permalink
fix: rss.parser set to default value when subscribe Bangumi
Browse files Browse the repository at this point in the history
  • Loading branch information
KotaHv committed Jan 24, 2024
1 parent 6973773 commit 2149182
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/src/module/api/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def download_collection(data: Bangumi):
@router.post(
"/subscribe", response_model=APIResponse, dependencies=[Depends(get_current_user)]
)
async def subscribe(data: Bangumi):
async def subscribe(data: Bangumi, rss: RSSItem):
with SeasonCollector() as collector:
resp = collector.subscribe_season(data)
resp = collector.subscribe_season(data, parser=rss.parser)
return u_response(resp)
7 changes: 5 additions & 2 deletions backend/src/module/manager/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ def collect_season(self, bangumi: Bangumi, link: str = None):
)

@staticmethod
def subscribe_season(data: Bangumi):
def subscribe_season(data: Bangumi, parser: str = "mikan"):
with RSSEngine() as engine:
data.added = True
data.eps_collect = True
engine.add_rss(
rss_link=data.rss_link, name=data.official_title, aggregate=False
rss_link=data.rss_link,
name=data.official_title,
aggregate=False,
parser=parser,
)
result = engine.download_bangumi(data)
engine.bangumi.add(data)
Expand Down
8 changes: 6 additions & 2 deletions webui/src/api/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ export const apiDownload = {
* 新番
* @param bangumiData - Bangumi 数据
*/
async subscribe(bangumiData: BangumiRule) {
const postData: BangumiAPI = {
async subscribe(bangumiData: BangumiRule, rss: RSS) {
const bangumi: BangumiAPI = {
...bangumiData,
filter: bangumiData.filter.join(','),
rss_link: bangumiData.rss_link.join(','),
};
const postData = {
data: bangumi,
rss,
};
const { data } = await axios.post<ApiSuccess>(
'api/v1/rss/subscribe',
postData
Expand Down
2 changes: 1 addition & 1 deletion webui/src/components/ab-add-rss.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function subscribe() {
if (rule.value) {
try {
loading.subscribe = true;
const res = await apiDownload.subscribe(rule.value);
const res = await apiDownload.subscribe(rule.value, rss.value);
loading.subscribe = false;
if (res) {
message.success('Subscribe Success!');
Expand Down

0 comments on commit 2149182

Please sign in to comment.