mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { DownloadPackage } from '@/core/download'
|
|
import { UserAgent } from '@/core/utils/constants'
|
|
import { getFriendlyTitle } from '@/core/utils/title'
|
|
import { DownloadVideoOutput } from '../../../../components/video/download/types'
|
|
|
|
export const aria2Input: DownloadVideoOutput = {
|
|
name: 'aria2',
|
|
displayName: 'aria2 Input',
|
|
description: '使用 aria2 命令行输入文件开始下载. (aria2c -i xxx.txt)',
|
|
runAction: async action => {
|
|
const { infos } = action
|
|
const referer = document.URL.replace(window.location.search, '')
|
|
const items = infos
|
|
.map(info => {
|
|
const fragmentItems = info.titledFragments
|
|
.map(f => ({
|
|
url: f.url,
|
|
params: {
|
|
referer,
|
|
userAgent: UserAgent,
|
|
out: f.title,
|
|
},
|
|
}))
|
|
.flat()
|
|
return fragmentItems.map(f => {
|
|
const params = Object.entries(f.params)
|
|
.map(([key, value]) => ` ${lodash.kebabCase(key)}=${value}`)
|
|
.join('\n')
|
|
return `${f.url}\n${params}`
|
|
})
|
|
})
|
|
.flat()
|
|
const input = `
|
|
# Generated by Bilibili Evolved Video Export
|
|
# https://github.com/the1812/Bilibili-Evolved/
|
|
${items.join('\n')}`.trim()
|
|
await DownloadPackage.single(`${getFriendlyTitle()}.txt`, input)
|
|
},
|
|
}
|