全面移除视频,移除域名混淆加载,直接写死,移除展示类型(同步更新)

This commit is contained in:
chuzhongzai
2023-03-15 21:44:19 +08:00
parent 5d543868bf
commit 38267a076a
3 changed files with 26 additions and 446 deletions
+14 -286
View File
@@ -4,7 +4,6 @@ import {ElMessage} from "element-plus"
import qs from "qs"
const BaseUrl = "http://downloader.lionwebsite.xyz/"
const GalleryManageUrl = BaseUrl + "GalleryManage"
const VideoManageUrl = BaseUrl + "VideoManage"
const actions = {
updateGalleryTasks(context, type){
@@ -35,34 +34,6 @@ const actions = {
}
})
},
updateVideoTasks(context, type){
axios.get(VideoManageUrl, {
params:{
type,
AuthCode: state.AuthCode
}
}).then(res => {
if(res.data.result === "success") {
let tasks = JSON.parse(res.data.data)
if (type === "all" && state.videoRefreshTimer === 0) { //判断是否有未下载完成的视频以及定时更新是否开启
for (let i = tasks.length - 1; i > tasks.length - 11; i--) //从后往前遍历十个本子,查看是否有未下载完成的视频
if (tasks[i].status !== "下载完成") {
state.videoRefreshTimer = setInterval(() => {
context.dispatch("updateVideoTasks", "undone").then()
}, 20000)
break
}
}
context.commit("_updateVideoTasks", {tasks, type})
}
else if(type === 'undone') {
clearInterval(state.videoRefreshTimer)
state.videoRefreshTimer = 0
context.dispatch("updateVideoTasks", "all").then()
}
})
},
postGalleryTask(context, data){
axios.post(GalleryManageUrl, qs.stringify({
AuthCode: state.AuthCode,
@@ -85,28 +56,6 @@ const actions = {
}
})
},
postVideoTask(context, data){
axios.post(VideoManageUrl, qs.stringify({
AuthCode: state.AuthCode,
link: data.link,
targetResolution: data.targetResolution
})).then((res) => {
if(res.data.result === "success") {
ElMessage("提交成功")
context.commit("_setChosenVideo", {video: false, resolution: data.targetResolution})
if(state.videoRefreshTimer === 0)
state.videoRefreshTimer = setInterval(() => {
context.dispatch("updateVideoTasks", "undone").then()
}, 20000)
}
else{
if(res.data.data)
ElMessage(res.data.data)
else
ElMessage("提交失败")
}
})
},
queryGalleryTask(context, link){
axios.get(GalleryManageUrl, {
params:{
@@ -122,21 +71,6 @@ const actions = {
ElMessage("查询失败")
})
},
queryVideoTask(context, link){
axios.get(VideoManageUrl, {
params:{
param: link,
type: "link",
AuthCode: state.AuthCode
}
}).then((res) => {
if(res.data.result === 'success')
context.commit("_setChosenVideo", {video: JSON.parse(res.data.data)})
else
ElMessage("查询失败")
})
},
queryOnlineLinks(context, gid){
// 如果本地有缓存,则直接返回,没有再请求
if(context.state.onlineLinks[gid] !== undefined){
@@ -176,10 +110,8 @@ const actions = {
if(res.data.result === 'success'){
context.commit("_authed", {AuthCode, ...JSON.parse(res.data.data)})
//初始化
context.dispatch("loadMaskDomain").then()
context.dispatch("loadWeekUsedAmount").then()
context.dispatch("updateGalleryTasks", "all").then(() => confirmCurrentTask(context.state))
context.dispatch("updateVideoTasks", "all").then()
//获取图片合适长度
let screenWidth = window.screen.width * 0.9 - 40
@@ -199,12 +131,6 @@ const actions = {
context.commit("_unAuthed")
})
},
loadMaskDomain(context){
axios.get(BaseUrl + "maskDomain").then((res) => {
if(res.data.result === "success")
context.commit("_setMaskDomain", JSON.parse(res.data.data))
})
},
loadWeekUsedAmount(context){
axios.get(GalleryManageUrl + "/weekUsedAmount", {
params: {
@@ -228,16 +154,6 @@ const actions = {
context.commit("_collectGallery", gid)
})
},
collectVideo(context, id){
axios.post(VideoManageUrl + "/collect?" + qs.stringify({
id,
userId: state.userId
})).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_collectVideo", id)
})
},
disCollectGallery(context, gid){
axios.post(GalleryManageUrl + "/disCollect?" + qs.stringify({
gid,
@@ -248,16 +164,6 @@ const actions = {
context.commit("_disCollectGallery", gid)
})
},
disCollectVideo(context, id){
axios.post(VideoManageUrl + "/disCollect?" + qs.stringify({
id,
userId: state.userId
})).then((res) => {
ElMessage(res.data.data)
if(res.data.result === "success")
context.commit("_disCollectVideo", id)
})
},
updateGalleryTag(context, data){
axios.post(GalleryManageUrl + "/tag?" + qs.stringify(data)).then((res) => {
ElMessage(res.data.data)
@@ -265,13 +171,6 @@ const actions = {
context.commit("_updateGalleryTag", data)
})
},
updateVideoTag(context, data){
axios.post(VideoManageUrl + "/tag?" + qs.stringify(data)).then((res) => {
ElMessage(res.data.data)
if(res.data.result === 'success')
context.commit("_updateVideoTag", data)
})
},
deleteGallery(context, gid){
axios.delete(GalleryManageUrl, {
params:{
@@ -286,22 +185,6 @@ const actions = {
ElMessage(res.data.data)
})
},
deleteVideo(context, id){
axios.delete(VideoManageUrl, {
params:{
AuthCode:state.AuthCode,
id
}
}).then((res) => {
if(res.data.result === "success"){
ElMessage("删除成功")
context.commit("_deleteVideo", id)
}
else{
ElMessage(res.data.data)
}
})
},
alterAuthCode(context, AuthCode){
axios.put(BaseUrl + "AuthCode?" + qs.stringify({'AuthCode': state.AuthCode, 'newAuthCode': AuthCode}))
.then((res) => {
@@ -327,15 +210,6 @@ const mutations = {
}
}
},
_collectVideo(state, id){
let tasks = state.totalVideoTask
for(let i=0; i< tasks.length; i++){
if(!tasks[i].isCollect && tasks[i].id === id){
tasks[i].isCollect = true
state.collectGallery.push(tasks[i])
}
}
},
_disCollectGallery(state, gid){
let index
for(let i=0; i < state.collectGallery.length; i++){
@@ -347,17 +221,6 @@ const mutations = {
state.collectGallery[index].isCollect = false
state.collectGallery.splice(index, 1)
},
_disCollectVideo(state, id){
let index
for(let i=0; i < state.collectVideo.length; i++){
if(state.collectVideo[i].id === id){
index = i
break
}
}
state.collectVideo[index].isCollect = false
state.collectVideo.splice(index, 1)
},
_updateGalleryTag(state, data){
for(let i=0; i < state.totalGalleryTask.length; i++){
if(state.totalGalleryTask[i].gid === data.gid){
@@ -366,14 +229,6 @@ const mutations = {
}
}
},
_updateVideoTag(state, data){
for(let i=0; i < state.totalVideoTask.length; i++){
if(state.totalVideoTask[i].gid === data.gid){
state.totalVideoTask[i].tag = data.tag
break
}
}
},
_updateGalleryTasks(state, data){
let {tasks, type} = data
if(type === 'all') {
@@ -396,11 +251,7 @@ const mutations = {
case "下载完成":
task.progress = "下载完成"
let tempLink
let url = new URL(task.link)
state.maskDomain.forEach((mask) => {
if (url.host === mask['raw'])
tempLink = task.link.replace(mask['raw'], mask['mask'])
})
tempLink = task.link.replace("element-plus.org", "exhentai.org").replace("element.org", "e-hentai.org")
task.download = GalleryManageUrl + "/file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
break;
}
@@ -481,82 +332,6 @@ const mutations = {
ElMessage("加载完成")
}
},
_updateVideoTasks(state, data){
let {tasks, type} = data
if(type === 'all') {
state.totalVideoTask.splice(0)
state.collectVideo.splice(0)
state.downloadVideo.splice(0)
tasks.forEach((task) => {
task.progress = task.status
//视频下载很快,所以不太注重下载进度
if (task.status === "下载完成") {
let tempLink
let url = new URL(task.link)
state.maskDomain.forEach((mask) => {
if (url.host === mask['raw'])
tempLink = task.link.replace(mask['raw'], mask['mask'])
})
task.download = VideoManageUrl + "/file/" + encodeURI(task.name) + "?link=" + tempLink + "&AuthCode=" + state.AuthCode
}
//处理时间戳
task.createTimeDisplay = new Date(task.createTime * 1000).toLocaleString("zh")
//处理标签
if(! 'tag' in task)
task.tag = ""
//处理是否收藏
if('collector' in task){
let collector = task.collector.split(",")
delete task.collector
for(let i=0; i<collector.length; i++){
if(parseInt(collector[i]) === state.userId){
task.isCollect = true
state.collectVideo.push(task)
break
}
}
if(!'isCollect' in task)
task.isCollect = false
}
//处理是否下载
if(task.downloader === state.userId)
state.downloadVideo.push(task)
state.totalVideoTask.push(task)
})
}
else{
let tempArray = Array.from(state.totalVideoTask)
state.totalVideoTask.splice(0)
let preDeleteIndex
tempArray.forEach((task) => {
preDeleteIndex = -1
if(task.status !== "下载完成")
for(let i=0; i < tasks.length; i++)
if(tasks[i].name === task.name){
task.progress = tasks[i].status
preDeleteIndex = i
break
}
if(preDeleteIndex !== -1)
delete tasks[preDeleteIndex]
state.totalVideoTask.push(task)
})
}
state.totalVideoTask = state.totalVideoTask.sort((before, after) => {
if(state.sortType === 'name')
return before.name > after.name ? 1: -1
else
return before.createTime - after.createTime
})
},
_changePage(state, targetPage){
state.page = targetPage
},
@@ -581,8 +356,7 @@ const mutations = {
let gid = null
let name = null
if(state.showType === "gallery")
gid = link.split("/")[4]
gid = link.split("/")[4]
if(gid === null)
for (i = 0; i < tasks.length; i++) {
@@ -650,10 +424,6 @@ const mutations = {
let tasks = [state.totalGalleryTask, state.downloadGallery, state.collectGallery]
deleteTask(tasks, 'gid', gid)
},
_deleteVideo(state, id){
let tasks = [state.totalVideoTask, state.downloadVideo, state.collectVideo]
deleteTask(tasks, 'id', id)
},
_setChosenGallery(state,data){
if(data.gallery === false) {
state.chosenGallery.shortName = getShortname(state.chosenGallery.name)
@@ -663,32 +433,15 @@ const mutations = {
state.chosenGallery.progress = "已提交"
state.chosenGallery.tag = ""
state.totalGalleryTask.push(state.chosenGallery)
state.downloadGallery.push(state.chosenGallery)
}
state.chosenGallery = data.gallery
},
_setChosenVideo(state,data){
if(data.video === false) {
state.chosenVideo.resolution = data.resolution
state.chosenVideo.fileSize = "下载完成后再查看"
state.chosenVideo.duration = "下载完成后再查看"
state.chosenVideo.createTimeDisplay = "下载完成后再查看"
state.chosenVideo.progress = "已提交"
state.totalVideoTask.push(state.chosenVideo)
}
state.chosenVideo = data.video
},
_setCategory(state, category){
state.category = category
confirmCurrentTask(state)
sortTasks(state)
},
_setShowType(state, showType){
state.showType = showType
confirmCurrentTask(state)
if(showType === 'video' && state.sortType === "shortName")
state.sortType = 'name'
sortTasks(state)
},
_setSortType(state, sortType){
state.sortType = sortType
sortTasks(state)
@@ -699,9 +452,6 @@ const mutations = {
else
state.length = state.defaultLength
},
_setMaskDomain(state, maskDomain){
state.maskDomain = maskDomain
},
_addAndSetOnlineLinks(state, data){
let links = JSON.parse(data.links)
state.onlineLinks[data.gid] = []
@@ -743,11 +493,6 @@ const state = {
imageWidth: "", //图片宽度
imagePadding: "", //图片padding
totalVideoTask: [], //存放视频数据的数组
chosenVideo: false, //准备下载的视频
collectVideo: [], //收藏的视频
downloadVideo: [], //下载的视频
page: 1, //当前页数
length: 10, //每页能有多少个链接
defaultLength: 7, //默认个数
@@ -759,17 +504,13 @@ const state = {
AuthCode: '', //授权码
loadComplete: false, //是否加载完成
galleryRefreshTimer: 0, //本子更新计时器id
videoRefreshTimer: 0, //视频更新计时器id
isInclude: false, //是否搜索到任务
searchTask: [], //搜索到的任务
showType:'gallery', //展示类型
category: 'myDownload', //分类
sortType:'shortName', //排序类型
currentTasks: [], //当前任务
weekUsed: {}, //每周用量
maskDomain: [] //伪装域名
}
const getters = {
@@ -836,30 +577,17 @@ function getShortname(name){
}
function confirmCurrentTask(state){
if(state.showType === "gallery")
switch (state.category){
case 'myDownload':
state.currentTasks = state.downloadGallery
break
case 'myCollect':
state.currentTasks = state.collectGallery
break
case 'total':
state.currentTasks = state.totalGalleryTask
break
}
else
switch (state.category){
case 'myDownload':
state.currentTasks = state.downloadVideo
break
case 'myCollect':
state.currentTasks = state.collectGallery
break
case 'total':
state.currentTasks = state.totalVideoTask
break
}
switch (state.category){
case 'myDownload':
state.currentTasks = state.downloadGallery
break
case 'myCollect':
state.currentTasks = state.collectGallery
break
case 'total':
state.currentTasks = state.totalGalleryTask
break
}
}
function sortTasks(state){