diff --git a/src/components/VideoModal/index.vue b/src/components/VideoModal/index.vue
index ff339c3..d358449 100644
--- a/src/components/VideoModal/index.vue
+++ b/src/components/VideoModal/index.vue
@@ -37,6 +37,9 @@
全选
+
+ 保留[P?]
+
@@ -76,6 +79,7 @@ const videoInfo = ref(videoData)
const selected = ref([])
const allSelected = ref(false)
const router = useRouter()
+const saveFilePrefix = ref(true)
const cancel = () => {
visible.value = false
@@ -87,7 +91,7 @@ const cancel = () => {
const handleDownload = async () => {
confirmLoading.value = true
// 获取当前选中视频的下载数据
- const list = await getDownloadList(toRaw(videoInfo.value), toRaw(selected.value), quality.value)
+ const list = await getDownloadList(toRaw(videoInfo.value), toRaw(selected.value), quality.value, undefined, undefined, saveFilePrefix.value)
console.log('list-->', list)
const taskList = addDownload(list)
store.taskStore().setTask(taskList)
@@ -110,6 +114,7 @@ const handleDownload = async () => {
}
const open = (data: VideoData) => {
+ saveFilePrefix.value = true
const quality = userQuality[store.baseStore().loginStatus]
// 过滤掉 不合法的清晰度
data.qualityOptions = data.qualityOptions.filter((item: any) => quality.includes(item.value))
diff --git a/src/core/bilibili.ts b/src/core/bilibili.ts
index 9924f95..b33a2c4 100644
--- a/src/core/bilibili.ts
+++ b/src/core/bilibili.ts
@@ -14,7 +14,7 @@ const nanoid = customAlphabet(alphabet, 16)
* @params videoInfo: 当前下载的视频详情 selected:所选的分p quality:所选的清晰度
* @returns 返回下载数据 Array
*/
-const getDownloadList = async (videoInfo: VideoData, selected: number[], quality: number, isReload = false, oldTask?: VideoData) => {
+const getDownloadList = async (videoInfo: VideoData, selected: number[], quality: number, isReload = false, oldTask?: VideoData, saveFilePrefix = true) => {
const downloadList: VideoData[] = []
const limit = pLimit(8)
const selectedLen = selected.length
@@ -72,8 +72,8 @@ const getDownloadList = async (videoInfo: VideoData, selected: number[], quality
cid: currentCid,
bvid: currentBvid,
downloadUrl,
- filePathList: handleFilePathList(selectedLen === 1 && !isReload ? 0 : currentPage, currentPageData.title, tempVideoInfo, currentBvid, taskId),
- fileDir: handleFileDir(selectedLen === 1 && !isReload ? 0 : currentPage, currentPageData.title, tempVideoInfo, currentBvid, taskId),
+ filePathList: handleFilePathList(selectedLen === 1 && !isReload ? 0 : currentPage, currentPageData.title, tempVideoInfo, currentBvid, taskId, saveFilePrefix),
+ fileDir: handleFileDir(selectedLen === 1 && !isReload ? 0 : currentPage, currentPageData.title, tempVideoInfo, currentBvid, taskId, saveFilePrefix),
subtitle
}
downloadList.push(videoData)
@@ -184,11 +184,12 @@ const checkUrl = (url: string) => {
// 检查url是否有重定向
const checkUrlRedirect = async (videoUrl: string) => {
+ const ua = randUserAgent()
const params = {
videoUrl,
config: {
headers: {
- 'User-Agent': randUserAgent(),
+ 'User-Agent': ua,
cookie: `SESSDATA=${store.settingStore(pinia).SESSDATA}`
}
}
@@ -599,14 +600,14 @@ const getSubtitle = async (cid: number, bvid: string) => {
}
// 处理filePathList
-const handleFilePathList = (page: number, title: string, videoInfo: VideoData, bvid: string, id: string): string[] => {
+const handleFilePathList = (page: number, title: string, videoInfo: VideoData, bvid: string, id: string, saveFilePrefix = true): string[] => {
const up = videoInfo.up[0].name
const collectionName = (Array.isArray(videoInfo.page) && videoInfo.page.length > 1)
? videoInfo.page[0].collectionName
: ''
const storeDownloadPath = store.settingStore().downloadPath
- const downloadPath = collectionName ? `${storeDownloadPath}/${collectionName}${up ? `-${up}` : ''}` : storeDownloadPath
- const name = `${!page ? '' : `[P${page}]`}${filterTitle(`${title}${up ? `-${up}` : ''}-${bvid}-${id}`)}`
+ const downloadPath = collectionName ? `${storeDownloadPath}/${up ? `${up}-` : ''}${collectionName}` : storeDownloadPath
+ const name = `${(page && saveFilePrefix) ? `[P${page}]` : ''}${filterTitle(`${up ? `${up}-` : ''}${title}-${bvid}-${id}`)}`
const isFolder = store.settingStore().isFolder
let pathList = [
`${downloadPath}/${name}.mp4`,
@@ -628,15 +629,14 @@ const handleFilePathList = (page: number, title: string, videoInfo: VideoData, b
}
// 处理fileDir
-const handleFileDir = (page: number, title: string, videoInfo: VideoData, bvid: string, id: string): string => {
+const handleFileDir = (page: number, title: string, videoInfo: VideoData, bvid: string, id: string, saveFilePrefix = true): string => {
const up = videoInfo.up[0].name
const collectionName = (Array.isArray(videoInfo.page) && videoInfo.page.length > 1)
? videoInfo.page[0].collectionName
: ''
const storeDownloadPath = store.settingStore().downloadPath
- const downloadPath = collectionName ? `${storeDownloadPath}/${collectionName}${up ? `-${up}` : ''}` : storeDownloadPath
-
- const name = `${!page ? '' : `[P${page}]`}${filterTitle(`${title}${up ? `-${up}` : ''}-${bvid}-${id}`)}`
+ const downloadPath = collectionName ? `${storeDownloadPath}/${up ? `${up}-` : ''}${collectionName}` : storeDownloadPath
+ const name = `${(page && saveFilePrefix) ? `[P${page}]` : ''}${filterTitle(`${up ? `${up}-` : ''}${title}-${bvid}-${id}`)}`
const isFolder = store.settingStore().isFolder
return `${downloadPath}${isFolder ? `/${name}/` : ''}`
}
diff --git a/src/utils/randUA.ts b/src/utils/randUA.ts
index 115311a..7609747 100644
--- a/src/utils/randUA.ts
+++ b/src/utils/randUA.ts
@@ -5,7 +5,7 @@ const userAgent = new UserAgent({
deviceCategory: 'desktop'
})
function randUserAgent () {
- return userAgent.random().toString()
+ return `${userAgent.random().toString()} ${Math.floor(Math.random() * 100000)}`
}
export {