Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
- ui problem.
- return rss link of searcher
  • Loading branch information
EstrellaXD committed Sep 9, 2023
1 parent 757f07e commit daadcb2
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 52 deletions.
14 changes: 0 additions & 14 deletions backend/src/module/rss/searcher.py

This file was deleted.

20 changes: 9 additions & 11 deletions backend/src/module/searcher/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ def analyse_keyword(self, keywords: list[str], site: str = "mikan") -> BangumiJS
bangumi = self.torrent_to_data(torrent=torrent, rss=rss_item)
if bangumi and bangumi not in exist_list:
exist_list.append(bangumi)
bangumi.rss_link = self.special_url(bangumi, site).url
yield json.dumps(bangumi.dict(), separators=(',', ':'))

def search_season(self, data: Bangumi):
@staticmethod
def special_url(data: Bangumi, site: str) -> RSSItem:
keywords = [getattr(data, key) for key in SEARCH_KEY if getattr(data, key)]
url = search_url("mikan", keywords)
torrents = self.search_torrents(url)
return [torrent for torrent in torrents if data.title_raw in torrent.name]
url = search_url(site, keywords)
return url


if __name__ == "__main__":
with SearchTorrent() as st:
keywords = ["无职转生", "第二季"]
bangumis = st.analyse_keyword(keywords)
for bangumi in bangumis:
print(bangumi)
def search_season(self, data: Bangumi, site: str = "mikan") -> list[Torrent]:
rss_item = self.special_url(data, site)
torrents = self.search_torrents(rss_item)
return [torrent for torrent in torrents if data.title_raw in torrent.name]
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const message = useMessage();
const { getAll } = useBangumiStore();
const rss = ref<RSS>(rssTemplate);
const searchRule = defineModel<BangumiRule>('searchRule', { default: null });
const rule = ref<BangumiRule>(ruleTemplate);
const rule = defineModel<BangumiRule>('rule', { default: ruleTemplate })
const parserType = ['mikan', 'tmdb', 'parser'];
const window = reactive({
Expand All @@ -33,10 +32,9 @@ watch(show, (val) => {
setTimeout(() => {
window.next = false;
}, 300);
} else if (val || searchRule.value) {
} else if (val && rule.value.official_title !== '') {
window.next = true;
window.rule = true;
rule.value = searchRule.value;
}
});
Expand All @@ -48,7 +46,6 @@ async function addRss() {
window.loading = true;
const data = await apiRSS.add(rss.value);
window.loading = false;
window.next = true;
message.success(data.msg_en);
show.value = false;
console.log('rss', data);
Expand Down Expand Up @@ -161,7 +158,6 @@ async function subscribe() {

<div v-else-if="window.rule">
<ab-rule v-model:rule="rule"></ab-rule>

<div flex="~ justify-end" space-x-10px>
<ab-button size="small" :loading="loading.collect" @click="collect"
>Collect</ab-button
Expand Down
3 changes: 2 additions & 1 deletion webui/src/components/ab-rss-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ref } from 'vue';
withDefaults(
defineProps<{
id: number
name: string;
url: string;
enable: boolean;
Expand All @@ -26,7 +27,7 @@ const checked = ref(false);
small
:model-value="checked"
@update:model-value="checked = $event"
@click="() => $emit('on-select')"
@click="() => $emit('on-select', checked, id)"
/>
<div w-200px text-h3 truncate>{{ name }}</div>
<div w-300px text-h3 truncate>{{ url }}</div>
Expand Down
3 changes: 0 additions & 3 deletions webui/src/components/ab-search-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,5 @@ function onSelect(site: string) {


<style lang="scss" scoped>
.result-enter-active {
transition: all 0.3s;
}
</style>
19 changes: 15 additions & 4 deletions webui/src/components/layout/ab-topbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
Power,
Refresh,
} from '@icon-park/vue-next';
import { ruleTemplate } from "#/bangumi";
import type {BangumiRule} from "#/bangumi";
const {t, changeLocale} = useMyI18n();
const {running, onUpdate, offUpdate} = useAppInfo();
const showAccount = ref(false);
const showAdd = ref(false);
const showAddRSS = ref(false);
const searchRule = ref<BangumiRule>()
const {start, pause, shutdown, restart, resetRule} = useProgramStore();
Expand Down Expand Up @@ -62,11 +63,20 @@ const items = [
const onSearchFocus = ref(false);
function addSearchResult(bangumi: BangumiRule) {
showAdd.value = true;
showAddRSS.value = true;
searchRule.value = bangumi;
console.log('searchRule', searchRule.value);
}
watch(showAddRSS, (val) => {
if (!val) {
searchRule.value = ruleTemplate;
setTimeout(() => {
onSearchFocus.value = false;
}, 300);
}
});
onBeforeMount(() => {
onUpdate();
});
Expand All @@ -85,19 +95,20 @@ onUnmounted(() => {
</div>

<ab-search-bar @add-bangumi="addSearchResult"/>
<div text-h2>{{ showAddRSS }}</div>
</div>

<div ml-auto>
<ab-status-bar
:items="items"
:running="running"
@click-add="() => (showAdd = true)"
@click-add="() => (showAddRSS = true)"
@change-lang="() => changeLocale()"
></ab-status-bar>
</div>

<ab-change-account v-model:show="showAccount"></ab-change-account>

<ab-add-bangumi v-model:show="showAdd" v-model:searchRule="searchRule"></ab-add-bangumi>
<ab-add-rss v-model:show="showAddRSS" v-model:rule="searchRule"></ab-add-rss>
</div>
</template>
12 changes: 10 additions & 2 deletions webui/src/pages/index/rss.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
const {rss, selectedRSS} = storeToRefs(useRSSStore());
const {getAll, deleteSelected, disableSelected, enableSelected, handleCheckboxClicked} = useRSSStore();
const {getAll, deleteSelected, disableSelected, enableSelected} = useRSSStore();
onActivated(() => {
getAll();
Expand All @@ -9,6 +9,13 @@ definePage({
name: 'RSS',
});
function addSelected(checked: boolean, id: number) {
if (!checked) {
selectedRSS.value.push(id);
} else {
selectedRSS.value = selectedRSS.value.filter((i) => i !== id);
}
}
</script>

Expand All @@ -31,13 +38,14 @@ definePage({
<div space-y-12px>
<ab-rss-item
v-for="i in rss"
:id="i.id"
:key="i.id"
:name="i.name"
:url="i.url"
:enable="i.enabled"
:parser="i.parser"
:aggregate="i.aggregate"
@on-select="handleCheckboxClicked(i.id)"
@on-select="addSelected"
>
</ab-rss-item>
</div>
Expand Down
10 changes: 0 additions & 10 deletions webui/src/store/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ export const useRSSStore = defineStore('rss', () => {
refresh();
}

function handleCheckboxClicked(id: number) {
if (selectedRSS.value.includes(id)) {
// delete id in list
selectedRSS.value = selectedRSS.value.filter((e) => e !== id);
} else {
selectedRSS.value.push(id)
}
}

onUpdateRSSResult(actionSuccess);
onDeleteRSSResult(actionSuccess);
onDisableRSSResult(actionSuccess);
Expand All @@ -78,6 +69,5 @@ export const useRSSStore = defineStore('rss', () => {
disableSelected,
deleteSelected,
enableSelected,
handleCheckboxClicked,
};
});
2 changes: 1 addition & 1 deletion webui/types/dts/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
AbAdd: typeof import('./../../src/components/basic/ab-add.vue')['default']
AbAddBangumi: typeof import('./../../src/components/ab-add-bangumi.vue')['default']
AbAddRss: typeof import('./../../src/components/ab-add-rss.vue')['default']
AbBangumiCard: typeof import('./../../src/components/ab-bangumi-card.vue')['default']
AbButton: typeof import('./../../src/components/basic/ab-button.vue')['default']
AbChangeAccount: typeof import('./../../src/components/ab-change-account.vue')['default']
Expand Down

0 comments on commit daadcb2

Please sign in to comment.