From 8ea7ca6c4c4f6063e2cd9cac21d59bbc736014e8 Mon Sep 17 00:00:00 2001 From: the1812 Date: Sun, 16 Aug 2020 10:16:21 +0800 Subject: [PATCH] Disable direct download for large videos --- bilibili-evolved.offline.user.js | 8 ++++---- bilibili-evolved.preview-offline.user.js | 8 ++++---- bilibili-evolved.preview.user.js | 6 +++--- bilibili-evolved.user.js | 6 +++--- min/bundle.json | 4 ++-- min/bundle.zip | Bin 2376605 -> 2376650 bytes min/download-video.min.css | 2 +- min/download-video.min.html | 2 +- src/client/utils.js | 2 +- src/video/download-video/download-video.html | 16 ++++++++-------- src/video/download-video/download-video.scss | 3 ++- 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 1e3c71941..363fd9c82 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 761.76 +// @version 761.77 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2020, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -223,7 +223,7 @@ const dqa = (selector, scopedSelector) => { } return [...selector.querySelectorAll(scopedSelector)] } -const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0` +const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0` const EmptyImageUrl = 'data:image/svg+xml;utf-8,' const ascendingSort = (itemProp) => { return (a, b) => itemProp(a) - itemProp(b) @@ -1355,8 +1355,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:a}=e.import("video-info");const{DanmakuConverter:i}=e.import("danmaku-converter");async function o(t){const e=n();let a={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));return e*4/188};const e=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};a.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;a.alpha=(100-parseFloat(dq(".bilibili-player-setting-opacity .bui-thumb-tooltip").innerText))/100;a.duration=(()=>{const e=18-3*t(".bilibili-player-setting-speedplus .bui-thumb");return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();a.blockTypes=(()=>{let t=[];const e={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"]};for(const[n,a]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(a)}}return t.concat(7,8)})();const n=1.4-.2*t(".bilibili-player-setting-fontsize .bui-thumb");a.resolution={x:1920*n,y:1080*n};a.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(a.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){a.bottomMarginPercent=.15}a.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked;const i=localStorage.getItem("bilibili_player_settings");if(i){const t=JSON.parse(i);const e=_.get(t,"block.list",[]);a.blockFilter=(t=>{for(const n of e){if(!n.s){continue}switch(n.t){case"keyword":{if(t.content.includes(n.v)){return false}break}case"regexp":{if(new RegExp(n.v).test(t.content)){return false}break}case"user":{if(t.userHash===n.v){return false}break}}}return true})}}catch(t){a={...a,font:"微软雅黑",alpha:.4,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new i(a);const s=o.convertToAssDocument(t);return s.generateAss()}async function s(t){const e=n();const i=new a((unsafeWindow||window).cid);await i.fetchInfo();const s=await(async()=>{if(t===true){return new Blob([await o(i.rawXML)],{type:"text/plain"})}else{return new Blob([i.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(s);const l=dq("#danmaku-link");const c=l.getAttribute("href");if(c){URL.revokeObjectURL(c)}l.setAttribute("download",`${e}.${t?"ass":"xml"}`);l.setAttribute("href",r);l.click()}return{export:{downloadDanmaku:s,convertToAss:o},widget:{content:`\n\n\n\n下载弹幕(XML)\n\n\n\n下载弹幕(ASS)\n\n`,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=dq("#download-danmaku-xml");const e=dq("#download-danmaku-ass");const n=[t,e];const a=(t,e)=>{t.addEventListener("click",async()=>{try{n.forEach(t=>t.disabled=true);await s(e)}catch(t){logError(t)}finally{n.forEach(t=>t.disabled=false)}})};a(t,false);a(e,true)}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-live-records.min.js"] = (()=>{return(t,o)=>{const e=()=>document.URL.replace(location.search,"").match(/https:\/\/live\.bilibili\.com\/record\/(.+)/);return{widget:{content:`\n`,condition:async()=>{const t=e();return Boolean(t)},success:()=>{const t=dq("#download-live-records");t.addEventListener("click",async()=>{try{t.disabled=true;const o=e()[1];const n=await Ajax.getJson(`https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl?rid=${o}&platform=html5`);if(n.code!==0){logError(new Error(`获取录像链接失败: ${n.message}`));return}const i=n.data.list.map(t=>t.url);Toast.success(i.map(t=>`${t}`).join("\n"),"下载录像")}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-subtitle.min.js"] = (()=>{return(t,e)=>{let n;const i=(t,e)=>{const i=document.createElement("a");const o=URL.createObjectURL(new Blob([t]));if(n){URL.revokeObjectURL(n)}n=o;i.setAttribute("href",o);i.setAttribute("download",escapeFilename(e));document.body.appendChild(i);i.click();i.remove()};const o=async()=>{const{getFriendlyTitle:t}=await e.importAsync("title");const{SubtitleConverter:n,SubtitleSize:i,SubtitleLocation:o}=await e.importAsync("subtitle-converter");const s=await loadSubtitleSettingsPanel();if(!s){logError("未找到字幕设置");return[n.defaultConfig,""]}const l=s.querySelector(".bilibili-player-video-subtitle-setting-lan .bui-select-result").innerHTML;const a=t(true);const c=s.querySelector(".bilibili-player-video-subtitle-setting-fontsize .bui-thumb");const r=parseFloat(c.style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const u={214:i.VeryLarge,163.5:i.Large,107:i.Medium,50.5:i.Small,0:i.VerySmall};const b=u[r];const d=s.querySelector(".bilibili-player-video-subtitle-setting-color .bui-select-result span:first-child");const p=d.getAttribute("style").match(/background:[ ]*(.+);/)[1];const g=s.querySelector(".bilibili-player-video-subtitle-setting-opacity .bui-bar");const f=parseFloat(g.style.transform.replace(/scaleX\(([\d\.]+)/,"$1"));const y=dq(".subtitle-position");const w={bc:o.BottomCenter,bl:o.BottomLeft,br:o.BottomRight,tc:o.TopCenter,tl:o.TopLeft,tr:o.TopRight};const m=Object.entries(w).filter(([t])=>{return y.classList.contains(`subtitle-position-${t}`)}).map(([,t])=>t).shift();const S=dq("video");const h={title:a,height:S.videoHeight,width:S.videoWidth,color:p,location:m,opacity:f,size:b,boxPadding:1,boxMargin:32};return[h,l]};const s=async(t,n)=>{const{VideoInfo:i}=await e.importAsync("video-info");const o=new i(t);o.cid=typeof n==="string"?parseInt(n):n;await o.fetchInfo();return o.subtitles};return{widget:{content:`\n\n\n`,condition:videoCondition,success:()=>{const t=dq("#download-subtitle-json");const n=dq("#download-subtitle-ass");const l=[t,n];const a=(t,n)=>{t.addEventListener("click",async()=>{try{l.forEach(t=>t.disabled=true);const{aid:t,cid:a}=unsafeWindow;if(!t||!a){logError("未找到视频AID和CID");return}const c=await s(t,a);if(c.length===0){Toast.info("当前视频没有字幕.","下载字幕",3e3);return}const[r,u]=await o();const b=c.find(t=>t.language===u)||c[0];const d=await Ajax.getJson(b.url);const p=d.body;if(n){const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const n=new t(r);const o=await n.convertToAss(p);i(o,r.title+".ass")}else{i(JSON.stringify(p),r.title+".json")}}catch(t){logError(t)}finally{l.forEach(t=>t.disabled=false)}})};a(t,false);a(n,true)}},export:{getSubtitleConfig:o,getSubtitleList:s}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:22px;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px;align-self:center}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:a}=e.import("title");const{VideoInfo:s,DanmakuInfo:i}=e.import("video-info");const{DownloadVideoPackage:n}=e.import("download-video-package");class o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnver=0&fnval=16`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json`}}}return e.bind(this)}async getDashUrl(t){return(await this.getApiGenerator(true))(c.aid,c.cid,t)}async getUrl(t){return(await this.getApiGenerator())(c.aid,c.cid,t)}}class r extends o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnval=16`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnval=16`}}else{if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=&otype=json`}}}return e.bind(this)}}class l extends o{constructor(t){super();this.ep=t}async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}`}}}return e.bind(this)}}const c={entity:new o,aid:"",cid:""};let d=[];let u=null;class p{constructor(t,e,a){this.quality=t;this.internalName=e;this.displayName=a}async downloadInfo(t=false){const e=new m(this);await e.fetchVideoInfo(t);return e}static parseFormats(t){const e=t.accept_quality;const a=t.accept_format.split(",");const s=t.accept_description;const i=e.map((t,e)=>{return new p(t,a[e],s[e])});return i}static async filterFormats(t){return t}static async getAvailableDashFormats(){const t=await c.entity.getDashUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}static async getAvailableFormats(){const t=await c.entity.getUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}}const h=[new p(120,"4K","超清 4K"),new p(116,"1080P60","高清 1080P60"),new p(112,"1080P+","高清 1080P+"),new p(80,"1080P","高清 1080P"),new p(74,"720P60","高清 720P60"),new p(64,"720P","高清 720P"),new p(32,"480P","清晰 480P"),new p(15,"320P","流畅 320P")];class m{constructor(t,e){this.subtitle=false;this.fragmentSplitFactor=6*2;this.workingXhr=null;this.progressMap=new Map;this.format=t;this.fragments=e||[];this.videoSpeed=new f(this)}get danmakuOption(){return t.downloadVideoDefaultDanmaku}get subtitleOption(){return t.downloadVideoDefaultSubtitle}get isDash(){return this.fragments.some(t=>t.url.includes(".m4s"))}get totalSize(){return this.fragments.map(t=>t.size).reduce((t,e)=>t+e)}async fetchVideoInfo(t=false){if(!t){const t=await c.entity.getUrl(this.format.quality);const a=await Ajax.getTextWithCredentials(t);const s=JSON.parse(a.replace(/http:/g,"https:"));const i=s.data||s.result||s;const n=this.format.quality;if(i.quality!==n){const{throwQualityError:t}=await e.importAsync("quality-errors");t(n)}const o=i.durl;this.fragments=o.map(t=>{return{length:t.length,size:t.size,url:t.url,backupUrls:t.backup_url}})}else{const{dashToFragments:t,getDashInfo:a}=await e.importAsync("video-dash");const s=await a(await c.entity.getDashUrl(this.format.quality),this.format.quality);this.fragments=t(s)}return this.fragments}updateProgress(){const t=this.progressMap?[...this.progressMap.values()].reduce((t,e)=>t+e,0)/this.totalSize:0;if(t>1||t<0){console.error(`[下载视频] 进度异常: ${t}`,this.progressMap.values())}this.progress&&this.progress(t)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(t=>t.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(t){const e=[];const a=this.isDash?4*1024*1024:16*1024*1024;let s;if(t.size<=a*6){s=t.size/this.fragmentSplitFactor}else{s=a}let i=0;const n=t=>[...this.progressMap.keys()].indexOf(t)+1;while(i{const s=new XMLHttpRequest;s.open("GET",t.url);s.responseType="arraybuffer";s.withCredentials=false;s.addEventListener("progress",t=>{console.log(`[下载视频] 视频片段${n(s)}下载进度: ${t.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(s,t.loaded);this.updateProgress()});s.addEventListener("load",()=>{if((""+s.status)[0]==="2"){console.log(`[下载视频] 视频片段${n(s)}下载完成`);e(s.response)}else{a(`视频片段${n(s)}请求失败, response = ${s.status}`)}});s.addEventListener("abort",()=>a("canceled"));s.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${n(s)}下载失败: ${o}`);this.progressMap.set(s,0);this.updateProgress();s.open("GET",t.url);s.setRequestHeader("Range",o);s.send()});s.setRequestHeader("Range",o);this.progressMap.set(s,0);s.send();this.workingXhr.push(s)}));i=Math.round(i+s)+1}return Promise.all(e)}async copyUrl(){const t=this.fragments.map(t=>t.url).reduce((t,e)=>t+"\r\n"+e);GM.setClipboard(t,"text")}async showUrl(){const t=this.fragments.map(t=>`\n${t.url}\n`).reduce((t,e)=>t+"\r\n"+e);Toast.success(t+`复制全部`,"显示链接");const e=await SpinQuery.select("#copy-link");e.addEventListener("click",async()=>{await this.copyUrl()})}async exportIdm(){const{toIdmFormat:t}=await e.importAsync("idm-support");const s=t([this]);const i=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,i);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);r.add(`${a()}.ef2`,s);await r.emit(`${a()}.zip`)}async exportData(t=false){const e=JSON.stringify([{fragments:this.fragments,title:a(),totalSize:this.fragments.map(t=>t.size).reduce((t,e)=>t+e),referer:document.URL.replace(window.location.search,"")}]);if(t){GM.setClipboard(e,"text")}else{const t=new Blob([e],{type:"text/json"});const s=await this.downloadDanmaku();const i=new n;i.add(`${a()}.json`,t);i.add(a()+"."+this.danmakuOption.toLowerCase(),s);await i.emit(`${a()}.zip`)}}async exportAria2(s=false){const{getNumber:i}=await e.importAsync("get-number");if(s){const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,s);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);await r.emit();const l=t.aria2RpcOption;const c=this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}const n=[];if(l.secretKey!==""){n.push(`token:${l.secretKey}`)}n.push([t.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":UserAgent,out:`${a()}${s}${this.extension(t)}`,split:this.fragmentSplitFactor,dir:l.baseDir+l.dir||undefined,"max-download-limit":l.maxDownloadLimit||undefined});const o=encodeURIComponent(`${a()}${s}`);return{params:n,id:o}});const{sendRpc:d}=await e.importAsync("aria2-rpc");await d(c)}else{const t=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}return`\n${t.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=${UserAgent}\n out=${a()}${s}${this.extension(t)}\n split=${this.fragmentSplitFactor}\n`.trim()}).join("\n")}\n`.trim();const e=new Blob([t],{type:"text/plain"});const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.txt`,e);r.add(a()+"."+this.danmakuOption.toLowerCase(),s);r.add(a()+"."+this.subtitleOption.toLowerCase(),o);await r.emit(`${a()}.zip`)}}extension(t){const e=t||this.fragments[0];const a=[".flv",".mp4"].find(t=>e.url.includes(t));if(a){return a}else if(e.url.includes(".m4s")){return this.fragments.indexOf(e)===0?".mp4":".m4a"}else{console.warn("No extension detected.");return".flv"}}async downloadDanmaku(){if(this.danmakuOption!=="无"){const t=new i(c.cid);await t.fetchInfo();if(this.danmakuOption==="XML"){return t.rawXML}else{const{convertToAss:a}=await e.importAsync("download-danmaku");return a(t.rawXML)}}else{return null}}async downloadSubtitle(){if(this.subtitle&&this.subtitleOption!=="无"){const{getSubtitleConfig:t,getSubtitleList:a}=await e.importAsync("download-subtitle");const[s,i]=await t();const n=await a(c.aid,c.cid);const o=n.find(t=>t.language===i)||n[0];const r=await Ajax.getJson(o.url);const l=r.body;if(this.subtitleOption==="JSON"){return l}else{const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const a=new t(s);const i=await a.convertToAss(l);return i}}return null}async download(){this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const t=[];this.videoSpeed.startMeasure();for(const e of this.fragments){const a=await this.downloadFragment(e);t.push(a)}if(t.length<1){throw new Error("下载失败.")}const s=a();const i=new n;const{getNumber:o}=await e.importAsync("get-number");t.forEach((e,a)=>{let n;const r=this.fragments[a];if(t.length>1&&!this.isDash){n=`${s} - ${o(a+1,t.length)}${this.extension(r)}`}else{n=`${s}${this.extension(r)}`}i.add(n,new Blob(Array.isArray(e)?e:[e]))});const r=await this.downloadDanmaku();i.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,r);const l=await this.downloadSubtitle();i.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,l);await i.emit(s+".zip");this.progress&&this.progress(0);this.videoSpeed.stopMeasure()}}class f{constructor(t){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=t}startMeasure(){this.intervalTimer=setInterval(()=>{const t=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((t,e)=>t+e,0):0;const e=t-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(e)+"/s")}this.lastProgress=t},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const t=await SpinQuery.select(()=>(unsafeWindow||window).aid);const e=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(t&&e)){return false}c.aid=t;c.cid=e;if(document.URL.includes("bangumi")){c.entity=new r}else if(document.URL.includes("cheese")){const t=document.URL.match(/cheese\/play\/ep([\d]+)/);c.entity=new l(t[1])}else{c.entity=new o}try{d=await p.getAvailableFormats()}catch(t){return false}return true}const g=e=>{const a=t.downloadVideoQuality;const s=e.find(t=>t.quality===a);if(s){return s}const i=e.filter(t=>t.quality{const t=dq(".download-video");t.classList.toggle("opened");window.scroll(0,0);dq(".gui-settings-mask").click()});t.addEventListener("mouseover",()=>{b()},{once:true})}async function b(){let r;const l=[{name:"single",displayName:"单个视频"},{name:"batch",displayName:"批量导出"},{name:"manual",displayName:"手动输入"}];const f=new Vue({template:e.import("downloadVideoHtml"),components:{VDropdown:()=>e.importAsync("v-dropdown.vue"),VCheckbox:()=>e.importAsync("v-checkbox.vue"),RpcProfiles:()=>e.importAsync("aria2-rpc-profiles.vue")},data:{batch:false,subtitle:false,selectedTab:l[0],coverUrl:EmptyImageUrl,aid:c.aid,cid:c.cid,dashModel:{value:t.downloadVideoFormat,items:["flv","dash"]},qualityModel:{value:u.displayName,items:d.map(t=>t.displayName)},manualQualityModel:{value:h[1].displayName,items:h.map(t=>t.displayName)},danmakuModel:{value:t.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},subtitleModel:{value:t.downloadVideoDefaultSubtitle,items:["无","JSON","ASS"]},codecModel:{value:t.downloadVideoDashCodec,items:["AVC/H.264","HEVC/H.265"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",rpcSettings:t.aria2RpcOption,showRpcSettings:false,busy:false,saveRpcSettingsText:"保存配置",enableDash:t.enableDashDownload,lastDirectDownloadLink:"",manualInputText:""},computed:{tabs(){if(this.batch){return l}const t=[...l];_.remove(t,t=>t.name==="batch");return t},manualInputItems(){const t=this.manualInputText.split(/\s/g);const e=t.map(t=>t.match(/av(\d+)/i)||t.match(/^(\d+)$/));return _.uniq(e.filter(t=>t!==null).map(t=>t[1]))},downloadSingle(){return this.selectedTab.name==="single"},displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(t=>t.checked).length},dash(){return this.dashModel.value==="dash"}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){t.downloadVideoDefaultDanmaku=this.danmakuModel.value},subtitleOptionChange(){t.downloadVideoDefaultSubtitle=this.subtitleModel.value},async codecChange(){t.downloadVideoDashCodec=this.codecModel.value;await this.formatChange()},async dashChange(){const e=t.downloadVideoFormat=this.dashModel.value;let a=[];if(e==="flv"){a=await p.getAvailableFormats()}else{a=await p.getAvailableDashFormats()}d=a;u=g(d);this.qualityModel.items=a.map(t=>t.displayName);this.qualityModel.value=this.qualityModel.items[d.indexOf(u)];await this.formatChange()},async formatChange(e=false){const a=this.getFormat();if(e){t.downloadVideoQuality=a.quality}try{this.size="获取大小中";const t=await a.downloadInfo(this.dash);this.size=t.totalSize}catch(t){this.size="获取大小失败";throw t}},getManualFormat(){let t;t=h.find(t=>t.displayName===this.manualQualityModel.value);if(!t){console.error(`No format found. model value = ${this.manualQualityModel.value}`);return null}return t},getFormat(){let t;t=d.find(t=>t.displayName===this.qualityModel.value);if(!t){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return t},async exportData(t){if(this.busy===true){return}try{this.busy=true;if(this.selectedTab.name==="batch"){await this.exportBatchData(t);return}if(this.selectedTab.name==="manual"){await this.exportManualData(t);return}const s=this.getFormat();const i=await s.downloadInfo(this.dash);i.subtitle=this.subtitle;switch(t){case"copyLink":await i.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"showLink":await i.showUrl();break;case"aria2":await i.exportAria2(false);break;case"aria2RPC":await i.exportAria2(true);break;case"copyVLD":await i.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await i.exportData(false);break;case"ffmpegFragments":if(i.fragments.length<2){Toast.info("当前视频没有分段.","分段合并",3e3)}else{const{getFragmentsList:t}=await e.importAsync("ffmpeg-support");const s=new n;s.add("ffmpeg-files.txt",t(i.fragments.length,a(),i.fragments.map(t=>i.extension(t))));await s.emit()}break;case"idm":await i.exportIdm();break;default:break}}catch(t){logError(t)}finally{this.busy=false}},async exportBatchData(t){const s=this.episodeList;if(s.every(t=>t.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const o=t=>{const e=s.find(e=>e.cid===t.cid);if(e===undefined){return false}return e.checked};const r=this.batchExtractor;const l=this.getFormat();if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","批量导出");const a=new n;try{if(this.danmakuModel.value==="XML"){for(const t of s.filter(o)){const e=new i(t.cid);await e.fetchInfo();a.add(r.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of s.filter(o)){const s=new i(e.cid);await s.fetchInfo();a.add(r.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await a.emit(this.cid+".danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const a=new n;try{const{getSubtitleConfig:i,getSubtitleList:n}=await e.importAsync("download-subtitle");const[l,c]=await i();for(const t of s.filter(o)){const s=await n(t.aid,t.cid);const i=s.find(t=>t.language===c)||s[0];if(i===undefined){continue}const o=await Ajax.getJson(i.url);const d=o.body;if(this.subtitleModel.value==="JSON"){a.add(r.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const i=new s(l);const n=await i.convertToAss(d);a.add(r.formatTitle(t.titleParameters)+".ass",n)}}await a.emit(this.cid+".subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const d=Toast.info("获取链接中...","批量导出");r.config.itemFilter=o;r.config.api=await c.entity.getApiGenerator(this.dash);let u;try{switch(t){case"idm":const s=await r.getRawItems(l);const{toIdmFormat:i}=await e.importAsync("idm-support");u=i(s);await n.single(a(false)+".ef2",new Blob([u],{type:"text/plain"}));return;case"aria2":u=await r.collectAria2(l,d,false);await n.single(a(false)+".txt",new Blob([u],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});return;case"aria2RPC":await r.collectAria2(l,d,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM.setClipboard(await r.collectData(l,d),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":u=await r.collectData(l,d);await n.single(a(false)+".json",new Blob([u],{type:"text/json"}),{ffmpeg:this.ffmpegOption});return;case"ffmpegFragments":{const t=await r.getRawItems(l);if(t.every(t=>t.fragments.length<2)){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const s=new m(l,t[0].fragments);const{getBatchFragmentsList:i}=await e.importAsync("ffmpeg-support");const o=i(t,this.dash||s.extension());if(!o){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const c=new n;for(const[t,e]of o.entries()){c.add(t,e)}await c.emit(escapeFilename(`${a(false)}.zip`))}break;case"ffmpegEpisodes":{const t=await r.getRawItems(l);const a=new m(l,t[0].fragments);const{getBatchEpisodesList:s}=await e.importAsync("ffmpeg-support");const i=s(t,this.dash||a.extension());const o=new n;o.add("ffmpeg-files.txt",i);await o.emit()}break;default:return}}catch(t){logError(t)}finally{d.dismiss()}},async exportManualData(t){if(this.manualInputItems.length===0){Toast.info("请至少输入一个有效的视频链接!","手动输入",3e3);return}const{ManualInputBatch:a}=await e.importAsync("batch-download");const s=new a({api:await(new o).getApiGenerator(this.dash),itemFilter:()=>true});s.items=this.manualInputItems;if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","手动输入");const o=new n;try{if(this.danmakuModel.value==="XML"){for(const t of await s.getItemList()){const e=new i(t.cid);await e.fetchInfo();o.add(a.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of await s.getItemList()){const s=new i(e.cid);await s.fetchInfo();o.add(a.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await o.emit("manual-exports.danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const i=new n;try{const{getSubtitleConfig:n,getSubtitleList:o}=await e.importAsync("download-subtitle");const[r,l]=await n();for(const t of await s.getItemList()){const s=await o(t.aid,t.cid);const n=s.find(t=>t.language===l)||s[0];const c=await Ajax.getJson(n.url);const d=c.body;if(this.subtitleModel.value==="JSON"){i.add(a.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const n=new s(r);const o=await n.convertToAss(d);i.add(a.formatTitle(t.titleParameters)+".ass",o)}}await i.emit("manual-exports.subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const r=Toast.info("获取链接中...","手动输入");try{switch(t){default:case"aria2":{const t=await s.collectAria2(this.getManualFormat().quality,false);await n.single("manual-exports.txt",new Blob([t],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});break}case"aria2RPC":{await s.collectAria2(this.getManualFormat().quality,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);break}case"idm":{const t=await s.getRawItems(this.getManualFormat().quality);const{toIdmFormat:a}=await e.importAsync("idm-support");const i=a(t);await n.single("manual-exports.ef2",new Blob([i],{type:"text/plain"}));break}}}catch(t){logError(t)}finally{r.dismiss()}},async checkBatch(){const t=["//www.bilibili.com/bangumi","//www.bilibili.com/video","//www.bilibili.com/blackboard/bnj2020.html"];if(!t.some(t=>document.URL.includes(t))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:a}=await e.importAsync("batch-download");if(await a.test()!==true){this.batch=false;this.episodeList=[];return}const s=this.batchExtractor=new a;this.batch=true;this.episodeList=(await s.getItemList()).map((t,e)=>{return{aid:t.aid,cid:t.cid,title:t.title,titleParameters:t.titleParameters,index:e,checked:true}})},async checkSubtitle(){const{getSubtitleList:t}=await e.importAsync("download-subtitle");const a=await t(c.aid,c.cid);this.subtitle=a.length>0},cancelDownload(){if(r){r.cancelDownload()}},async startDownload(){const t=this.getFormat();try{this.downloading=true;const e=await t.downloadInfo(this.dash);e.subtitle=this.subtitle;e.videoSpeed.speedUpdate=(t=>this.speed=t);e.progress=(t=>{this.progressPercent=Math.trunc(t*100)});r=e;await e.download();this.lastDirectDownloadLink=n.lastPackageUrl}catch(t){if(t!=="canceled"){logError(t)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(t=>t.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(t=>t.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(t=>t.checked=!t.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}t.aria2RpcOption=this.rpcSettings;const e=t.aria2RpcOptionProfiles.find(e=>e.name===t.aria2RpcOptionSelectedProfile);if(e){Object.assign(e,this.rpcSettings);t.aria2RpcOptionProfiles=t.aria2RpcOptionProfiles}this.saveRpcSettingsText="已保存";setTimeout(()=>this.saveRpcSettingsText="保存配置",2e3)},updateProfile(e){t.aria2RpcOption=this.rpcSettings=_.omit(e,"name")}},async mounted(){}});const y=f.$mount().$el;document.body.insertAdjacentElement("beforeend",y);Observer.videoChange(async()=>{f.close();f.batch=false;f.selectedTab=l[0];const t=dq("#download-video");const e=await w();t.style.display=e?"flex":"none";if(!e){return}f.aid=c.aid;f.cid=c.cid;try{const t=new s(c.aid);await t.fetchInfo();f.coverUrl=t.coverUrl.replace("http:","https:")}catch(t){f.coverUrl=EmptyImageUrl}f.dashChange();f.checkSubtitle();await f.checkBatch()})}return{widget:{content:`\n`,condition:w,success:y}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video-package.min.js"] = (()=>{return(e,t)=>{class n{constructor(e={}){this.config=e;this.entries=[]}download(e,t){const a=document.createElement("a");const i=URL.createObjectURL(t);if(n.lastPackageUrl){URL.revokeObjectURL(n.lastPackageUrl)}n.lastPackageUrl=i;a.setAttribute("href",i);a.setAttribute("download",escapeFilename(e));document.body.appendChild(a);a.click();a.remove()}add(e,t){if(t===null||t===undefined){return}console.log(`add file: ${escapeFilename(e)}`);this.entries.push({name:escapeFilename(e),data:t})}async blob(){if(this.entries.length===0){return null}if(this.entries.length===1){const e=this.entries[0].data;return typeof e==="string"?new Blob([e]):e}const e=new JSZip;this.entries.forEach(({name:t,data:n})=>{e.file(t,n)});return await e.generateAsync({type:"blob"})}async emit(e){if(this.entries.length===0){return}if(!e||this.entries.length===1){e=this.entries[0].name}const t=await this.blob();if(!t){return}return this.download(e,t)}static async single(e,t,a={}){const i=new n(a);i.add(e,t);return await i.emit()}}n.lastPackageUrl="";return{export:{DownloadVideoPackage:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dpi-img.vue.min.js"] = (()=>{return(t,e)=>{const s=``;return{export:Object.assign({template:s},{props:{size:[Object,Number],src:String,blur:Number,root:HTMLElement,rootMargin:String,threshold:Number,placeholderImage:Boolean},data(){return{srcset:null,actualSrc:null,isPlaceholderActive:false}},watch:{size(){this.sourceChange()},src(){this.sourceChange()}},methods:{sourceChange(){if(this.actualSrc===null||this.srcset===null){return}this.calcSrc()},calcSrc(){const t=!this.src||!this.size;this.isPlaceholderActive=t&&this.placeholderImage;if(t){this.srcset=null;if(this.placeholderImage){this.actualSrc=`https://s1.hdslb.com/bfs/static/blive/live-web-center/static/img/no-cover.1ebe4d5.jpg`}else{this.actualSrc=null}return}let e=this.src;if(e.startsWith("http:")){e=e.replace("http:","https:")}if(e.includes("//static.hdslb.com/images/member/noface.gif")){this.srcset=e;this.actualSrc=e;return}const s=e.substring(e.lastIndexOf(".")+1);this.srcset=getDpiSourceSet(e,this.size,s);this.actualSrc=e}},mounted(){const t={root:this.root,rootMargin:this.rootMargin||"200px",threshold:this.threshold};const e=new IntersectionObserver(t=>{t.forEach(t=>{if(t.isIntersecting){this.calcSrc();e.disconnect()}})},t);e.observe(this.$el)},computed:{width(){if(typeof this.size==="object"&&"width"in this.size){return this.size.width}return null},height(){if(typeof this.size==="object"&&"height"in this.size){return this.size.height}return null},filter(){const t=[];if(this.blur){t.push(`blur(${this.blur}px)`)}return t.join(" ")}}})}}})(); diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index ba10df324..6d4bb00da 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 761.76 +// @version 761.77 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2020, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -223,7 +223,7 @@ const dqa = (selector, scopedSelector) => { } return [...selector.querySelectorAll(scopedSelector)] } -const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0` +const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0` const EmptyImageUrl = 'data:image/svg+xml;utf-8,' const ascendingSort = (itemProp) => { return (a, b) => itemProp(a) - itemProp(b) @@ -1355,8 +1355,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:a}=e.import("video-info");const{DanmakuConverter:i}=e.import("danmaku-converter");async function o(t){const e=n();let a={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));return e*4/188};const e=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};a.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;a.alpha=(100-parseFloat(dq(".bilibili-player-setting-opacity .bui-thumb-tooltip").innerText))/100;a.duration=(()=>{const e=18-3*t(".bilibili-player-setting-speedplus .bui-thumb");return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();a.blockTypes=(()=>{let t=[];const e={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"]};for(const[n,a]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(a)}}return t.concat(7,8)})();const n=1.4-.2*t(".bilibili-player-setting-fontsize .bui-thumb");a.resolution={x:1920*n,y:1080*n};a.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(a.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){a.bottomMarginPercent=.15}a.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked;const i=localStorage.getItem("bilibili_player_settings");if(i){const t=JSON.parse(i);const e=_.get(t,"block.list",[]);a.blockFilter=(t=>{for(const n of e){if(!n.s){continue}switch(n.t){case"keyword":{if(t.content.includes(n.v)){return false}break}case"regexp":{if(new RegExp(n.v).test(t.content)){return false}break}case"user":{if(t.userHash===n.v){return false}break}}}return true})}}catch(t){a={...a,font:"微软雅黑",alpha:.4,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new i(a);const s=o.convertToAssDocument(t);return s.generateAss()}async function s(t){const e=n();const i=new a((unsafeWindow||window).cid);await i.fetchInfo();const s=await(async()=>{if(t===true){return new Blob([await o(i.rawXML)],{type:"text/plain"})}else{return new Blob([i.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(s);const l=dq("#danmaku-link");const c=l.getAttribute("href");if(c){URL.revokeObjectURL(c)}l.setAttribute("download",`${e}.${t?"ass":"xml"}`);l.setAttribute("href",r);l.click()}return{export:{downloadDanmaku:s,convertToAss:o},widget:{content:`\n\n\n\n下载弹幕(XML)\n\n\n\n下载弹幕(ASS)\n\n`,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=dq("#download-danmaku-xml");const e=dq("#download-danmaku-ass");const n=[t,e];const a=(t,e)=>{t.addEventListener("click",async()=>{try{n.forEach(t=>t.disabled=true);await s(e)}catch(t){logError(t)}finally{n.forEach(t=>t.disabled=false)}})};a(t,false);a(e,true)}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-live-records.min.js"] = (()=>{return(t,o)=>{const e=()=>document.URL.replace(location.search,"").match(/https:\/\/live\.bilibili\.com\/record\/(.+)/);return{widget:{content:`\n`,condition:async()=>{const t=e();return Boolean(t)},success:()=>{const t=dq("#download-live-records");t.addEventListener("click",async()=>{try{t.disabled=true;const o=e()[1];const n=await Ajax.getJson(`https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl?rid=${o}&platform=html5`);if(n.code!==0){logError(new Error(`获取录像链接失败: ${n.message}`));return}const i=n.data.list.map(t=>t.url);Toast.success(i.map(t=>`${t}`).join("\n"),"下载录像")}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-subtitle.min.js"] = (()=>{return(t,e)=>{let n;const i=(t,e)=>{const i=document.createElement("a");const o=URL.createObjectURL(new Blob([t]));if(n){URL.revokeObjectURL(n)}n=o;i.setAttribute("href",o);i.setAttribute("download",escapeFilename(e));document.body.appendChild(i);i.click();i.remove()};const o=async()=>{const{getFriendlyTitle:t}=await e.importAsync("title");const{SubtitleConverter:n,SubtitleSize:i,SubtitleLocation:o}=await e.importAsync("subtitle-converter");const s=await loadSubtitleSettingsPanel();if(!s){logError("未找到字幕设置");return[n.defaultConfig,""]}const l=s.querySelector(".bilibili-player-video-subtitle-setting-lan .bui-select-result").innerHTML;const a=t(true);const c=s.querySelector(".bilibili-player-video-subtitle-setting-fontsize .bui-thumb");const r=parseFloat(c.style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const u={214:i.VeryLarge,163.5:i.Large,107:i.Medium,50.5:i.Small,0:i.VerySmall};const b=u[r];const d=s.querySelector(".bilibili-player-video-subtitle-setting-color .bui-select-result span:first-child");const p=d.getAttribute("style").match(/background:[ ]*(.+);/)[1];const g=s.querySelector(".bilibili-player-video-subtitle-setting-opacity .bui-bar");const f=parseFloat(g.style.transform.replace(/scaleX\(([\d\.]+)/,"$1"));const y=dq(".subtitle-position");const w={bc:o.BottomCenter,bl:o.BottomLeft,br:o.BottomRight,tc:o.TopCenter,tl:o.TopLeft,tr:o.TopRight};const m=Object.entries(w).filter(([t])=>{return y.classList.contains(`subtitle-position-${t}`)}).map(([,t])=>t).shift();const S=dq("video");const h={title:a,height:S.videoHeight,width:S.videoWidth,color:p,location:m,opacity:f,size:b,boxPadding:1,boxMargin:32};return[h,l]};const s=async(t,n)=>{const{VideoInfo:i}=await e.importAsync("video-info");const o=new i(t);o.cid=typeof n==="string"?parseInt(n):n;await o.fetchInfo();return o.subtitles};return{widget:{content:`\n\n\n`,condition:videoCondition,success:()=>{const t=dq("#download-subtitle-json");const n=dq("#download-subtitle-ass");const l=[t,n];const a=(t,n)=>{t.addEventListener("click",async()=>{try{l.forEach(t=>t.disabled=true);const{aid:t,cid:a}=unsafeWindow;if(!t||!a){logError("未找到视频AID和CID");return}const c=await s(t,a);if(c.length===0){Toast.info("当前视频没有字幕.","下载字幕",3e3);return}const[r,u]=await o();const b=c.find(t=>t.language===u)||c[0];const d=await Ajax.getJson(b.url);const p=d.body;if(n){const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const n=new t(r);const o=await n.convertToAss(p);i(o,r.title+".ass")}else{i(JSON.stringify(p),r.title+".json")}}catch(t){logError(t)}finally{l.forEach(t=>t.disabled=false)}})};a(t,false);a(n,true)}},export:{getSubtitleConfig:o,getSubtitleList:s}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:22px;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px;align-self:center}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:a}=e.import("title");const{VideoInfo:s,DanmakuInfo:i}=e.import("video-info");const{DownloadVideoPackage:n}=e.import("download-video-package");class o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnver=0&fnval=16`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json`}}}return e.bind(this)}async getDashUrl(t){return(await this.getApiGenerator(true))(c.aid,c.cid,t)}async getUrl(t){return(await this.getApiGenerator())(c.aid,c.cid,t)}}class r extends o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnval=16`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnval=16`}}else{if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=&otype=json`}}}return e.bind(this)}}class l extends o{constructor(t){super();this.ep=t}async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}`}}}return e.bind(this)}}const c={entity:new o,aid:"",cid:""};let d=[];let u=null;class p{constructor(t,e,a){this.quality=t;this.internalName=e;this.displayName=a}async downloadInfo(t=false){const e=new m(this);await e.fetchVideoInfo(t);return e}static parseFormats(t){const e=t.accept_quality;const a=t.accept_format.split(",");const s=t.accept_description;const i=e.map((t,e)=>{return new p(t,a[e],s[e])});return i}static async filterFormats(t){return t}static async getAvailableDashFormats(){const t=await c.entity.getDashUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}static async getAvailableFormats(){const t=await c.entity.getUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}}const h=[new p(120,"4K","超清 4K"),new p(116,"1080P60","高清 1080P60"),new p(112,"1080P+","高清 1080P+"),new p(80,"1080P","高清 1080P"),new p(74,"720P60","高清 720P60"),new p(64,"720P","高清 720P"),new p(32,"480P","清晰 480P"),new p(15,"320P","流畅 320P")];class m{constructor(t,e){this.subtitle=false;this.fragmentSplitFactor=6*2;this.workingXhr=null;this.progressMap=new Map;this.format=t;this.fragments=e||[];this.videoSpeed=new f(this)}get danmakuOption(){return t.downloadVideoDefaultDanmaku}get subtitleOption(){return t.downloadVideoDefaultSubtitle}get isDash(){return this.fragments.some(t=>t.url.includes(".m4s"))}get totalSize(){return this.fragments.map(t=>t.size).reduce((t,e)=>t+e)}async fetchVideoInfo(t=false){if(!t){const t=await c.entity.getUrl(this.format.quality);const a=await Ajax.getTextWithCredentials(t);const s=JSON.parse(a.replace(/http:/g,"https:"));const i=s.data||s.result||s;const n=this.format.quality;if(i.quality!==n){const{throwQualityError:t}=await e.importAsync("quality-errors");t(n)}const o=i.durl;this.fragments=o.map(t=>{return{length:t.length,size:t.size,url:t.url,backupUrls:t.backup_url}})}else{const{dashToFragments:t,getDashInfo:a}=await e.importAsync("video-dash");const s=await a(await c.entity.getDashUrl(this.format.quality),this.format.quality);this.fragments=t(s)}return this.fragments}updateProgress(){const t=this.progressMap?[...this.progressMap.values()].reduce((t,e)=>t+e,0)/this.totalSize:0;if(t>1||t<0){console.error(`[下载视频] 进度异常: ${t}`,this.progressMap.values())}this.progress&&this.progress(t)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(t=>t.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(t){const e=[];const a=this.isDash?4*1024*1024:16*1024*1024;let s;if(t.size<=a*6){s=t.size/this.fragmentSplitFactor}else{s=a}let i=0;const n=t=>[...this.progressMap.keys()].indexOf(t)+1;while(i{const s=new XMLHttpRequest;s.open("GET",t.url);s.responseType="arraybuffer";s.withCredentials=false;s.addEventListener("progress",t=>{console.log(`[下载视频] 视频片段${n(s)}下载进度: ${t.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(s,t.loaded);this.updateProgress()});s.addEventListener("load",()=>{if((""+s.status)[0]==="2"){console.log(`[下载视频] 视频片段${n(s)}下载完成`);e(s.response)}else{a(`视频片段${n(s)}请求失败, response = ${s.status}`)}});s.addEventListener("abort",()=>a("canceled"));s.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${n(s)}下载失败: ${o}`);this.progressMap.set(s,0);this.updateProgress();s.open("GET",t.url);s.setRequestHeader("Range",o);s.send()});s.setRequestHeader("Range",o);this.progressMap.set(s,0);s.send();this.workingXhr.push(s)}));i=Math.round(i+s)+1}return Promise.all(e)}async copyUrl(){const t=this.fragments.map(t=>t.url).reduce((t,e)=>t+"\r\n"+e);GM.setClipboard(t,"text")}async showUrl(){const t=this.fragments.map(t=>`\n${t.url}\n`).reduce((t,e)=>t+"\r\n"+e);Toast.success(t+`复制全部`,"显示链接");const e=await SpinQuery.select("#copy-link");e.addEventListener("click",async()=>{await this.copyUrl()})}async exportIdm(){const{toIdmFormat:t}=await e.importAsync("idm-support");const s=t([this]);const i=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,i);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);r.add(`${a()}.ef2`,s);await r.emit(`${a()}.zip`)}async exportData(t=false){const e=JSON.stringify([{fragments:this.fragments,title:a(),totalSize:this.fragments.map(t=>t.size).reduce((t,e)=>t+e),referer:document.URL.replace(window.location.search,"")}]);if(t){GM.setClipboard(e,"text")}else{const t=new Blob([e],{type:"text/json"});const s=await this.downloadDanmaku();const i=new n;i.add(`${a()}.json`,t);i.add(a()+"."+this.danmakuOption.toLowerCase(),s);await i.emit(`${a()}.zip`)}}async exportAria2(s=false){const{getNumber:i}=await e.importAsync("get-number");if(s){const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,s);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);await r.emit();const l=t.aria2RpcOption;const c=this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}const n=[];if(l.secretKey!==""){n.push(`token:${l.secretKey}`)}n.push([t.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":UserAgent,out:`${a()}${s}${this.extension(t)}`,split:this.fragmentSplitFactor,dir:l.baseDir+l.dir||undefined,"max-download-limit":l.maxDownloadLimit||undefined});const o=encodeURIComponent(`${a()}${s}`);return{params:n,id:o}});const{sendRpc:d}=await e.importAsync("aria2-rpc");await d(c)}else{const t=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}return`\n${t.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=${UserAgent}\n out=${a()}${s}${this.extension(t)}\n split=${this.fragmentSplitFactor}\n`.trim()}).join("\n")}\n`.trim();const e=new Blob([t],{type:"text/plain"});const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.txt`,e);r.add(a()+"."+this.danmakuOption.toLowerCase(),s);r.add(a()+"."+this.subtitleOption.toLowerCase(),o);await r.emit(`${a()}.zip`)}}extension(t){const e=t||this.fragments[0];const a=[".flv",".mp4"].find(t=>e.url.includes(t));if(a){return a}else if(e.url.includes(".m4s")){return this.fragments.indexOf(e)===0?".mp4":".m4a"}else{console.warn("No extension detected.");return".flv"}}async downloadDanmaku(){if(this.danmakuOption!=="无"){const t=new i(c.cid);await t.fetchInfo();if(this.danmakuOption==="XML"){return t.rawXML}else{const{convertToAss:a}=await e.importAsync("download-danmaku");return a(t.rawXML)}}else{return null}}async downloadSubtitle(){if(this.subtitle&&this.subtitleOption!=="无"){const{getSubtitleConfig:t,getSubtitleList:a}=await e.importAsync("download-subtitle");const[s,i]=await t();const n=await a(c.aid,c.cid);const o=n.find(t=>t.language===i)||n[0];const r=await Ajax.getJson(o.url);const l=r.body;if(this.subtitleOption==="JSON"){return l}else{const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const a=new t(s);const i=await a.convertToAss(l);return i}}return null}async download(){this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const t=[];this.videoSpeed.startMeasure();for(const e of this.fragments){const a=await this.downloadFragment(e);t.push(a)}if(t.length<1){throw new Error("下载失败.")}const s=a();const i=new n;const{getNumber:o}=await e.importAsync("get-number");t.forEach((e,a)=>{let n;const r=this.fragments[a];if(t.length>1&&!this.isDash){n=`${s} - ${o(a+1,t.length)}${this.extension(r)}`}else{n=`${s}${this.extension(r)}`}i.add(n,new Blob(Array.isArray(e)?e:[e]))});const r=await this.downloadDanmaku();i.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,r);const l=await this.downloadSubtitle();i.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,l);await i.emit(s+".zip");this.progress&&this.progress(0);this.videoSpeed.stopMeasure()}}class f{constructor(t){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=t}startMeasure(){this.intervalTimer=setInterval(()=>{const t=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((t,e)=>t+e,0):0;const e=t-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(e)+"/s")}this.lastProgress=t},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const t=await SpinQuery.select(()=>(unsafeWindow||window).aid);const e=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(t&&e)){return false}c.aid=t;c.cid=e;if(document.URL.includes("bangumi")){c.entity=new r}else if(document.URL.includes("cheese")){const t=document.URL.match(/cheese\/play\/ep([\d]+)/);c.entity=new l(t[1])}else{c.entity=new o}try{d=await p.getAvailableFormats()}catch(t){return false}return true}const g=e=>{const a=t.downloadVideoQuality;const s=e.find(t=>t.quality===a);if(s){return s}const i=e.filter(t=>t.quality{const t=dq(".download-video");t.classList.toggle("opened");window.scroll(0,0);dq(".gui-settings-mask").click()});t.addEventListener("mouseover",()=>{b()},{once:true})}async function b(){let r;const l=[{name:"single",displayName:"单个视频"},{name:"batch",displayName:"批量导出"},{name:"manual",displayName:"手动输入"}];const f=new Vue({template:e.import("downloadVideoHtml"),components:{VDropdown:()=>e.importAsync("v-dropdown.vue"),VCheckbox:()=>e.importAsync("v-checkbox.vue"),RpcProfiles:()=>e.importAsync("aria2-rpc-profiles.vue")},data:{batch:false,subtitle:false,selectedTab:l[0],coverUrl:EmptyImageUrl,aid:c.aid,cid:c.cid,dashModel:{value:t.downloadVideoFormat,items:["flv","dash"]},qualityModel:{value:u.displayName,items:d.map(t=>t.displayName)},manualQualityModel:{value:h[1].displayName,items:h.map(t=>t.displayName)},danmakuModel:{value:t.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},subtitleModel:{value:t.downloadVideoDefaultSubtitle,items:["无","JSON","ASS"]},codecModel:{value:t.downloadVideoDashCodec,items:["AVC/H.264","HEVC/H.265"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",rpcSettings:t.aria2RpcOption,showRpcSettings:false,busy:false,saveRpcSettingsText:"保存配置",enableDash:t.enableDashDownload,lastDirectDownloadLink:"",manualInputText:""},computed:{tabs(){if(this.batch){return l}const t=[...l];_.remove(t,t=>t.name==="batch");return t},manualInputItems(){const t=this.manualInputText.split(/\s/g);const e=t.map(t=>t.match(/av(\d+)/i)||t.match(/^(\d+)$/));return _.uniq(e.filter(t=>t!==null).map(t=>t[1]))},downloadSingle(){return this.selectedTab.name==="single"},displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(t=>t.checked).length},dash(){return this.dashModel.value==="dash"}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){t.downloadVideoDefaultDanmaku=this.danmakuModel.value},subtitleOptionChange(){t.downloadVideoDefaultSubtitle=this.subtitleModel.value},async codecChange(){t.downloadVideoDashCodec=this.codecModel.value;await this.formatChange()},async dashChange(){const e=t.downloadVideoFormat=this.dashModel.value;let a=[];if(e==="flv"){a=await p.getAvailableFormats()}else{a=await p.getAvailableDashFormats()}d=a;u=g(d);this.qualityModel.items=a.map(t=>t.displayName);this.qualityModel.value=this.qualityModel.items[d.indexOf(u)];await this.formatChange()},async formatChange(e=false){const a=this.getFormat();if(e){t.downloadVideoQuality=a.quality}try{this.size="获取大小中";const t=await a.downloadInfo(this.dash);this.size=t.totalSize}catch(t){this.size="获取大小失败";throw t}},getManualFormat(){let t;t=h.find(t=>t.displayName===this.manualQualityModel.value);if(!t){console.error(`No format found. model value = ${this.manualQualityModel.value}`);return null}return t},getFormat(){let t;t=d.find(t=>t.displayName===this.qualityModel.value);if(!t){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return t},async exportData(t){if(this.busy===true){return}try{this.busy=true;if(this.selectedTab.name==="batch"){await this.exportBatchData(t);return}if(this.selectedTab.name==="manual"){await this.exportManualData(t);return}const s=this.getFormat();const i=await s.downloadInfo(this.dash);i.subtitle=this.subtitle;switch(t){case"copyLink":await i.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"showLink":await i.showUrl();break;case"aria2":await i.exportAria2(false);break;case"aria2RPC":await i.exportAria2(true);break;case"copyVLD":await i.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await i.exportData(false);break;case"ffmpegFragments":if(i.fragments.length<2){Toast.info("当前视频没有分段.","分段合并",3e3)}else{const{getFragmentsList:t}=await e.importAsync("ffmpeg-support");const s=new n;s.add("ffmpeg-files.txt",t(i.fragments.length,a(),i.fragments.map(t=>i.extension(t))));await s.emit()}break;case"idm":await i.exportIdm();break;default:break}}catch(t){logError(t)}finally{this.busy=false}},async exportBatchData(t){const s=this.episodeList;if(s.every(t=>t.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const o=t=>{const e=s.find(e=>e.cid===t.cid);if(e===undefined){return false}return e.checked};const r=this.batchExtractor;const l=this.getFormat();if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","批量导出");const a=new n;try{if(this.danmakuModel.value==="XML"){for(const t of s.filter(o)){const e=new i(t.cid);await e.fetchInfo();a.add(r.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of s.filter(o)){const s=new i(e.cid);await s.fetchInfo();a.add(r.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await a.emit(this.cid+".danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const a=new n;try{const{getSubtitleConfig:i,getSubtitleList:n}=await e.importAsync("download-subtitle");const[l,c]=await i();for(const t of s.filter(o)){const s=await n(t.aid,t.cid);const i=s.find(t=>t.language===c)||s[0];if(i===undefined){continue}const o=await Ajax.getJson(i.url);const d=o.body;if(this.subtitleModel.value==="JSON"){a.add(r.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const i=new s(l);const n=await i.convertToAss(d);a.add(r.formatTitle(t.titleParameters)+".ass",n)}}await a.emit(this.cid+".subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const d=Toast.info("获取链接中...","批量导出");r.config.itemFilter=o;r.config.api=await c.entity.getApiGenerator(this.dash);let u;try{switch(t){case"idm":const s=await r.getRawItems(l);const{toIdmFormat:i}=await e.importAsync("idm-support");u=i(s);await n.single(a(false)+".ef2",new Blob([u],{type:"text/plain"}));return;case"aria2":u=await r.collectAria2(l,d,false);await n.single(a(false)+".txt",new Blob([u],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});return;case"aria2RPC":await r.collectAria2(l,d,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM.setClipboard(await r.collectData(l,d),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":u=await r.collectData(l,d);await n.single(a(false)+".json",new Blob([u],{type:"text/json"}),{ffmpeg:this.ffmpegOption});return;case"ffmpegFragments":{const t=await r.getRawItems(l);if(t.every(t=>t.fragments.length<2)){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const s=new m(l,t[0].fragments);const{getBatchFragmentsList:i}=await e.importAsync("ffmpeg-support");const o=i(t,this.dash||s.extension());if(!o){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const c=new n;for(const[t,e]of o.entries()){c.add(t,e)}await c.emit(escapeFilename(`${a(false)}.zip`))}break;case"ffmpegEpisodes":{const t=await r.getRawItems(l);const a=new m(l,t[0].fragments);const{getBatchEpisodesList:s}=await e.importAsync("ffmpeg-support");const i=s(t,this.dash||a.extension());const o=new n;o.add("ffmpeg-files.txt",i);await o.emit()}break;default:return}}catch(t){logError(t)}finally{d.dismiss()}},async exportManualData(t){if(this.manualInputItems.length===0){Toast.info("请至少输入一个有效的视频链接!","手动输入",3e3);return}const{ManualInputBatch:a}=await e.importAsync("batch-download");const s=new a({api:await(new o).getApiGenerator(this.dash),itemFilter:()=>true});s.items=this.manualInputItems;if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","手动输入");const o=new n;try{if(this.danmakuModel.value==="XML"){for(const t of await s.getItemList()){const e=new i(t.cid);await e.fetchInfo();o.add(a.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of await s.getItemList()){const s=new i(e.cid);await s.fetchInfo();o.add(a.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await o.emit("manual-exports.danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const i=new n;try{const{getSubtitleConfig:n,getSubtitleList:o}=await e.importAsync("download-subtitle");const[r,l]=await n();for(const t of await s.getItemList()){const s=await o(t.aid,t.cid);const n=s.find(t=>t.language===l)||s[0];const c=await Ajax.getJson(n.url);const d=c.body;if(this.subtitleModel.value==="JSON"){i.add(a.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const n=new s(r);const o=await n.convertToAss(d);i.add(a.formatTitle(t.titleParameters)+".ass",o)}}await i.emit("manual-exports.subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const r=Toast.info("获取链接中...","手动输入");try{switch(t){default:case"aria2":{const t=await s.collectAria2(this.getManualFormat().quality,false);await n.single("manual-exports.txt",new Blob([t],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});break}case"aria2RPC":{await s.collectAria2(this.getManualFormat().quality,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);break}case"idm":{const t=await s.getRawItems(this.getManualFormat().quality);const{toIdmFormat:a}=await e.importAsync("idm-support");const i=a(t);await n.single("manual-exports.ef2",new Blob([i],{type:"text/plain"}));break}}}catch(t){logError(t)}finally{r.dismiss()}},async checkBatch(){const t=["//www.bilibili.com/bangumi","//www.bilibili.com/video","//www.bilibili.com/blackboard/bnj2020.html"];if(!t.some(t=>document.URL.includes(t))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:a}=await e.importAsync("batch-download");if(await a.test()!==true){this.batch=false;this.episodeList=[];return}const s=this.batchExtractor=new a;this.batch=true;this.episodeList=(await s.getItemList()).map((t,e)=>{return{aid:t.aid,cid:t.cid,title:t.title,titleParameters:t.titleParameters,index:e,checked:true}})},async checkSubtitle(){const{getSubtitleList:t}=await e.importAsync("download-subtitle");const a=await t(c.aid,c.cid);this.subtitle=a.length>0},cancelDownload(){if(r){r.cancelDownload()}},async startDownload(){const t=this.getFormat();try{this.downloading=true;const e=await t.downloadInfo(this.dash);e.subtitle=this.subtitle;e.videoSpeed.speedUpdate=(t=>this.speed=t);e.progress=(t=>{this.progressPercent=Math.trunc(t*100)});r=e;await e.download();this.lastDirectDownloadLink=n.lastPackageUrl}catch(t){if(t!=="canceled"){logError(t)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(t=>t.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(t=>t.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(t=>t.checked=!t.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}t.aria2RpcOption=this.rpcSettings;const e=t.aria2RpcOptionProfiles.find(e=>e.name===t.aria2RpcOptionSelectedProfile);if(e){Object.assign(e,this.rpcSettings);t.aria2RpcOptionProfiles=t.aria2RpcOptionProfiles}this.saveRpcSettingsText="已保存";setTimeout(()=>this.saveRpcSettingsText="保存配置",2e3)},updateProfile(e){t.aria2RpcOption=this.rpcSettings=_.omit(e,"name")}},async mounted(){}});const y=f.$mount().$el;document.body.insertAdjacentElement("beforeend",y);Observer.videoChange(async()=>{f.close();f.batch=false;f.selectedTab=l[0];const t=dq("#download-video");const e=await w();t.style.display=e?"flex":"none";if(!e){return}f.aid=c.aid;f.cid=c.cid;try{const t=new s(c.aid);await t.fetchInfo();f.coverUrl=t.coverUrl.replace("http:","https:")}catch(t){f.coverUrl=EmptyImageUrl}f.dashChange();f.checkSubtitle();await f.checkBatch()})}return{widget:{content:`\n`,condition:w,success:y}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video-package.min.js"] = (()=>{return(e,t)=>{class n{constructor(e={}){this.config=e;this.entries=[]}download(e,t){const a=document.createElement("a");const i=URL.createObjectURL(t);if(n.lastPackageUrl){URL.revokeObjectURL(n.lastPackageUrl)}n.lastPackageUrl=i;a.setAttribute("href",i);a.setAttribute("download",escapeFilename(e));document.body.appendChild(a);a.click();a.remove()}add(e,t){if(t===null||t===undefined){return}console.log(`add file: ${escapeFilename(e)}`);this.entries.push({name:escapeFilename(e),data:t})}async blob(){if(this.entries.length===0){return null}if(this.entries.length===1){const e=this.entries[0].data;return typeof e==="string"?new Blob([e]):e}const e=new JSZip;this.entries.forEach(({name:t,data:n})=>{e.file(t,n)});return await e.generateAsync({type:"blob"})}async emit(e){if(this.entries.length===0){return}if(!e||this.entries.length===1){e=this.entries[0].name}const t=await this.blob();if(!t){return}return this.download(e,t)}static async single(e,t,a={}){const i=new n(a);i.add(e,t);return await i.emit()}}n.lastPackageUrl="";return{export:{DownloadVideoPackage:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dpi-img.vue.min.js"] = (()=>{return(t,e)=>{const s=``;return{export:Object.assign({template:s},{props:{size:[Object,Number],src:String,blur:Number,root:HTMLElement,rootMargin:String,threshold:Number,placeholderImage:Boolean},data(){return{srcset:null,actualSrc:null,isPlaceholderActive:false}},watch:{size(){this.sourceChange()},src(){this.sourceChange()}},methods:{sourceChange(){if(this.actualSrc===null||this.srcset===null){return}this.calcSrc()},calcSrc(){const t=!this.src||!this.size;this.isPlaceholderActive=t&&this.placeholderImage;if(t){this.srcset=null;if(this.placeholderImage){this.actualSrc=`https://s1.hdslb.com/bfs/static/blive/live-web-center/static/img/no-cover.1ebe4d5.jpg`}else{this.actualSrc=null}return}let e=this.src;if(e.startsWith("http:")){e=e.replace("http:","https:")}if(e.includes("//static.hdslb.com/images/member/noface.gif")){this.srcset=e;this.actualSrc=e;return}const s=e.substring(e.lastIndexOf(".")+1);this.srcset=getDpiSourceSet(e,this.size,s);this.actualSrc=e}},mounted(){const t={root:this.root,rootMargin:this.rootMargin||"200px",threshold:this.threshold};const e=new IntersectionObserver(t=>{t.forEach(t=>{if(t.isIntersecting){this.calcSrc();e.disconnect()}})},t);e.observe(this.$el)},computed:{width(){if(typeof this.size==="object"&&"width"in this.size){return this.size.width}return null},height(){if(typeof this.size==="object"&&"height"in this.size){return this.size.height}return null},filter(){const t=[];if(this.blur){t.push(`blur(${this.blur}px)`)}return t.join(" ")}}})}}})(); diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index f96bc6504..4575a5a76 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -222,7 +222,7 @@ const dqa = (selector, scopedSelector) => { } return [...selector.querySelectorAll(scopedSelector)] } -const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0` +const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0` const EmptyImageUrl = 'data:image/svg+xml;utf-8,' const ascendingSort = (itemProp) => { return (a, b) => itemProp(a) - itemProp(b) @@ -1354,8 +1354,8 @@ onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/m onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:a}=e.import("video-info");const{DanmakuConverter:i}=e.import("danmaku-converter");async function o(t){const e=n();let a={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));return e*4/188};const e=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};a.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;a.alpha=(100-parseFloat(dq(".bilibili-player-setting-opacity .bui-thumb-tooltip").innerText))/100;a.duration=(()=>{const e=18-3*t(".bilibili-player-setting-speedplus .bui-thumb");return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();a.blockTypes=(()=>{let t=[];const e={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"]};for(const[n,a]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(a)}}return t.concat(7,8)})();const n=1.4-.2*t(".bilibili-player-setting-fontsize .bui-thumb");a.resolution={x:1920*n,y:1080*n};a.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(a.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){a.bottomMarginPercent=.15}a.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked;const i=localStorage.getItem("bilibili_player_settings");if(i){const t=JSON.parse(i);const e=_.get(t,"block.list",[]);a.blockFilter=(t=>{for(const n of e){if(!n.s){continue}switch(n.t){case"keyword":{if(t.content.includes(n.v)){return false}break}case"regexp":{if(new RegExp(n.v).test(t.content)){return false}break}case"user":{if(t.userHash===n.v){return false}break}}}return true})}}catch(t){a={...a,font:"微软雅黑",alpha:.4,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new i(a);const s=o.convertToAssDocument(t);return s.generateAss()}async function s(t){const e=n();const i=new a((unsafeWindow||window).cid);await i.fetchInfo();const s=await(async()=>{if(t===true){return new Blob([await o(i.rawXML)],{type:"text/plain"})}else{return new Blob([i.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(s);const l=dq("#danmaku-link");const c=l.getAttribute("href");if(c){URL.revokeObjectURL(c)}l.setAttribute("download",`${e}.${t?"ass":"xml"}`);l.setAttribute("href",r);l.click()}return{export:{downloadDanmaku:s,convertToAss:o},widget:{content:`\n\n\n\n下载弹幕(XML)\n\n\n\n下载弹幕(ASS)\n\n`,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=dq("#download-danmaku-xml");const e=dq("#download-danmaku-ass");const n=[t,e];const a=(t,e)=>{t.addEventListener("click",async()=>{try{n.forEach(t=>t.disabled=true);await s(e)}catch(t){logError(t)}finally{n.forEach(t=>t.disabled=false)}})};a(t,false);a(e,true)}}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-live-records.min.js"] = (()=>{return(t,o)=>{const e=()=>document.URL.replace(location.search,"").match(/https:\/\/live\.bilibili\.com\/record\/(.+)/);return{widget:{content:`\n`,condition:async()=>{const t=e();return Boolean(t)},success:()=>{const t=dq("#download-live-records");t.addEventListener("click",async()=>{try{t.disabled=true;const o=e()[1];const n=await Ajax.getJson(`https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl?rid=${o}&platform=html5`);if(n.code!==0){logError(new Error(`获取录像链接失败: ${n.message}`));return}const i=n.data.list.map(t=>t.url);Toast.success(i.map(t=>`${t}`).join("\n"),"下载录像")}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-subtitle.min.js"] = (()=>{return(t,e)=>{let n;const i=(t,e)=>{const i=document.createElement("a");const o=URL.createObjectURL(new Blob([t]));if(n){URL.revokeObjectURL(n)}n=o;i.setAttribute("href",o);i.setAttribute("download",escapeFilename(e));document.body.appendChild(i);i.click();i.remove()};const o=async()=>{const{getFriendlyTitle:t}=await e.importAsync("title");const{SubtitleConverter:n,SubtitleSize:i,SubtitleLocation:o}=await e.importAsync("subtitle-converter");const s=await loadSubtitleSettingsPanel();if(!s){logError("未找到字幕设置");return[n.defaultConfig,""]}const l=s.querySelector(".bilibili-player-video-subtitle-setting-lan .bui-select-result").innerHTML;const a=t(true);const c=s.querySelector(".bilibili-player-video-subtitle-setting-fontsize .bui-thumb");const r=parseFloat(c.style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const u={214:i.VeryLarge,163.5:i.Large,107:i.Medium,50.5:i.Small,0:i.VerySmall};const b=u[r];const d=s.querySelector(".bilibili-player-video-subtitle-setting-color .bui-select-result span:first-child");const p=d.getAttribute("style").match(/background:[ ]*(.+);/)[1];const g=s.querySelector(".bilibili-player-video-subtitle-setting-opacity .bui-bar");const f=parseFloat(g.style.transform.replace(/scaleX\(([\d\.]+)/,"$1"));const y=dq(".subtitle-position");const w={bc:o.BottomCenter,bl:o.BottomLeft,br:o.BottomRight,tc:o.TopCenter,tl:o.TopLeft,tr:o.TopRight};const m=Object.entries(w).filter(([t])=>{return y.classList.contains(`subtitle-position-${t}`)}).map(([,t])=>t).shift();const S=dq("video");const h={title:a,height:S.videoHeight,width:S.videoWidth,color:p,location:m,opacity:f,size:b,boxPadding:1,boxMargin:32};return[h,l]};const s=async(t,n)=>{const{VideoInfo:i}=await e.importAsync("video-info");const o=new i(t);o.cid=typeof n==="string"?parseInt(n):n;await o.fetchInfo();return o.subtitles};return{widget:{content:`\n\n\n`,condition:videoCondition,success:()=>{const t=dq("#download-subtitle-json");const n=dq("#download-subtitle-ass");const l=[t,n];const a=(t,n)=>{t.addEventListener("click",async()=>{try{l.forEach(t=>t.disabled=true);const{aid:t,cid:a}=unsafeWindow;if(!t||!a){logError("未找到视频AID和CID");return}const c=await s(t,a);if(c.length===0){Toast.info("当前视频没有字幕.","下载字幕",3e3);return}const[r,u]=await o();const b=c.find(t=>t.language===u)||c[0];const d=await Ajax.getJson(b.url);const p=d.body;if(n){const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const n=new t(r);const o=await n.convertToAss(p);i(o,r.title+".ass")}else{i(JSON.stringify(p),r.title+".json")}}catch(t){logError(t)}finally{l.forEach(t=>t.disabled=false)}})};a(t,false);a(n,true)}},export:{getSubtitleConfig:o,getSubtitleList:s}}}})(); -onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; -onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; +onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:22px;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px;align-self:center}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; +onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:a}=e.import("title");const{VideoInfo:s,DanmakuInfo:i}=e.import("video-info");const{DownloadVideoPackage:n}=e.import("download-video-package");class o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnver=0&fnval=16`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json`}}}return e.bind(this)}async getDashUrl(t){return(await this.getApiGenerator(true))(c.aid,c.cid,t)}async getUrl(t){return(await this.getApiGenerator())(c.aid,c.cid,t)}}class r extends o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnval=16`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnval=16`}}else{if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=&otype=json`}}}return e.bind(this)}}class l extends o{constructor(t){super();this.ep=t}async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}`}}}return e.bind(this)}}const c={entity:new o,aid:"",cid:""};let d=[];let u=null;class p{constructor(t,e,a){this.quality=t;this.internalName=e;this.displayName=a}async downloadInfo(t=false){const e=new m(this);await e.fetchVideoInfo(t);return e}static parseFormats(t){const e=t.accept_quality;const a=t.accept_format.split(",");const s=t.accept_description;const i=e.map((t,e)=>{return new p(t,a[e],s[e])});return i}static async filterFormats(t){return t}static async getAvailableDashFormats(){const t=await c.entity.getDashUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}static async getAvailableFormats(){const t=await c.entity.getUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}}const h=[new p(120,"4K","超清 4K"),new p(116,"1080P60","高清 1080P60"),new p(112,"1080P+","高清 1080P+"),new p(80,"1080P","高清 1080P"),new p(74,"720P60","高清 720P60"),new p(64,"720P","高清 720P"),new p(32,"480P","清晰 480P"),new p(15,"320P","流畅 320P")];class m{constructor(t,e){this.subtitle=false;this.fragmentSplitFactor=6*2;this.workingXhr=null;this.progressMap=new Map;this.format=t;this.fragments=e||[];this.videoSpeed=new f(this)}get danmakuOption(){return t.downloadVideoDefaultDanmaku}get subtitleOption(){return t.downloadVideoDefaultSubtitle}get isDash(){return this.fragments.some(t=>t.url.includes(".m4s"))}get totalSize(){return this.fragments.map(t=>t.size).reduce((t,e)=>t+e)}async fetchVideoInfo(t=false){if(!t){const t=await c.entity.getUrl(this.format.quality);const a=await Ajax.getTextWithCredentials(t);const s=JSON.parse(a.replace(/http:/g,"https:"));const i=s.data||s.result||s;const n=this.format.quality;if(i.quality!==n){const{throwQualityError:t}=await e.importAsync("quality-errors");t(n)}const o=i.durl;this.fragments=o.map(t=>{return{length:t.length,size:t.size,url:t.url,backupUrls:t.backup_url}})}else{const{dashToFragments:t,getDashInfo:a}=await e.importAsync("video-dash");const s=await a(await c.entity.getDashUrl(this.format.quality),this.format.quality);this.fragments=t(s)}return this.fragments}updateProgress(){const t=this.progressMap?[...this.progressMap.values()].reduce((t,e)=>t+e,0)/this.totalSize:0;if(t>1||t<0){console.error(`[下载视频] 进度异常: ${t}`,this.progressMap.values())}this.progress&&this.progress(t)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(t=>t.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(t){const e=[];const a=this.isDash?4*1024*1024:16*1024*1024;let s;if(t.size<=a*6){s=t.size/this.fragmentSplitFactor}else{s=a}let i=0;const n=t=>[...this.progressMap.keys()].indexOf(t)+1;while(i{const s=new XMLHttpRequest;s.open("GET",t.url);s.responseType="arraybuffer";s.withCredentials=false;s.addEventListener("progress",t=>{console.log(`[下载视频] 视频片段${n(s)}下载进度: ${t.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(s,t.loaded);this.updateProgress()});s.addEventListener("load",()=>{if((""+s.status)[0]==="2"){console.log(`[下载视频] 视频片段${n(s)}下载完成`);e(s.response)}else{a(`视频片段${n(s)}请求失败, response = ${s.status}`)}});s.addEventListener("abort",()=>a("canceled"));s.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${n(s)}下载失败: ${o}`);this.progressMap.set(s,0);this.updateProgress();s.open("GET",t.url);s.setRequestHeader("Range",o);s.send()});s.setRequestHeader("Range",o);this.progressMap.set(s,0);s.send();this.workingXhr.push(s)}));i=Math.round(i+s)+1}return Promise.all(e)}async copyUrl(){const t=this.fragments.map(t=>t.url).reduce((t,e)=>t+"\r\n"+e);GM.setClipboard(t,"text")}async showUrl(){const t=this.fragments.map(t=>`\n${t.url}\n`).reduce((t,e)=>t+"\r\n"+e);Toast.success(t+`复制全部`,"显示链接");const e=await SpinQuery.select("#copy-link");e.addEventListener("click",async()=>{await this.copyUrl()})}async exportIdm(){const{toIdmFormat:t}=await e.importAsync("idm-support");const s=t([this]);const i=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,i);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);r.add(`${a()}.ef2`,s);await r.emit(`${a()}.zip`)}async exportData(t=false){const e=JSON.stringify([{fragments:this.fragments,title:a(),totalSize:this.fragments.map(t=>t.size).reduce((t,e)=>t+e),referer:document.URL.replace(window.location.search,"")}]);if(t){GM.setClipboard(e,"text")}else{const t=new Blob([e],{type:"text/json"});const s=await this.downloadDanmaku();const i=new n;i.add(`${a()}.json`,t);i.add(a()+"."+this.danmakuOption.toLowerCase(),s);await i.emit(`${a()}.zip`)}}async exportAria2(s=false){const{getNumber:i}=await e.importAsync("get-number");if(s){const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,s);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);await r.emit();const l=t.aria2RpcOption;const c=this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}const n=[];if(l.secretKey!==""){n.push(`token:${l.secretKey}`)}n.push([t.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":UserAgent,out:`${a()}${s}${this.extension(t)}`,split:this.fragmentSplitFactor,dir:l.baseDir+l.dir||undefined,"max-download-limit":l.maxDownloadLimit||undefined});const o=encodeURIComponent(`${a()}${s}`);return{params:n,id:o}});const{sendRpc:d}=await e.importAsync("aria2-rpc");await d(c)}else{const t=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}return`\n${t.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=${UserAgent}\n out=${a()}${s}${this.extension(t)}\n split=${this.fragmentSplitFactor}\n`.trim()}).join("\n")}\n`.trim();const e=new Blob([t],{type:"text/plain"});const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.txt`,e);r.add(a()+"."+this.danmakuOption.toLowerCase(),s);r.add(a()+"."+this.subtitleOption.toLowerCase(),o);await r.emit(`${a()}.zip`)}}extension(t){const e=t||this.fragments[0];const a=[".flv",".mp4"].find(t=>e.url.includes(t));if(a){return a}else if(e.url.includes(".m4s")){return this.fragments.indexOf(e)===0?".mp4":".m4a"}else{console.warn("No extension detected.");return".flv"}}async downloadDanmaku(){if(this.danmakuOption!=="无"){const t=new i(c.cid);await t.fetchInfo();if(this.danmakuOption==="XML"){return t.rawXML}else{const{convertToAss:a}=await e.importAsync("download-danmaku");return a(t.rawXML)}}else{return null}}async downloadSubtitle(){if(this.subtitle&&this.subtitleOption!=="无"){const{getSubtitleConfig:t,getSubtitleList:a}=await e.importAsync("download-subtitle");const[s,i]=await t();const n=await a(c.aid,c.cid);const o=n.find(t=>t.language===i)||n[0];const r=await Ajax.getJson(o.url);const l=r.body;if(this.subtitleOption==="JSON"){return l}else{const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const a=new t(s);const i=await a.convertToAss(l);return i}}return null}async download(){this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const t=[];this.videoSpeed.startMeasure();for(const e of this.fragments){const a=await this.downloadFragment(e);t.push(a)}if(t.length<1){throw new Error("下载失败.")}const s=a();const i=new n;const{getNumber:o}=await e.importAsync("get-number");t.forEach((e,a)=>{let n;const r=this.fragments[a];if(t.length>1&&!this.isDash){n=`${s} - ${o(a+1,t.length)}${this.extension(r)}`}else{n=`${s}${this.extension(r)}`}i.add(n,new Blob(Array.isArray(e)?e:[e]))});const r=await this.downloadDanmaku();i.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,r);const l=await this.downloadSubtitle();i.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,l);await i.emit(s+".zip");this.progress&&this.progress(0);this.videoSpeed.stopMeasure()}}class f{constructor(t){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=t}startMeasure(){this.intervalTimer=setInterval(()=>{const t=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((t,e)=>t+e,0):0;const e=t-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(e)+"/s")}this.lastProgress=t},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const t=await SpinQuery.select(()=>(unsafeWindow||window).aid);const e=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(t&&e)){return false}c.aid=t;c.cid=e;if(document.URL.includes("bangumi")){c.entity=new r}else if(document.URL.includes("cheese")){const t=document.URL.match(/cheese\/play\/ep([\d]+)/);c.entity=new l(t[1])}else{c.entity=new o}try{d=await p.getAvailableFormats()}catch(t){return false}return true}const g=e=>{const a=t.downloadVideoQuality;const s=e.find(t=>t.quality===a);if(s){return s}const i=e.filter(t=>t.quality{const t=dq(".download-video");t.classList.toggle("opened");window.scroll(0,0);dq(".gui-settings-mask").click()});t.addEventListener("mouseover",()=>{b()},{once:true})}async function b(){let r;const l=[{name:"single",displayName:"单个视频"},{name:"batch",displayName:"批量导出"},{name:"manual",displayName:"手动输入"}];const f=new Vue({template:e.import("downloadVideoHtml"),components:{VDropdown:()=>e.importAsync("v-dropdown.vue"),VCheckbox:()=>e.importAsync("v-checkbox.vue"),RpcProfiles:()=>e.importAsync("aria2-rpc-profiles.vue")},data:{batch:false,subtitle:false,selectedTab:l[0],coverUrl:EmptyImageUrl,aid:c.aid,cid:c.cid,dashModel:{value:t.downloadVideoFormat,items:["flv","dash"]},qualityModel:{value:u.displayName,items:d.map(t=>t.displayName)},manualQualityModel:{value:h[1].displayName,items:h.map(t=>t.displayName)},danmakuModel:{value:t.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},subtitleModel:{value:t.downloadVideoDefaultSubtitle,items:["无","JSON","ASS"]},codecModel:{value:t.downloadVideoDashCodec,items:["AVC/H.264","HEVC/H.265"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",rpcSettings:t.aria2RpcOption,showRpcSettings:false,busy:false,saveRpcSettingsText:"保存配置",enableDash:t.enableDashDownload,lastDirectDownloadLink:"",manualInputText:""},computed:{tabs(){if(this.batch){return l}const t=[...l];_.remove(t,t=>t.name==="batch");return t},manualInputItems(){const t=this.manualInputText.split(/\s/g);const e=t.map(t=>t.match(/av(\d+)/i)||t.match(/^(\d+)$/));return _.uniq(e.filter(t=>t!==null).map(t=>t[1]))},downloadSingle(){return this.selectedTab.name==="single"},displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(t=>t.checked).length},dash(){return this.dashModel.value==="dash"}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){t.downloadVideoDefaultDanmaku=this.danmakuModel.value},subtitleOptionChange(){t.downloadVideoDefaultSubtitle=this.subtitleModel.value},async codecChange(){t.downloadVideoDashCodec=this.codecModel.value;await this.formatChange()},async dashChange(){const e=t.downloadVideoFormat=this.dashModel.value;let a=[];if(e==="flv"){a=await p.getAvailableFormats()}else{a=await p.getAvailableDashFormats()}d=a;u=g(d);this.qualityModel.items=a.map(t=>t.displayName);this.qualityModel.value=this.qualityModel.items[d.indexOf(u)];await this.formatChange()},async formatChange(e=false){const a=this.getFormat();if(e){t.downloadVideoQuality=a.quality}try{this.size="获取大小中";const t=await a.downloadInfo(this.dash);this.size=t.totalSize}catch(t){this.size="获取大小失败";throw t}},getManualFormat(){let t;t=h.find(t=>t.displayName===this.manualQualityModel.value);if(!t){console.error(`No format found. model value = ${this.manualQualityModel.value}`);return null}return t},getFormat(){let t;t=d.find(t=>t.displayName===this.qualityModel.value);if(!t){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return t},async exportData(t){if(this.busy===true){return}try{this.busy=true;if(this.selectedTab.name==="batch"){await this.exportBatchData(t);return}if(this.selectedTab.name==="manual"){await this.exportManualData(t);return}const s=this.getFormat();const i=await s.downloadInfo(this.dash);i.subtitle=this.subtitle;switch(t){case"copyLink":await i.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"showLink":await i.showUrl();break;case"aria2":await i.exportAria2(false);break;case"aria2RPC":await i.exportAria2(true);break;case"copyVLD":await i.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await i.exportData(false);break;case"ffmpegFragments":if(i.fragments.length<2){Toast.info("当前视频没有分段.","分段合并",3e3)}else{const{getFragmentsList:t}=await e.importAsync("ffmpeg-support");const s=new n;s.add("ffmpeg-files.txt",t(i.fragments.length,a(),i.fragments.map(t=>i.extension(t))));await s.emit()}break;case"idm":await i.exportIdm();break;default:break}}catch(t){logError(t)}finally{this.busy=false}},async exportBatchData(t){const s=this.episodeList;if(s.every(t=>t.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const o=t=>{const e=s.find(e=>e.cid===t.cid);if(e===undefined){return false}return e.checked};const r=this.batchExtractor;const l=this.getFormat();if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","批量导出");const a=new n;try{if(this.danmakuModel.value==="XML"){for(const t of s.filter(o)){const e=new i(t.cid);await e.fetchInfo();a.add(r.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of s.filter(o)){const s=new i(e.cid);await s.fetchInfo();a.add(r.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await a.emit(this.cid+".danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const a=new n;try{const{getSubtitleConfig:i,getSubtitleList:n}=await e.importAsync("download-subtitle");const[l,c]=await i();for(const t of s.filter(o)){const s=await n(t.aid,t.cid);const i=s.find(t=>t.language===c)||s[0];if(i===undefined){continue}const o=await Ajax.getJson(i.url);const d=o.body;if(this.subtitleModel.value==="JSON"){a.add(r.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const i=new s(l);const n=await i.convertToAss(d);a.add(r.formatTitle(t.titleParameters)+".ass",n)}}await a.emit(this.cid+".subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const d=Toast.info("获取链接中...","批量导出");r.config.itemFilter=o;r.config.api=await c.entity.getApiGenerator(this.dash);let u;try{switch(t){case"idm":const s=await r.getRawItems(l);const{toIdmFormat:i}=await e.importAsync("idm-support");u=i(s);await n.single(a(false)+".ef2",new Blob([u],{type:"text/plain"}));return;case"aria2":u=await r.collectAria2(l,d,false);await n.single(a(false)+".txt",new Blob([u],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});return;case"aria2RPC":await r.collectAria2(l,d,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM.setClipboard(await r.collectData(l,d),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":u=await r.collectData(l,d);await n.single(a(false)+".json",new Blob([u],{type:"text/json"}),{ffmpeg:this.ffmpegOption});return;case"ffmpegFragments":{const t=await r.getRawItems(l);if(t.every(t=>t.fragments.length<2)){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const s=new m(l,t[0].fragments);const{getBatchFragmentsList:i}=await e.importAsync("ffmpeg-support");const o=i(t,this.dash||s.extension());if(!o){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const c=new n;for(const[t,e]of o.entries()){c.add(t,e)}await c.emit(escapeFilename(`${a(false)}.zip`))}break;case"ffmpegEpisodes":{const t=await r.getRawItems(l);const a=new m(l,t[0].fragments);const{getBatchEpisodesList:s}=await e.importAsync("ffmpeg-support");const i=s(t,this.dash||a.extension());const o=new n;o.add("ffmpeg-files.txt",i);await o.emit()}break;default:return}}catch(t){logError(t)}finally{d.dismiss()}},async exportManualData(t){if(this.manualInputItems.length===0){Toast.info("请至少输入一个有效的视频链接!","手动输入",3e3);return}const{ManualInputBatch:a}=await e.importAsync("batch-download");const s=new a({api:await(new o).getApiGenerator(this.dash),itemFilter:()=>true});s.items=this.manualInputItems;if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","手动输入");const o=new n;try{if(this.danmakuModel.value==="XML"){for(const t of await s.getItemList()){const e=new i(t.cid);await e.fetchInfo();o.add(a.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of await s.getItemList()){const s=new i(e.cid);await s.fetchInfo();o.add(a.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await o.emit("manual-exports.danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const i=new n;try{const{getSubtitleConfig:n,getSubtitleList:o}=await e.importAsync("download-subtitle");const[r,l]=await n();for(const t of await s.getItemList()){const s=await o(t.aid,t.cid);const n=s.find(t=>t.language===l)||s[0];const c=await Ajax.getJson(n.url);const d=c.body;if(this.subtitleModel.value==="JSON"){i.add(a.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const n=new s(r);const o=await n.convertToAss(d);i.add(a.formatTitle(t.titleParameters)+".ass",o)}}await i.emit("manual-exports.subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const r=Toast.info("获取链接中...","手动输入");try{switch(t){default:case"aria2":{const t=await s.collectAria2(this.getManualFormat().quality,false);await n.single("manual-exports.txt",new Blob([t],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});break}case"aria2RPC":{await s.collectAria2(this.getManualFormat().quality,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);break}case"idm":{const t=await s.getRawItems(this.getManualFormat().quality);const{toIdmFormat:a}=await e.importAsync("idm-support");const i=a(t);await n.single("manual-exports.ef2",new Blob([i],{type:"text/plain"}));break}}}catch(t){logError(t)}finally{r.dismiss()}},async checkBatch(){const t=["//www.bilibili.com/bangumi","//www.bilibili.com/video","//www.bilibili.com/blackboard/bnj2020.html"];if(!t.some(t=>document.URL.includes(t))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:a}=await e.importAsync("batch-download");if(await a.test()!==true){this.batch=false;this.episodeList=[];return}const s=this.batchExtractor=new a;this.batch=true;this.episodeList=(await s.getItemList()).map((t,e)=>{return{aid:t.aid,cid:t.cid,title:t.title,titleParameters:t.titleParameters,index:e,checked:true}})},async checkSubtitle(){const{getSubtitleList:t}=await e.importAsync("download-subtitle");const a=await t(c.aid,c.cid);this.subtitle=a.length>0},cancelDownload(){if(r){r.cancelDownload()}},async startDownload(){const t=this.getFormat();try{this.downloading=true;const e=await t.downloadInfo(this.dash);e.subtitle=this.subtitle;e.videoSpeed.speedUpdate=(t=>this.speed=t);e.progress=(t=>{this.progressPercent=Math.trunc(t*100)});r=e;await e.download();this.lastDirectDownloadLink=n.lastPackageUrl}catch(t){if(t!=="canceled"){logError(t)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(t=>t.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(t=>t.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(t=>t.checked=!t.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}t.aria2RpcOption=this.rpcSettings;const e=t.aria2RpcOptionProfiles.find(e=>e.name===t.aria2RpcOptionSelectedProfile);if(e){Object.assign(e,this.rpcSettings);t.aria2RpcOptionProfiles=t.aria2RpcOptionProfiles}this.saveRpcSettingsText="已保存";setTimeout(()=>this.saveRpcSettingsText="保存配置",2e3)},updateProfile(e){t.aria2RpcOption=this.rpcSettings=_.omit(e,"name")}},async mounted(){}});const y=f.$mount().$el;document.body.insertAdjacentElement("beforeend",y);Observer.videoChange(async()=>{f.close();f.batch=false;f.selectedTab=l[0];const t=dq("#download-video");const e=await w();t.style.display=e?"flex":"none";if(!e){return}f.aid=c.aid;f.cid=c.cid;try{const t=new s(c.aid);await t.fetchInfo();f.coverUrl=t.coverUrl.replace("http:","https:")}catch(t){f.coverUrl=EmptyImageUrl}f.dashChange();f.checkSubtitle();await f.checkBatch()})}return{widget:{content:`\n`,condition:w,success:y}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/download-video-package.min.js"] = (()=>{return(e,t)=>{class n{constructor(e={}){this.config=e;this.entries=[]}download(e,t){const a=document.createElement("a");const i=URL.createObjectURL(t);if(n.lastPackageUrl){URL.revokeObjectURL(n.lastPackageUrl)}n.lastPackageUrl=i;a.setAttribute("href",i);a.setAttribute("download",escapeFilename(e));document.body.appendChild(a);a.click();a.remove()}add(e,t){if(t===null||t===undefined){return}console.log(`add file: ${escapeFilename(e)}`);this.entries.push({name:escapeFilename(e),data:t})}async blob(){if(this.entries.length===0){return null}if(this.entries.length===1){const e=this.entries[0].data;return typeof e==="string"?new Blob([e]):e}const e=new JSZip;this.entries.forEach(({name:t,data:n})=>{e.file(t,n)});return await e.generateAsync({type:"blob"})}async emit(e){if(this.entries.length===0){return}if(!e||this.entries.length===1){e=this.entries[0].name}const t=await this.blob();if(!t){return}return this.download(e,t)}static async single(e,t,a={}){const i=new n(a);i.add(e,t);return await i.emit()}}n.lastPackageUrl="";return{export:{DownloadVideoPackage:n}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/min/dpi-img.vue.min.js"] = (()=>{return(t,e)=>{const s=``;return{export:Object.assign({template:s},{props:{size:[Object,Number],src:String,blur:Number,root:HTMLElement,rootMargin:String,threshold:Number,placeholderImage:Boolean},data(){return{srcset:null,actualSrc:null,isPlaceholderActive:false}},watch:{size(){this.sourceChange()},src(){this.sourceChange()}},methods:{sourceChange(){if(this.actualSrc===null||this.srcset===null){return}this.calcSrc()},calcSrc(){const t=!this.src||!this.size;this.isPlaceholderActive=t&&this.placeholderImage;if(t){this.srcset=null;if(this.placeholderImage){this.actualSrc=`https://s1.hdslb.com/bfs/static/blive/live-web-center/static/img/no-cover.1ebe4d5.jpg`}else{this.actualSrc=null}return}let e=this.src;if(e.startsWith("http:")){e=e.replace("http:","https:")}if(e.includes("//static.hdslb.com/images/member/noface.gif")){this.srcset=e;this.actualSrc=e;return}const s=e.substring(e.lastIndexOf(".")+1);this.srcset=getDpiSourceSet(e,this.size,s);this.actualSrc=e}},mounted(){const t={root:this.root,rootMargin:this.rootMargin||"200px",threshold:this.threshold};const e=new IntersectionObserver(t=>{t.forEach(t=>{if(t.isIntersecting){this.calcSrc();e.disconnect()}})},t);e.observe(this.$el)},computed:{width(){if(typeof this.size==="object"&&"width"in this.size){return this.size.width}return null},height(){if(typeof this.size==="object"&&"height"in this.size){return this.size.height}return null},filter(){const t=[];if(this.blur){t.push(`blur(${this.blur}px)`)}return t.join(" ")}}})}}})(); diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 957ea11dd..cdeb234e7 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -222,7 +222,7 @@ const dqa = (selector, scopedSelector) => { } return [...selector.querySelectorAll(scopedSelector)] } -const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0` +const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0` const EmptyImageUrl = 'data:image/svg+xml;utf-8,' const ascendingSort = (itemProp) => { return (a, b) => itemProp(a) - itemProp(b) @@ -1354,8 +1354,8 @@ onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/mi onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:a}=e.import("video-info");const{DanmakuConverter:i}=e.import("danmaku-converter");async function o(t){const e=n();let a={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));return e*4/188};const e=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};a.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;a.alpha=(100-parseFloat(dq(".bilibili-player-setting-opacity .bui-thumb-tooltip").innerText))/100;a.duration=(()=>{const e=18-3*t(".bilibili-player-setting-speedplus .bui-thumb");return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();a.blockTypes=(()=>{let t=[];const e={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"]};for(const[n,a]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(a)}}return t.concat(7,8)})();const n=1.4-.2*t(".bilibili-player-setting-fontsize .bui-thumb");a.resolution={x:1920*n,y:1080*n};a.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(a.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){a.bottomMarginPercent=.15}a.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked;const i=localStorage.getItem("bilibili_player_settings");if(i){const t=JSON.parse(i);const e=_.get(t,"block.list",[]);a.blockFilter=(t=>{for(const n of e){if(!n.s){continue}switch(n.t){case"keyword":{if(t.content.includes(n.v)){return false}break}case"regexp":{if(new RegExp(n.v).test(t.content)){return false}break}case"user":{if(t.userHash===n.v){return false}break}}}return true})}}catch(t){a={...a,font:"微软雅黑",alpha:.4,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new i(a);const s=o.convertToAssDocument(t);return s.generateAss()}async function s(t){const e=n();const i=new a((unsafeWindow||window).cid);await i.fetchInfo();const s=await(async()=>{if(t===true){return new Blob([await o(i.rawXML)],{type:"text/plain"})}else{return new Blob([i.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(s);const l=dq("#danmaku-link");const c=l.getAttribute("href");if(c){URL.revokeObjectURL(c)}l.setAttribute("download",`${e}.${t?"ass":"xml"}`);l.setAttribute("href",r);l.click()}return{export:{downloadDanmaku:s,convertToAss:o},widget:{content:`\n\n\n\n下载弹幕(XML)\n\n\n\n下载弹幕(ASS)\n\n`,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=dq("#download-danmaku-xml");const e=dq("#download-danmaku-ass");const n=[t,e];const a=(t,e)=>{t.addEventListener("click",async()=>{try{n.forEach(t=>t.disabled=true);await s(e)}catch(t){logError(t)}finally{n.forEach(t=>t.disabled=false)}})};a(t,false);a(e,true)}}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-live-records.min.js"] = (()=>{return(t,o)=>{const e=()=>document.URL.replace(location.search,"").match(/https:\/\/live\.bilibili\.com\/record\/(.+)/);return{widget:{content:`\n`,condition:async()=>{const t=e();return Boolean(t)},success:()=>{const t=dq("#download-live-records");t.addEventListener("click",async()=>{try{t.disabled=true;const o=e()[1];const n=await Ajax.getJson(`https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl?rid=${o}&platform=html5`);if(n.code!==0){logError(new Error(`获取录像链接失败: ${n.message}`));return}const i=n.data.list.map(t=>t.url);Toast.success(i.map(t=>`${t}`).join("\n"),"下载录像")}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-subtitle.min.js"] = (()=>{return(t,e)=>{let n;const i=(t,e)=>{const i=document.createElement("a");const o=URL.createObjectURL(new Blob([t]));if(n){URL.revokeObjectURL(n)}n=o;i.setAttribute("href",o);i.setAttribute("download",escapeFilename(e));document.body.appendChild(i);i.click();i.remove()};const o=async()=>{const{getFriendlyTitle:t}=await e.importAsync("title");const{SubtitleConverter:n,SubtitleSize:i,SubtitleLocation:o}=await e.importAsync("subtitle-converter");const s=await loadSubtitleSettingsPanel();if(!s){logError("未找到字幕设置");return[n.defaultConfig,""]}const l=s.querySelector(".bilibili-player-video-subtitle-setting-lan .bui-select-result").innerHTML;const a=t(true);const c=s.querySelector(".bilibili-player-video-subtitle-setting-fontsize .bui-thumb");const r=parseFloat(c.style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const u={214:i.VeryLarge,163.5:i.Large,107:i.Medium,50.5:i.Small,0:i.VerySmall};const b=u[r];const d=s.querySelector(".bilibili-player-video-subtitle-setting-color .bui-select-result span:first-child");const p=d.getAttribute("style").match(/background:[ ]*(.+);/)[1];const g=s.querySelector(".bilibili-player-video-subtitle-setting-opacity .bui-bar");const f=parseFloat(g.style.transform.replace(/scaleX\(([\d\.]+)/,"$1"));const y=dq(".subtitle-position");const w={bc:o.BottomCenter,bl:o.BottomLeft,br:o.BottomRight,tc:o.TopCenter,tl:o.TopLeft,tr:o.TopRight};const m=Object.entries(w).filter(([t])=>{return y.classList.contains(`subtitle-position-${t}`)}).map(([,t])=>t).shift();const S=dq("video");const h={title:a,height:S.videoHeight,width:S.videoWidth,color:p,location:m,opacity:f,size:b,boxPadding:1,boxMargin:32};return[h,l]};const s=async(t,n)=>{const{VideoInfo:i}=await e.importAsync("video-info");const o=new i(t);o.cid=typeof n==="string"?parseInt(n):n;await o.fetchInfo();return o.subtitles};return{widget:{content:`\n\n\n`,condition:videoCondition,success:()=>{const t=dq("#download-subtitle-json");const n=dq("#download-subtitle-ass");const l=[t,n];const a=(t,n)=>{t.addEventListener("click",async()=>{try{l.forEach(t=>t.disabled=true);const{aid:t,cid:a}=unsafeWindow;if(!t||!a){logError("未找到视频AID和CID");return}const c=await s(t,a);if(c.length===0){Toast.info("当前视频没有字幕.","下载字幕",3e3);return}const[r,u]=await o();const b=c.find(t=>t.language===u)||c[0];const d=await Ajax.getJson(b.url);const p=d.body;if(n){const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const n=new t(r);const o=await n.convertToAss(p);i(o,r.title+".ass")}else{i(JSON.stringify(p),r.title+".json")}}catch(t){logError(t)}finally{l.forEach(t=>t.disabled=false)}})};a(t,false);a(n,true)}},export:{getSubtitleConfig:o,getSubtitleList:s}}}})(); -onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; -onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; +onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:22px;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px;align-self:center}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; +onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

{{t.displayName}}
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
`; onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:a}=e.import("title");const{VideoInfo:s,DanmakuInfo:i}=e.import("video-info");const{DownloadVideoPackage:n}=e.import("download-video-package");class o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnver=0&fnval=16`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${e}&cid=${a}&otype=json`}}}return e.bind(this)}async getDashUrl(t){return(await this.getApiGenerator(true))(c.aid,c.cid,t)}async getUrl(t){return(await this.getApiGenerator())(c.aid,c.cid,t)}}class r extends o{async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&fourk=1&fnval=16`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&otype=json&fourk=1&fnval=16`}}else{if(s){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${e}&cid=${a}&qn=&otype=json`}}}return e.bind(this)}}class l extends o{constructor(t){super();this.ep=t}async getApiGenerator(t=false){function e(e,a,s){if(t){if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}&fnver=0&fnval=16`}}else{if(s){return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&qn=${s}&otype=json&ep_id=${this.ep}`}else{return`https://api.bilibili.com/pugv/player/web/playurl?avid=${e}&cid=${a}&otype=json&ep_id=${this.ep}`}}}return e.bind(this)}}const c={entity:new o,aid:"",cid:""};let d=[];let u=null;class p{constructor(t,e,a){this.quality=t;this.internalName=e;this.displayName=a}async downloadInfo(t=false){const e=new m(this);await e.fetchVideoInfo(t);return e}static parseFormats(t){const e=t.accept_quality;const a=t.accept_format.split(",");const s=t.accept_description;const i=e.map((t,e)=>{return new p(t,a[e],s[e])});return i}static async filterFormats(t){return t}static async getAvailableDashFormats(){const t=await c.entity.getDashUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}static async getAvailableFormats(){const t=await c.entity.getUrl();const e=await Ajax.getJsonWithCredentials(t);if(e.code!==0){throw new Error("获取清晰度信息失败.")}const a=e.data||e.result||e;return await p.filterFormats(p.parseFormats(a))}}const h=[new p(120,"4K","超清 4K"),new p(116,"1080P60","高清 1080P60"),new p(112,"1080P+","高清 1080P+"),new p(80,"1080P","高清 1080P"),new p(74,"720P60","高清 720P60"),new p(64,"720P","高清 720P"),new p(32,"480P","清晰 480P"),new p(15,"320P","流畅 320P")];class m{constructor(t,e){this.subtitle=false;this.fragmentSplitFactor=6*2;this.workingXhr=null;this.progressMap=new Map;this.format=t;this.fragments=e||[];this.videoSpeed=new f(this)}get danmakuOption(){return t.downloadVideoDefaultDanmaku}get subtitleOption(){return t.downloadVideoDefaultSubtitle}get isDash(){return this.fragments.some(t=>t.url.includes(".m4s"))}get totalSize(){return this.fragments.map(t=>t.size).reduce((t,e)=>t+e)}async fetchVideoInfo(t=false){if(!t){const t=await c.entity.getUrl(this.format.quality);const a=await Ajax.getTextWithCredentials(t);const s=JSON.parse(a.replace(/http:/g,"https:"));const i=s.data||s.result||s;const n=this.format.quality;if(i.quality!==n){const{throwQualityError:t}=await e.importAsync("quality-errors");t(n)}const o=i.durl;this.fragments=o.map(t=>{return{length:t.length,size:t.size,url:t.url,backupUrls:t.backup_url}})}else{const{dashToFragments:t,getDashInfo:a}=await e.importAsync("video-dash");const s=await a(await c.entity.getDashUrl(this.format.quality),this.format.quality);this.fragments=t(s)}return this.fragments}updateProgress(){const t=this.progressMap?[...this.progressMap.values()].reduce((t,e)=>t+e,0)/this.totalSize:0;if(t>1||t<0){console.error(`[下载视频] 进度异常: ${t}`,this.progressMap.values())}this.progress&&this.progress(t)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(t=>t.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(t){const e=[];const a=this.isDash?4*1024*1024:16*1024*1024;let s;if(t.size<=a*6){s=t.size/this.fragmentSplitFactor}else{s=a}let i=0;const n=t=>[...this.progressMap.keys()].indexOf(t)+1;while(i{const s=new XMLHttpRequest;s.open("GET",t.url);s.responseType="arraybuffer";s.withCredentials=false;s.addEventListener("progress",t=>{console.log(`[下载视频] 视频片段${n(s)}下载进度: ${t.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(s,t.loaded);this.updateProgress()});s.addEventListener("load",()=>{if((""+s.status)[0]==="2"){console.log(`[下载视频] 视频片段${n(s)}下载完成`);e(s.response)}else{a(`视频片段${n(s)}请求失败, response = ${s.status}`)}});s.addEventListener("abort",()=>a("canceled"));s.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${n(s)}下载失败: ${o}`);this.progressMap.set(s,0);this.updateProgress();s.open("GET",t.url);s.setRequestHeader("Range",o);s.send()});s.setRequestHeader("Range",o);this.progressMap.set(s,0);s.send();this.workingXhr.push(s)}));i=Math.round(i+s)+1}return Promise.all(e)}async copyUrl(){const t=this.fragments.map(t=>t.url).reduce((t,e)=>t+"\r\n"+e);GM.setClipboard(t,"text")}async showUrl(){const t=this.fragments.map(t=>`\n${t.url}\n`).reduce((t,e)=>t+"\r\n"+e);Toast.success(t+`复制全部`,"显示链接");const e=await SpinQuery.select("#copy-link");e.addEventListener("click",async()=>{await this.copyUrl()})}async exportIdm(){const{toIdmFormat:t}=await e.importAsync("idm-support");const s=t([this]);const i=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,i);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);r.add(`${a()}.ef2`,s);await r.emit(`${a()}.zip`)}async exportData(t=false){const e=JSON.stringify([{fragments:this.fragments,title:a(),totalSize:this.fragments.map(t=>t.size).reduce((t,e)=>t+e),referer:document.URL.replace(window.location.search,"")}]);if(t){GM.setClipboard(e,"text")}else{const t=new Blob([e],{type:"text/json"});const s=await this.downloadDanmaku();const i=new n;i.add(`${a()}.json`,t);i.add(a()+"."+this.danmakuOption.toLowerCase(),s);await i.emit(`${a()}.zip`)}}async exportAria2(s=false){const{getNumber:i}=await e.importAsync("get-number");if(s){const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,s);r.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,o);await r.emit();const l=t.aria2RpcOption;const c=this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}const n=[];if(l.secretKey!==""){n.push(`token:${l.secretKey}`)}n.push([t.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":UserAgent,out:`${a()}${s}${this.extension(t)}`,split:this.fragmentSplitFactor,dir:l.baseDir+l.dir||undefined,"max-download-limit":l.maxDownloadLimit||undefined});const o=encodeURIComponent(`${a()}${s}`);return{params:n,id:o}});const{sendRpc:d}=await e.importAsync("aria2-rpc");await d(c)}else{const t=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((t,e)=>{let s="";if(this.fragments.length>1&&!this.isDash){s=" - "+i(e+1,this.fragments.length)}return`\n${t.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=${UserAgent}\n out=${a()}${s}${this.extension(t)}\n split=${this.fragmentSplitFactor}\n`.trim()}).join("\n")}\n`.trim();const e=new Blob([t],{type:"text/plain"});const s=await this.downloadDanmaku();const o=await this.downloadSubtitle();const r=new n;r.add(`${a()}.txt`,e);r.add(a()+"."+this.danmakuOption.toLowerCase(),s);r.add(a()+"."+this.subtitleOption.toLowerCase(),o);await r.emit(`${a()}.zip`)}}extension(t){const e=t||this.fragments[0];const a=[".flv",".mp4"].find(t=>e.url.includes(t));if(a){return a}else if(e.url.includes(".m4s")){return this.fragments.indexOf(e)===0?".mp4":".m4a"}else{console.warn("No extension detected.");return".flv"}}async downloadDanmaku(){if(this.danmakuOption!=="无"){const t=new i(c.cid);await t.fetchInfo();if(this.danmakuOption==="XML"){return t.rawXML}else{const{convertToAss:a}=await e.importAsync("download-danmaku");return a(t.rawXML)}}else{return null}}async downloadSubtitle(){if(this.subtitle&&this.subtitleOption!=="无"){const{getSubtitleConfig:t,getSubtitleList:a}=await e.importAsync("download-subtitle");const[s,i]=await t();const n=await a(c.aid,c.cid);const o=n.find(t=>t.language===i)||n[0];const r=await Ajax.getJson(o.url);const l=r.body;if(this.subtitleOption==="JSON"){return l}else{const{SubtitleConverter:t}=await e.importAsync("subtitle-converter");const a=new t(s);const i=await a.convertToAss(l);return i}}return null}async download(){this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const t=[];this.videoSpeed.startMeasure();for(const e of this.fragments){const a=await this.downloadFragment(e);t.push(a)}if(t.length<1){throw new Error("下载失败.")}const s=a();const i=new n;const{getNumber:o}=await e.importAsync("get-number");t.forEach((e,a)=>{let n;const r=this.fragments[a];if(t.length>1&&!this.isDash){n=`${s} - ${o(a+1,t.length)}${this.extension(r)}`}else{n=`${s}${this.extension(r)}`}i.add(n,new Blob(Array.isArray(e)?e:[e]))});const r=await this.downloadDanmaku();i.add(`${a()}.${this.danmakuOption==="ASS"?"ass":"xml"}`,r);const l=await this.downloadSubtitle();i.add(`${a()}.${this.subtitleOption==="ASS"?"ass":"json"}`,l);await i.emit(s+".zip");this.progress&&this.progress(0);this.videoSpeed.stopMeasure()}}class f{constructor(t){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=t}startMeasure(){this.intervalTimer=setInterval(()=>{const t=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((t,e)=>t+e,0):0;const e=t-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(e)+"/s")}this.lastProgress=t},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const t=await SpinQuery.select(()=>(unsafeWindow||window).aid);const e=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(t&&e)){return false}c.aid=t;c.cid=e;if(document.URL.includes("bangumi")){c.entity=new r}else if(document.URL.includes("cheese")){const t=document.URL.match(/cheese\/play\/ep([\d]+)/);c.entity=new l(t[1])}else{c.entity=new o}try{d=await p.getAvailableFormats()}catch(t){return false}return true}const g=e=>{const a=t.downloadVideoQuality;const s=e.find(t=>t.quality===a);if(s){return s}const i=e.filter(t=>t.quality{const t=dq(".download-video");t.classList.toggle("opened");window.scroll(0,0);dq(".gui-settings-mask").click()});t.addEventListener("mouseover",()=>{b()},{once:true})}async function b(){let r;const l=[{name:"single",displayName:"单个视频"},{name:"batch",displayName:"批量导出"},{name:"manual",displayName:"手动输入"}];const f=new Vue({template:e.import("downloadVideoHtml"),components:{VDropdown:()=>e.importAsync("v-dropdown.vue"),VCheckbox:()=>e.importAsync("v-checkbox.vue"),RpcProfiles:()=>e.importAsync("aria2-rpc-profiles.vue")},data:{batch:false,subtitle:false,selectedTab:l[0],coverUrl:EmptyImageUrl,aid:c.aid,cid:c.cid,dashModel:{value:t.downloadVideoFormat,items:["flv","dash"]},qualityModel:{value:u.displayName,items:d.map(t=>t.displayName)},manualQualityModel:{value:h[1].displayName,items:h.map(t=>t.displayName)},danmakuModel:{value:t.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},subtitleModel:{value:t.downloadVideoDefaultSubtitle,items:["无","JSON","ASS"]},codecModel:{value:t.downloadVideoDashCodec,items:["AVC/H.264","HEVC/H.265"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",rpcSettings:t.aria2RpcOption,showRpcSettings:false,busy:false,saveRpcSettingsText:"保存配置",enableDash:t.enableDashDownload,lastDirectDownloadLink:"",manualInputText:""},computed:{tabs(){if(this.batch){return l}const t=[...l];_.remove(t,t=>t.name==="batch");return t},manualInputItems(){const t=this.manualInputText.split(/\s/g);const e=t.map(t=>t.match(/av(\d+)/i)||t.match(/^(\d+)$/));return _.uniq(e.filter(t=>t!==null).map(t=>t[1]))},downloadSingle(){return this.selectedTab.name==="single"},displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(t=>t.checked).length},dash(){return this.dashModel.value==="dash"}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){t.downloadVideoDefaultDanmaku=this.danmakuModel.value},subtitleOptionChange(){t.downloadVideoDefaultSubtitle=this.subtitleModel.value},async codecChange(){t.downloadVideoDashCodec=this.codecModel.value;await this.formatChange()},async dashChange(){const e=t.downloadVideoFormat=this.dashModel.value;let a=[];if(e==="flv"){a=await p.getAvailableFormats()}else{a=await p.getAvailableDashFormats()}d=a;u=g(d);this.qualityModel.items=a.map(t=>t.displayName);this.qualityModel.value=this.qualityModel.items[d.indexOf(u)];await this.formatChange()},async formatChange(e=false){const a=this.getFormat();if(e){t.downloadVideoQuality=a.quality}try{this.size="获取大小中";const t=await a.downloadInfo(this.dash);this.size=t.totalSize}catch(t){this.size="获取大小失败";throw t}},getManualFormat(){let t;t=h.find(t=>t.displayName===this.manualQualityModel.value);if(!t){console.error(`No format found. model value = ${this.manualQualityModel.value}`);return null}return t},getFormat(){let t;t=d.find(t=>t.displayName===this.qualityModel.value);if(!t){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return t},async exportData(t){if(this.busy===true){return}try{this.busy=true;if(this.selectedTab.name==="batch"){await this.exportBatchData(t);return}if(this.selectedTab.name==="manual"){await this.exportManualData(t);return}const s=this.getFormat();const i=await s.downloadInfo(this.dash);i.subtitle=this.subtitle;switch(t){case"copyLink":await i.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"showLink":await i.showUrl();break;case"aria2":await i.exportAria2(false);break;case"aria2RPC":await i.exportAria2(true);break;case"copyVLD":await i.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await i.exportData(false);break;case"ffmpegFragments":if(i.fragments.length<2){Toast.info("当前视频没有分段.","分段合并",3e3)}else{const{getFragmentsList:t}=await e.importAsync("ffmpeg-support");const s=new n;s.add("ffmpeg-files.txt",t(i.fragments.length,a(),i.fragments.map(t=>i.extension(t))));await s.emit()}break;case"idm":await i.exportIdm();break;default:break}}catch(t){logError(t)}finally{this.busy=false}},async exportBatchData(t){const s=this.episodeList;if(s.every(t=>t.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const o=t=>{const e=s.find(e=>e.cid===t.cid);if(e===undefined){return false}return e.checked};const r=this.batchExtractor;const l=this.getFormat();if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","批量导出");const a=new n;try{if(this.danmakuModel.value==="XML"){for(const t of s.filter(o)){const e=new i(t.cid);await e.fetchInfo();a.add(r.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of s.filter(o)){const s=new i(e.cid);await s.fetchInfo();a.add(r.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await a.emit(this.cid+".danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const a=new n;try{const{getSubtitleConfig:i,getSubtitleList:n}=await e.importAsync("download-subtitle");const[l,c]=await i();for(const t of s.filter(o)){const s=await n(t.aid,t.cid);const i=s.find(t=>t.language===c)||s[0];if(i===undefined){continue}const o=await Ajax.getJson(i.url);const d=o.body;if(this.subtitleModel.value==="JSON"){a.add(r.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const i=new s(l);const n=await i.convertToAss(d);a.add(r.formatTitle(t.titleParameters)+".ass",n)}}await a.emit(this.cid+".subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const d=Toast.info("获取链接中...","批量导出");r.config.itemFilter=o;r.config.api=await c.entity.getApiGenerator(this.dash);let u;try{switch(t){case"idm":const s=await r.getRawItems(l);const{toIdmFormat:i}=await e.importAsync("idm-support");u=i(s);await n.single(a(false)+".ef2",new Blob([u],{type:"text/plain"}));return;case"aria2":u=await r.collectAria2(l,d,false);await n.single(a(false)+".txt",new Blob([u],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});return;case"aria2RPC":await r.collectAria2(l,d,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM.setClipboard(await r.collectData(l,d),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":u=await r.collectData(l,d);await n.single(a(false)+".json",new Blob([u],{type:"text/json"}),{ffmpeg:this.ffmpegOption});return;case"ffmpegFragments":{const t=await r.getRawItems(l);if(t.every(t=>t.fragments.length<2)){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const s=new m(l,t[0].fragments);const{getBatchFragmentsList:i}=await e.importAsync("ffmpeg-support");const o=i(t,this.dash||s.extension());if(!o){Toast.info("所有选择的分P都没有分段.","分段列表",3e3);return}const c=new n;for(const[t,e]of o.entries()){c.add(t,e)}await c.emit(escapeFilename(`${a(false)}.zip`))}break;case"ffmpegEpisodes":{const t=await r.getRawItems(l);const a=new m(l,t[0].fragments);const{getBatchEpisodesList:s}=await e.importAsync("ffmpeg-support");const i=s(t,this.dash||a.extension());const o=new n;o.add("ffmpeg-files.txt",i);await o.emit()}break;default:return}}catch(t){logError(t)}finally{d.dismiss()}},async exportManualData(t){if(this.manualInputItems.length===0){Toast.info("请至少输入一个有效的视频链接!","手动输入",3e3);return}const{ManualInputBatch:a}=await e.importAsync("batch-download");const s=new a({api:await(new o).getApiGenerator(this.dash),itemFilter:()=>true});s.items=this.manualInputItems;if(this.danmakuModel.value!=="无"){const t=Toast.info("下载弹幕中...","手动输入");const o=new n;try{if(this.danmakuModel.value==="XML"){for(const t of await s.getItemList()){const e=new i(t.cid);await e.fetchInfo();o.add(a.formatTitle(t.titleParameters)+".xml",e.rawXML)}}else{const{convertToAss:t}=await e.importAsync("download-danmaku");for(const e of await s.getItemList()){const s=new i(e.cid);await s.fetchInfo();o.add(a.formatTitle(e.titleParameters)+".ass",await t(s.rawXML))}}await o.emit("manual-exports.danmakus.zip")}catch(t){logError(`弹幕下载失败`);throw t}finally{t.dismiss()}}if(this.subtitleModel.value!=="无"){const t=Toast.info("下载字幕中...","批量导出");const i=new n;try{const{getSubtitleConfig:n,getSubtitleList:o}=await e.importAsync("download-subtitle");const[r,l]=await n();for(const t of await s.getItemList()){const s=await o(t.aid,t.cid);const n=s.find(t=>t.language===l)||s[0];const c=await Ajax.getJson(n.url);const d=c.body;if(this.subtitleModel.value==="JSON"){i.add(a.formatTitle(t.titleParameters)+".json",d)}else{const{SubtitleConverter:s}=await e.importAsync("subtitle-converter");const n=new s(r);const o=await n.convertToAss(d);i.add(a.formatTitle(t.titleParameters)+".ass",o)}}await i.emit("manual-exports.subtitles.zip")}catch(t){logError(`字幕下载失败`);throw t}finally{t.dismiss()}}const r=Toast.info("获取链接中...","手动输入");try{switch(t){default:case"aria2":{const t=await s.collectAria2(this.getManualFormat().quality,false);await n.single("manual-exports.txt",new Blob([t],{type:"text/plain"}),{ffmpeg:this.ffmpegOption});break}case"aria2RPC":{await s.collectAria2(this.getManualFormat().quality,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);break}case"idm":{const t=await s.getRawItems(this.getManualFormat().quality);const{toIdmFormat:a}=await e.importAsync("idm-support");const i=a(t);await n.single("manual-exports.ef2",new Blob([i],{type:"text/plain"}));break}}}catch(t){logError(t)}finally{r.dismiss()}},async checkBatch(){const t=["//www.bilibili.com/bangumi","//www.bilibili.com/video","//www.bilibili.com/blackboard/bnj2020.html"];if(!t.some(t=>document.URL.includes(t))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:a}=await e.importAsync("batch-download");if(await a.test()!==true){this.batch=false;this.episodeList=[];return}const s=this.batchExtractor=new a;this.batch=true;this.episodeList=(await s.getItemList()).map((t,e)=>{return{aid:t.aid,cid:t.cid,title:t.title,titleParameters:t.titleParameters,index:e,checked:true}})},async checkSubtitle(){const{getSubtitleList:t}=await e.importAsync("download-subtitle");const a=await t(c.aid,c.cid);this.subtitle=a.length>0},cancelDownload(){if(r){r.cancelDownload()}},async startDownload(){const t=this.getFormat();try{this.downloading=true;const e=await t.downloadInfo(this.dash);e.subtitle=this.subtitle;e.videoSpeed.speedUpdate=(t=>this.speed=t);e.progress=(t=>{this.progressPercent=Math.trunc(t*100)});r=e;await e.download();this.lastDirectDownloadLink=n.lastPackageUrl}catch(t){if(t!=="canceled"){logError(t)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(t=>t.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(t=>t.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(t=>t.checked=!t.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}t.aria2RpcOption=this.rpcSettings;const e=t.aria2RpcOptionProfiles.find(e=>e.name===t.aria2RpcOptionSelectedProfile);if(e){Object.assign(e,this.rpcSettings);t.aria2RpcOptionProfiles=t.aria2RpcOptionProfiles}this.saveRpcSettingsText="已保存";setTimeout(()=>this.saveRpcSettingsText="保存配置",2e3)},updateProfile(e){t.aria2RpcOption=this.rpcSettings=_.omit(e,"name")}},async mounted(){}});const y=f.$mount().$el;document.body.insertAdjacentElement("beforeend",y);Observer.videoChange(async()=>{f.close();f.batch=false;f.selectedTab=l[0];const t=dq("#download-video");const e=await w();t.style.display=e?"flex":"none";if(!e){return}f.aid=c.aid;f.cid=c.cid;try{const t=new s(c.aid);await t.fetchInfo();f.coverUrl=t.coverUrl.replace("http:","https:")}catch(t){f.coverUrl=EmptyImageUrl}f.dashChange();f.checkSubtitle();await f.checkBatch()})}return{widget:{content:`\n`,condition:w,success:y}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video-package.min.js"] = (()=>{return(e,t)=>{class n{constructor(e={}){this.config=e;this.entries=[]}download(e,t){const a=document.createElement("a");const i=URL.createObjectURL(t);if(n.lastPackageUrl){URL.revokeObjectURL(n.lastPackageUrl)}n.lastPackageUrl=i;a.setAttribute("href",i);a.setAttribute("download",escapeFilename(e));document.body.appendChild(a);a.click();a.remove()}add(e,t){if(t===null||t===undefined){return}console.log(`add file: ${escapeFilename(e)}`);this.entries.push({name:escapeFilename(e),data:t})}async blob(){if(this.entries.length===0){return null}if(this.entries.length===1){const e=this.entries[0].data;return typeof e==="string"?new Blob([e]):e}const e=new JSZip;this.entries.forEach(({name:t,data:n})=>{e.file(t,n)});return await e.generateAsync({type:"blob"})}async emit(e){if(this.entries.length===0){return}if(!e||this.entries.length===1){e=this.entries[0].name}const t=await this.blob();if(!t){return}return this.download(e,t)}static async single(e,t,a={}){const i=new n(a);i.add(e,t);return await i.emit()}}n.lastPackageUrl="";return{export:{DownloadVideoPackage:n}}}})(); onlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dpi-img.vue.min.js"] = (()=>{return(t,e)=>{const s=``;return{export:Object.assign({template:s},{props:{size:[Object,Number],src:String,blur:Number,root:HTMLElement,rootMargin:String,threshold:Number,placeholderImage:Boolean},data(){return{srcset:null,actualSrc:null,isPlaceholderActive:false}},watch:{size(){this.sourceChange()},src(){this.sourceChange()}},methods:{sourceChange(){if(this.actualSrc===null||this.srcset===null){return}this.calcSrc()},calcSrc(){const t=!this.src||!this.size;this.isPlaceholderActive=t&&this.placeholderImage;if(t){this.srcset=null;if(this.placeholderImage){this.actualSrc=`https://s1.hdslb.com/bfs/static/blive/live-web-center/static/img/no-cover.1ebe4d5.jpg`}else{this.actualSrc=null}return}let e=this.src;if(e.startsWith("http:")){e=e.replace("http:","https:")}if(e.includes("//static.hdslb.com/images/member/noface.gif")){this.srcset=e;this.actualSrc=e;return}const s=e.substring(e.lastIndexOf(".")+1);this.srcset=getDpiSourceSet(e,this.size,s);this.actualSrc=e}},mounted(){const t={root:this.root,rootMargin:this.rootMargin||"200px",threshold:this.threshold};const e=new IntersectionObserver(t=>{t.forEach(t=>{if(t.isIntersecting){this.calcSrc();e.disconnect()}})},t);e.observe(this.$el)},computed:{width(){if(typeof this.size==="object"&&"width"in this.size){return this.size.width}return null},height(){if(typeof this.size==="object"&&"height"in this.size){return this.size.height}return null},filter(){const t=[];if(this.blur){t.push(`blur(${this.blur}px)`)}return t.join(" ")}}})}}})(); diff --git a/min/bundle.json b/min/bundle.json index 7e8dcabea..7a0c3ae74 100644 --- a/min/bundle.json +++ b/min/bundle.json @@ -83,8 +83,8 @@ "download-danmaku.min.js": "A82325BDFB1B955F91D09801BC53643DF4E70F380E4C4F637AD53925148653E0", "download-live-records.min.js": "7EF26D22D22EB75A6B27B78B3DB0E2ADE6004587C11B0C2893CF1CCB3B6FAB6F", "download-subtitle.min.js": "EAD1F63E53C5A0A9877EBF655B68FB3438601D2869F31D0D4A2F7BD2A215E5F3", - "download-video.min.css": "FE1F0F36E733DD1B3464700BCA8B8EBEBC310D7649B27E63B3AFC735BCD5E33B", - "download-video.min.html": "5D2E4D31AC6F48A41FCB3AA9B7773FF201B0C8ECC5BC85EEC1427C1FED875E83", + "download-video.min.css": "3739711E755A4C7050343337AA59C235D19CC0D75FEF1B39DD1FE471AF19C811", + "download-video.min.html": "F1DBAF7AC697CA28D7B0C0807160B4D5A33DDCDFA9ADB4DFCD511C685FDC0277", "download-video.min.js": "6937EE9C8ED782FFD07D7B6FFF2F2D59BA05FB436E3F5C9C2A48CEF7C0987607", "download-video-package.min.js": "79C0338420F6B388B1F5FFB50DB8333CD8DBF253DFF564F143AA0C01E79EF518", "dpi-img.vue.min.js": "11DF7577B754D8C01E8331E4FDAC9494E72523099845A0D6B0D897849CD841D6", diff --git a/min/bundle.zip b/min/bundle.zip index ff909ff0c1f8f2835b92b6137a07b83f4e5eb6e9..6e25a448a37b15c3972247eea040018fd32a0eb9 100644 GIT binary patch delta 2360 zcmZuz3s6+&6~1>bPvx;>FL#$^_wM5!Ko(Y>3JA+vj4_f>T9X)TC9=eg%Ps<9B$D{p zj3F6{l!PxDFr}ld2`0#BC7EeyNu8K>Xf@5WCeg&$WNg!kk*PCrlD68jkdAhyJM+z% z|NQ4a?{n^s?i&<;$JiATL%NU@iU>u9qC(N3m{4qJQD|`}E)*Y12qlK}p`_4VCk-F$ zOPXlVH#Cobw|c-X2w^A)OdFI_<`dBJ%UwAIF844EG`h27;~Mpr2YjVyKEUNc`&B z+YcnYnJfrl7zF`(Bbk2o^P>jc)R}R^>4>RQuNsoXtg=V8b#(;;_HMVY)#G$@`g*(% zG>2^m;aC^WXY;NJR6Nir*>JwP(4(7hEjvE*p6lvSDiXEzM<&|DSO2hC)TQ{}YRF`}ZRx7^zm;HElpUCk9)L zvVeELZ&xs3q&#r|myJ{rYs!=b@8j*w0o+O^%dm?gu-+x><8CY4;lgVsO2LyR za*G}uGf|y*64%3IJyxX9O7RQqO5xLKoJpZ_@jHkzQ>8R`pN!r2$yWSRqd0V!NtJ|c zGV*%lWSlLfL`;QQRXy`8Bd(d*#rJlxi#booDfnoY91Tw@xpdky@TF3fcogHQR41(+ zkl`7S)djVxC9GqJbqvW09!g+K&CJqSfZZ0V(wSbwX$w`xZaydrtwDc_8<(TVj0`Kw ztUiQuR!T;bmE)3d)=CO~Y^9|-EK0=@2dmzM z(+;Z8CC4Dr$-d9UDEK5sNrrwgd-Ir+CA{c!QnmOjX2WCxi5jia#m3`7jcd0bFKZmq zm|nr4UQxo?bx9YE3TBN;$_p>Dj7aV*MYZF{jclgscvewfK4^wT~S z!+oj^IRzBQ)1iumu(@cBZs~KdyU2<@7iBNn*{=$L=8lfw_F;uR{xB>zg0Ed{>endF zqH<~HkP82hYQn`V&gEzp3v}QYS#*zh2GQAEfI8G?Q?d9G_GPnp{|ObnC)CvWE}tLD z8=ba0hf?W6qMK@UN4vw+2)~=Mb@4lK$<1AS+|3<*4IjI?q76^mQ1!G;hPjLlr+;LV z7vJuq)!4L@V|@>YmvTC9;0hC6#;3^4VS4g29M9qTIBMo$-JioA@5Mw8RmcBcvI`x} zfh}&oud@qt8k`Xf99j@DHHRBNLQZRyN1dVl5K$ zXr)f`VO<`ly&DJec(m@v$9YsL?cQU@);+wc=100bpXL47kk1u7h|zpb>ls`OlPaVZ zFe$|P0@m?Yj23W4e}%slP?^+w%8s^Eb|cCQxw=Q-E96zxgo#2HS%YtwNC(zA(6`QE z!v_vdPRBAf^F0hMW4StqJQZ?aN1#6aR2$`9PCrm^DK3tpqIj|t#3Kd z{FcKS-T*GCe%68VS%(pU64u>T#M9%vivA*MjL80%L%`WD9A?}s;!WI+++tcS?m$m5 zHHx3(55-ii&&YEMoxZkqzpr(NdvmZ2lOp$WVF{^m%L;B^p`nN@=wY^Q)pA@e`EQD6 zn8VHVNeQi#W*>Iq{wAk_@)f+NHa5+lOz2N!zn%1JRa6nT|HH6^ce{I2up8$b9Aa%XH_F%*4TD!S6MC!p zqt`m83E1G~UGh%&a{7jb*Ke>xxA;>030yUl%YOyXR6`a%?x^7p%O7uPJjDM2ey`YO delta 2280 zcmY*a4Nz3q72daRVL^UnAG@%yZ{O}a0wRn23CPdx!itDdenLu`iN-9lL{ivg1f(e% z(QKrWS|v7o6EsRkYi&{y8Y7d`h}e#%j7gJrh9<2|W16PPB#tsu(^Na52c)CfnKO6Z zIrrZ4-S3?9?Nr}@@Df{ZPzY*+Vo(a8WQK7#WNTMh9bpvBAZ`xHEIAQ$q%ZA_T5*xcZI|F`Yo1>+<)YcT}_O}MSO)dT> z6kHxPRO@`L9lkzw%)lnG#j_dNOl%2kiEL)JB(`KW3!BVlWmDK}Z1!<=Ox;_pJybnD zGOMPWzWo6F!$<|nw@@-tljiAr>Db&}yL%N+PY+Ix=BPqy+RPQid>rQ|t>z zo}_8^`I=&DAB#hKZ7Hr7nv`5*c{bMI4%;eEZ zKbTvMFeg!lc%oOr&0fidCzB{${Hjla`-hSdr}#_g!TU*!NP#t(){4?W36CA*81IZk zmX>r#hZGxmkBS?E7)how?H9mIGP$+ILvyPEW<5pYAq%5QJ|aOmE=kyHA%{49Z2l|Z zg(|-AuXFLwk1xbmhwu?aX4HRw1#X$vXkDl9dzn!W%j6JB@s3O$@wE{Nvm=rjnN|kx zIX(Yn!jzE@_geYz*P|G=Qoc}(KUv8shEP0eC_Wwzg`amA-&Lqw``<5dSRt1%iK_~^ zg$h_~v__oO8BrBtwA_8I7;2Ov?mhGhMs2(`A2T+t<7ay0*tw3sLAIR}6i0A&*tyPy zIBTbJVI%%Cx9moVN|oBHk$6^RRyX5{N*UQfUfQK=Bb`$SHm7N#ZS z413XL(zIk3`ms2aB*7nGPYq5dR zdD$iOqc??t&%A`m6vohxkW|J$g345eVncr_6)$q0Hfg@+d#cUbjW2ZM^0Zf zX4bR&>O zNzgANSs&QXPG2{6#gQ4S*%NW_dG-Vxjb6VW*-mbnJqP9cIjh0(Wwc7H7?iPpP?m9i z88={j2ESwoc^O=sMD%1ZseYWv;I?`ERT(e8DkmYr z533YCn8iqjVa?*Bb?|0UrRb?vu&-LN-W}&@-XOMYQs8Y;Oo-0rSu!=ve+LXgF7y5I!er=e_;rb0BJeQn0 zX;jf5Hk~ZklFRAzV+!iV_{7m%KJf;oa%pYk^RFqI4qw3WWLMilKlGhd?q|9d59To| z-^XAcRS3&*HILQ`GE!HtptLsFaJIo_MU|Opa2Kld{;vOM{MXSV2!x-r46p@ zwlut3$dMZy(azpMOd+ioJlI%BRjj{1FQj_m9PSjd9Nf-=YbBR1481EEg*hM5MJ%>| zTgkHHM^q6%<0$HR5py@#v15Zh0dK_c%@akOvmYN8QDxZ7Gj>f!>;FfDUnUE$V^c8| zv2YC)bARo@wPF?-+du7i_fvb~oD@f+zJzK1_YFJBZrbCqw}fea4rfZpt-JP(U4sio zh7nuJcUiE!l#29c<5W#&z>BdMp6h2h5V<~S&eOGdi=!=opO&-xLOiqjRw;KwgI&e2 zU6rtL5u;^w)FIr-Y;OlSxzB!tW+%DD>Fp|%9jXZzoIHyuJ5{vrRFm#@o#Y}p{8B%s z==S+KF)t^z>=P~_;9|zQG3w$DTZUUM9{8UOs`zkFHKNwd4_S&HH)~4*&b!GI-Tb<$ z+1Ap;jnm}q*fOUt5(*|&L)5)VpS_@>YErc!S#aEII~=Mw{vJPf7lwu*_{svSKZisV0f?DbHx(1jBol0$zs It8&)=0c%mTga7~l diff --git a/min/download-video.min.css b/min/download-video.min.css index a88a2a5d9..2ce6e4b1b 100644 --- a/min/download-video.min.css +++ b/min/download-video.min.css @@ -1 +1 @@ -.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))} \ No newline at end of file +.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}.download-video.opened .rpc-settings.show{pointer-events:initial}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(33.33% - 32px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video .actions>.aria2-rpc{flex-basis:100%}.download-video i.mdi-alert-circle{font-size:22px;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px;align-self:center}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px;min-height:180px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1)}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))} \ No newline at end of file diff --git a/min/download-video.min.html b/min/download-video.min.html index e18fd4559..ac4a2c23b 100644 --- a/min/download-video.min.html +++ b/min/download-video.min.html @@ -1 +1 @@ -

下载视频

{{t.displayName}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
\ No newline at end of file +

下载视频

{{t.displayName}}
预计大小: {{displaySize}}
格式
清晰度
弹幕
字幕
首选编码

直接下载

{{speed}}
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

链接列表

共{{manualInputItems.length}}个视频

导出

{{showRpcSettings ? '取消' : 'aria2 RPC'}}

aria2 RPC

配置

主机
端口
密钥
限速
默认路径
路径
最终路径: {{rpcSettings.baseDir + rpcSettings.dir}}
方法
开始下载
{{saveRpcSettingsText}}
\ No newline at end of file diff --git a/src/client/utils.js b/src/client/utils.js index a2d5de56c..33c1f26c1 100644 --- a/src/client/utils.js +++ b/src/client/utils.js @@ -104,7 +104,7 @@ export const dqa = (selector, scopedSelector) => { } return [...selector.querySelectorAll(scopedSelector)] } -export const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0` +export const UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0` export const EmptyImageUrl = 'data:image/svg+xml;utf-8,' export const ascendingSort = (itemProp) => { return (a, b) => itemProp(a) - itemProp(b) diff --git a/src/video/download-video/download-video.html b/src/video/download-video/download-video.html index ae11b4b3c..4520563a0 100644 --- a/src/video/download-video/download-video.html +++ b/src/video/download-video/download-video.html @@ -25,12 +25,6 @@
-
- -
- 警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项. -
-
预计大小: {{displaySize}}
@@ -77,8 +71,14 @@

直接下载

{{speed}}
- - +
+ +
+ 警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项. +
+
+ +
diff --git a/src/video/download-video/download-video.scss b/src/video/download-video/download-video.scss index 1787cfc92..5d5b2cade 100644 --- a/src/video/download-video/download-video.scss +++ b/src/video/download-video/download-video.scss @@ -258,12 +258,13 @@ } } i.mdi-alert-circle { - font-size: 14pt; + font-size: 22px; color: #ff9800; } .size-warning { position: relative; padding: 0 8px; + align-self: center; } .size-warning-tip { position: absolute;