mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
author, category_id, category_name, publish_date Co-authored-by: lainio24 <lainio24@outlook.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { defineComponentMetadata } from '@/components/define'
|
||
import { PackageEntry } from '@/core/download'
|
||
import { hasVideo } from '@/core/spin-query'
|
||
import { videoUrls } from '@/core/utils/urls'
|
||
import { DownloadVideoAssets } from '../download/types'
|
||
import { generateFFMetadataBlob } from './metadata'
|
||
|
||
const author = [
|
||
{
|
||
name: 'WakelessSloth56',
|
||
link: 'https://github.com/WakelessSloth56',
|
||
},
|
||
{
|
||
name: 'LainIO24',
|
||
link: 'https://github.com/LainIO24',
|
||
},
|
||
]
|
||
|
||
export const component = defineComponentMetadata({
|
||
name: 'saveVideoMetadata',
|
||
displayName: '保存视频元数据',
|
||
description:
|
||
'保存视频元数据(标题、描述、UP、章节等)为 [FFMETADATA](https://ffmpeg.org/ffmpeg-formats.html#metadata) 格式',
|
||
author,
|
||
tags: [componentsTags.video],
|
||
entry: none,
|
||
urlInclude: videoUrls,
|
||
widget: {
|
||
condition: hasVideo,
|
||
component: () => import('./SaveMetadata.vue').then(m => m.default),
|
||
},
|
||
plugin: {
|
||
displayName: '下载视频 - 保存元数据',
|
||
author,
|
||
setup: ({ addData }) => {
|
||
addData('downloadVideo.assets', async (assets: DownloadVideoAssets[]) => {
|
||
assets.push({
|
||
name: 'saveMetadata',
|
||
displayName: '保存元数据',
|
||
getAssets: async (infos, instance: { saveMetadata: boolean }) => {
|
||
const { saveMetadata: enabled } = instance
|
||
if (enabled) {
|
||
const result: PackageEntry[] = []
|
||
for (const info of infos) {
|
||
result.push({
|
||
name: `${info.input.title}.ffmetadata.txt`,
|
||
data: await generateFFMetadataBlob(info.input.aid, info.input.cid),
|
||
options: {},
|
||
})
|
||
}
|
||
return result
|
||
}
|
||
return []
|
||
},
|
||
component: () => import('./Plugin.vue').then(m => m.default),
|
||
})
|
||
})
|
||
},
|
||
},
|
||
})
|