From 4b7bc8fd962a0e5141df7278bca962cdbd8be5ee Mon Sep 17 00:00:00 2001 From: Tinhone Date: Tue, 12 Sep 2023 22:30:44 +0800 Subject: [PATCH 01/46] =?UTF-8?q?fix:=20=E6=9E=81=E7=AE=80=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=9C=A8=E9=AB=98=E5=88=86=E5=B1=8F=E5=92=8C=E4=BD=8E?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E6=AF=94=E4=BE=8B=E4=B8=8B=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A6=E5=BA=95=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home-redesign/minimal/tabs/Feeds.vue | 8 ++- src/ui/ScrollTrigger.vue | 68 ++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/registry/lib/components/style/home-redesign/minimal/tabs/Feeds.vue b/registry/lib/components/style/home-redesign/minimal/tabs/Feeds.vue index 297821f43e..81eb1a60f0 100644 --- a/registry/lib/components/style/home-redesign/minimal/tabs/Feeds.vue +++ b/registry/lib/components/style/home-redesign/minimal/tabs/Feeds.vue @@ -4,7 +4,7 @@ - + @@ -43,6 +43,7 @@ export default Vue.extend({ try { this.error = false this.loading = true + this.$refs.scrollTrigger.setLoadState('loading') this.cards = lodash.uniqBy( [...this.cards, ...(await getVideoFeeds('video', this.lastID))], it => it.id, @@ -50,12 +51,17 @@ export default Vue.extend({ } catch (error) { logError(error) this.error = true + this.$refs.scrollTrigger.setLoadState('error') } finally { this.loading = false + if (this.loaded) { + this.$refs.scrollTrigger.setLoadState('loaded') + } } }, async refresh() { this.cards = [] + this.$refs.scrollTrigger.resetIsFirstLoad() }, }, }) diff --git a/src/ui/ScrollTrigger.vue b/src/ui/ScrollTrigger.vue index 8886aefe6e..16379e374f 100644 --- a/src/ui/ScrollTrigger.vue +++ b/src/ui/ScrollTrigger.vue @@ -7,23 +7,89 @@ + + \ No newline at end of file diff --git a/registry/lib/plugins/video/download/mpv-output-ex/handler.ts b/registry/lib/plugins/video/download/mpv-output-ex/handler.ts new file mode 100644 index 0000000000..9bd878a2d7 --- /dev/null +++ b/registry/lib/plugins/video/download/mpv-output-ex/handler.ts @@ -0,0 +1,66 @@ +import { Toast } from '@/core/toast' +import { monkey } from '@/core/ajax' +import { logError } from '@/core/utils/log' +import { DownloadVideoOutput } from '../../../../components/video/download/types' + +const getPastebinUrl = async (str: string, config: ConfigDataType) => { + const sp = new URLSearchParams(); + Object.entries({ + api_dev_key: config.api_dev_key, + api_user_key: config.api_user_key, // ! 必须绑定一个账号,否则链接可能被吞 + api_folder_key: "m3u", + api_option: "paste", + api_paste_code: str, + api_paste_private: "1", + api_paste_expire_date: "10M", + }).forEach(([key, value]) => sp.append(key, value)) + const response = await monkey({ + url: 'https://pastebin.com/api/api_post.php', + method: 'POST', + headers: { + "Content-Type": "application/x-www-form-urlencoded" + }, + data: sp.toString(), + nocache: true, + responseType: 'text', + fetch: true + }) + if (/^Bad API request,/.test(response)) throw response + + return response +} + +export const MPV_Ex: DownloadVideoOutput = { + name: 'mpv-ex', + displayName: 'MPV 输出支持加强版', + description: '多文件时格式选择 flv,使用前请先阅读 README', + runAction: async (action, instance) => { + let finalURL: string + const mpv_protocol = 'mpv://--http-header-fields="referer:https://www.bilibili.com/"' + if (action.isSingleVideo) { + // 单文件直接生成 url + const frag = action.infos[0].fragments + if (frag.length === 1) { + finalURL = `${mpv_protocol} ${frag[0].url}` + } else if (frag.length === 2) { + finalURL = `${mpv_protocol} ${frag[0].url} --audio-file=${frag[1].url}` + } + } else { + // 多文件生成 .m3u 播放列表 + const m3u = action.infos.reduce((acc, v, i) => { + return acc + `#EXTINF:-1,${v.input.title}\n${v.fragments[0].url}\n` // ? 暂不支持外挂音轨,默认取第一个资源的链接 + }, '#EXTM3U\n') + try { + const playlist = (await getPastebinUrl(m3u, instance)).replace(/^(https:\/\/pastebin.com)\/(.*)/, '$1/raw/$2?.m3u') + finalURL = `${mpv_protocol} ${playlist}` + } catch (error) { + logError(error) + return + } + } + + console.log(finalURL) + Toast.show(`播放`, 'MPV播放', 600e3) + }, + component: () => import('./Config.vue').then(m => m.default), +} diff --git a/registry/lib/plugins/video/download/mpv-output-ex/index.ts b/registry/lib/plugins/video/download/mpv-output-ex/index.ts new file mode 100644 index 0000000000..758a4fe5dc --- /dev/null +++ b/registry/lib/plugins/video/download/mpv-output-ex/index.ts @@ -0,0 +1,19 @@ +import { PluginMetadata } from '@/plugins/plugin' +import { DownloadVideoOutput } from '../../../../components/video/download/types' +import { MPV_Ex } from './handler' + +export const plugin: PluginMetadata = { + name: 'downloadVideo.outputs.mpv-ex', + displayName: '下载视频 - MPV 输出支持加强版', + author: { + name: 'asuaaa', + link: 'https://github.com/Asukaaaaaa', + }, + description: + '为下载视频增加 MPV 输出,支持导出列表, 配置方式请参考 [README](https://github.com/Asukaaaaaa/tricks/blob/main/Bilibili-Evolved%20mpv-ex%20%E6%8F%92%E4%BB%B6.md)', + setup: ({ addData }) => { + addData('downloadVideo.outputs', (outputs: DownloadVideoOutput[]) => { + outputs.push(MPV_Ex) + }) + }, +} diff --git a/registry/lib/plugins/video/download/mpv-output-ex/type.d.ts b/registry/lib/plugins/video/download/mpv-output-ex/type.d.ts new file mode 100644 index 0000000000..68ba520ef3 --- /dev/null +++ b/registry/lib/plugins/video/download/mpv-output-ex/type.d.ts @@ -0,0 +1,4 @@ +type ConfigDataType = { + api_dev_key: string; + api_user_key: string; +} From 422fbcd0b54d71ddbed102a7f808c2b809750c93 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 22 Sep 2023 19:11:47 +0800 Subject: [PATCH 03/46] lint fix --- .../video/download/mpv-output-ex/Config.vue | 2 -- .../video/download/mpv-output-ex/handler.ts | 30 +++++++++++-------- .../video/download/mpv-output-ex/type.d.ts | 4 +-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/registry/lib/plugins/video/download/mpv-output-ex/Config.vue b/registry/lib/plugins/video/download/mpv-output-ex/Config.vue index 6bfd6a817f..1e027cfb9d 100644 --- a/registry/lib/plugins/video/download/mpv-output-ex/Config.vue +++ b/registry/lib/plugins/video/download/mpv-output-ex/Config.vue @@ -1,4 +1,3 @@ - diff --git a/registry/lib/components/style/custom-font-family/extra-options/ExtraOptionsPanel.vue b/registry/lib/components/style/custom-font-family/extra-options/ExtraOptionsPanel.vue index 01c05c14bc..73657cb872 100644 --- a/registry/lib/components/style/custom-font-family/extra-options/ExtraOptionsPanel.vue +++ b/registry/lib/components/style/custom-font-family/extra-options/ExtraOptionsPanel.vue @@ -1,12 +1,5 @@