!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/download/aria2-output"]=t():e["video/download/aria2-output"]=t()}(globalThis,(()=>(()=>{var e={800:(e,t,n)=>{var o=n(218)((function(e){return e[1]}));o.push([e.id,".rpc-config.download-video-config-section {\n display: flex;\n align-items: center;\n flex-direction: column;\n align-items: stretch;\n}\n.rpc-config.download-video-config-section > * {\n display: flex;\n align-items: center;\n}\n.rpc-config.download-video-config-section > *:not(:last-child) {\n margin-bottom: 12px;\n}\n.rpc-config.download-video-config-section .profile-item-name {\n margin-right: 8px;\n}\n.rpc-config.download-video-config-section .profile-other .profile-item-name {\n align-self: flex-start;\n}\n.rpc-config.download-video-config-section .profile-select .be-textbox,\n.rpc-config.download-video-config-section .profile-select .be-dropdown {\n margin-right: 8px;\n}\n.rpc-config.download-video-config-section .profile-select .be-button {\n padding: 4px;\n}\n.rpc-config.download-video-config-section .profile-method {\n align-self: flex-start;\n}",""]),e.exports=o},218:e=>{"use strict"; // eslint-disable-next-line func-names e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")}, // eslint-disable-next-line func-names t.i=function(e,n,o){"string"==typeof e&&( // eslint-disable-next-line no-param-reassign e=[[null,e,""]]);var r={};if(o)for(var i=0;i{"use strict";var o,r=function(){return void 0===o&&( // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 // @see https://github.com/webpack-contrib/style-loader/issues/177 o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),s=[];function a(e){for(var t=-1,n=0;n{"use strict";n.r(t),n.d(t,{default:()=>P});var o=function(){var e=this,t=e._self._c;e._self._setupProxy;return t("div",{staticClass:"rpc-config download-video-config-section"},[e.isRenaming?t("div",{staticClass:"profile-select"},[t("div",{staticClass:"profile-item-name"},[e._v("重命名 RPC 预设:")]),e._v(" "),t("TextBox",{ref:"renameInput",model:{value:e.profileRename,callback:function(t){e.profileRename=t},expression:"profileRename"}}),e._v(" "),t("VButton",{key:"check",attrs:{type:"transparent",title:"完成"},on:{click:function(t){return e.endRename()}}},[t("VIcon",{attrs:{icon:"mdi-check",size:16}})],1)],1):t("div",{staticClass:"profile-select"},[t("div",{staticClass:"profile-item-name"},[e._v("RPC 预设:")]),e._v(" "),t("VDropdown",{attrs:{items:e.rpcProfiles},scopedSlots:e._u([{key:"item",fn:function({item:t}){return[e._v("\n "+e._s(t.name)+"\n ")]}}]),model:{value:e.selectedRpcProfile,callback:function(t){e.selectedRpcProfile=t},expression:"selectedRpcProfile"}}),e._v(" "),t("VButton",{key:"edit",attrs:{type:"transparent",title:"重命名"},on:{click:function(t){return e.startRename()}}},[t("VIcon",{attrs:{icon:"mdi-pencil-outline",size:16}})],1),e._v(" "),t("VButton",{key:"new",attrs:{type:"transparent",title:"新建预设"},on:{click:function(t){return e.newProfile()}}},[t("VIcon",{attrs:{icon:"mdi-plus",size:16}})],1),e._v(" "),t("VButton",{key:"delete",attrs:{disabled:e.rpcProfiles.length<2,type:"transparent",title:"删除当前预设"},on:{click:function(t){return e.deleteProfile()}}},[t("VIcon",{attrs:{icon:"mdi-trash-can-outline",size:16}})],1)],1),e._v(" "),e.selectedRpcProfile?[t("div",{staticClass:"profile-secret-key"},[t("div",{staticClass:"profile-item-name"},[e._v("密钥:")]),e._v(" "),t("TextBox",{attrs:{"change-on-blur":""},model:{value:e.selectedRpcProfile.secretKey,callback:function(t){e.$set(e.selectedRpcProfile,"secretKey",t)},expression:"selectedRpcProfile.secretKey"}})],1),e._v(" "),t("div",{staticClass:"profile-dir"},[t("div",{staticClass:"profile-item-name"},[e._v("路径:")]),e._v(" "),t("TextBox",{attrs:{"change-on-blur":""},model:{value:e.selectedRpcProfile.dir,callback:function(t){e.$set(e.selectedRpcProfile,"dir",t)},expression:"selectedRpcProfile.dir"}})],1),e._v(" "),t("div",{staticClass:"profile-host"},[t("div",{staticClass:"profile-item-name"},[e._v("主机:")]),e._v(" "),t("TextBox",{attrs:{"change-on-blur":""},model:{value:e.selectedRpcProfile.host,callback:function(t){e.$set(e.selectedRpcProfile,"host",t)},expression:"selectedRpcProfile.host"}})],1),e._v(" "),t("div",{staticClass:"profile-port"},[t("div",{staticClass:"profile-item-name"},[e._v("端口:")]),e._v(" "),t("TextBox",{attrs:{"change-on-blur":""},model:{value:e.selectedRpcProfile.port,callback:function(t){e.$set(e.selectedRpcProfile,"port",t)},expression:"selectedRpcProfile.port"}})],1),e._v(" "),t("div",{staticClass:"profile-method"},[t("div",{staticClass:"profile-item-name"},[e._v("方法:")]),e._v(" "),t("VDropdown",{attrs:{items:["get","post"],"key-mapper":e=>e},scopedSlots:e._u([{key:"item",fn:function({item:t}){return[e._v("\n "+e._s(t)+"\n ")]}}],null,!1,883355439),model:{value:e.selectedRpcProfile.method,callback:function(t){e.$set(e.selectedRpcProfile,"method",t)},expression:"selectedRpcProfile.method"}})],1),e._v(" "),t("div",{staticClass:"profile-other"},[t("div",{staticClass:"profile-item-name"},[e._v("其他配置:")]),e._v(" "),t("TextArea",{attrs:{placeholder:"some-key=value","change-on-blur":""},model:{value:e.selectedRpcProfile.other,callback:function(t){e.$set(e.selectedRpcProfile,"other",t)},expression:"selectedRpcProfile.other"}})],1)]:e._e()],2)};o._withStripped=!0;const r=coreApis.settings;var i=n(391);const s=coreApis.ui,a={name:"未命名",secretKey:"",dir:"",host:"127.0.0.1",port:"6800",method:"get",other:""},{options:c}=(0,r.getComponentSettings)("downloadVideo"),l={...{rpcProfiles:[a],selectedRpcProfileName:a.name},...c},d=l.rpcProfiles.find((e=>e.name===l.selectedRpcProfileName))??(l.rpcProfiles.length<1?(l.rpcProfiles.push(a),a):l.rpcProfiles[0]);console.log(l,d);const p=Vue.extend({components:{TextBox:s.TextBox,VButton:s.VButton,VIcon:s.VIcon,VDropdown:s.VDropdown,TextArea:s.TextArea},data:()=>({isRenaming:!1,profileRename:"",rpcProfiles:l.rpcProfiles,selectedRpcProfile:d}),methods:{saveSettings(){l.selectedRpcProfileName=this.selectedRpcProfile.name,l.rpcProfiles=this.rpcProfiles,Object.assign(c,l)},async startRename(){this.profileRename=this.selectedRpcProfile.name,this.isRenaming=!0,await this.$nextTick(),this.$refs.renameInput?.focus()},endRename(){const e=this.profileRename;e?l.rpcProfiles.some((t=>t.name!==this.selectedRpcProfile.name&&t.name===e))?i.Toast.error("名称不得与其他预设重复","重命名 RPC 预设",2e3):(this.selectedRpcProfile.name=this.profileRename,this.isRenaming=!1,this.saveSettings()):i.Toast.error("名称不得为空","重命名 RPC 预设",2e3)},newProfile(){const e={...this.selectedRpcProfile},t={num:1,toString(){return`未命名${this.num}`}};for(;l.rpcProfiles.some((e=>e.name===t.toString()));)t.num++;e.name=t.toString(),l.rpcProfiles.push(e),this.selectedRpcProfile=e},deleteProfile(){if(l.rpcProfiles.length<2)return;const e=l.rpcProfiles.findIndex((e=>e.name===this.selectedRpcProfile.name));-1!==e&&confirm(`确认删除 RPC 预设 "${this.selectedRpcProfile.name}" 吗?`)&&(l.rpcProfiles.splice(e,1),this.selectedRpcProfile=l.rpcProfiles[0])}}});var f=n(332),u=n.n(f),m=n(800),h=n.n(m),v={insert:"head",singleton:!1};u()(h(),v);h().locals;var g=function(e,t,n,o,r,i,s,a){var c,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=n,l._compiled=!0),o&&(l.functional=!0),i&&(l._scopeId="data-v-"+i),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):r&&(c=a?function(){r.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:r),c)if(l.functional){l._injectStyles=c;var d=l.render;l.render=function(e,t){return c.call(t),d(e,t)}}else{var p=l.beforeCreate;l.beforeCreate=p?[].concat(p,c):[c]}return{exports:e,options:l}}(p,o,[],!1,null,null,null);const P=g.exports},391:e=>{"use strict";e.exports=coreApis.toast}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,exports:{}};return e[o](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.d(o,{plugin:()=>h});const e=coreApis.download,t=coreApis.utils.constants,r=coreApis.utils.title,i={name:"aria2",displayName:"aria2 Input",description:"使用 aria2 命令行输入文件开始下载. (aria2c -i xxx.txt)",runAction:async n=>{const{infos:o}=n,i=document.URL.replace(window.location.search,""),s=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${o.map((e=>e.titledFragments.map((e=>({url:e.url,params:{referer:i,userAgent:t.UserAgent,out:e.title}}))).flat().map((e=>{const t=Object.entries(e.params).map((e=>{let[t,n]=e;return` ${lodash.kebabCase(t)}=${n}`})).join("\n");return`${e.url}\n${t}`})))).flat().join("\n")}`.trim();await e.DownloadPackage.single(`${(0,r.getFriendlyTitle)()}.txt`,s)}},s=coreApis.ajax;var a=n(391);const c=coreApis.utils.log,l=e=>{const t=e.host.match(/^http[s]?:\/\//)?e.host:`http://${e.host}`;return{option:e,host:t,methodName:"aria2.addUri"}},d=async(e,t)=>{try{let n=await t();return"string"==typeof n&&(n=JSON.parse(n)),void 0!==n.error?1===n.error.code?{param:e,success:!1,message:"请求遭到拒绝, 请检查您的密钥相关设置."}:{param:e,success:!1,message:`请求发生错误, code = ${n.error.code}, message = ${n.error.message}`}:{param:e,success:!0,message:n.result}}catch(t){return{param:e,success:!1,message:`无法连接到RPC主机, error = ${t.toString()}`}}},p=async(e,t)=>{const{option:n,host:o,methodName:r}=l(e);return d(t,(async()=>{const e=window.btoa(unescape(encodeURIComponent(JSON.stringify(t.params)))),i=`${o}:${n.port}/jsonrpc?method=${r}&id=${t.id}¶ms=${e}`;return console.log(`RPC request: ${i}`),i.startsWith("http:")?(0,s.monkey)({method:"GET",url:i,responseType:"json"}):(0,s.getJson)(i)}))},f=async(e,t)=>{const{option:n,host:o,methodName:r}=l(e);return d(t,(async()=>{const e=`${o}:${n.port}/jsonrpc`,i={method:r,id:t.id,params:t.params};return e.startsWith("http:")?(0,s.monkey)({method:"POST",url:e,responseType:"json",data:JSON.stringify(i)}):(0,s.postJson)(e,i)}))},u=e=>{if(!e)return{};const t=e.split("\n").map((e=>{const[t,...n]=e.trim().split("=");return[t.trim(),n.join("=").trim()]})).filter((e=>Boolean(e[1])));return Object.fromEntries(t)},m={name:"aria2Rpc",displayName:"aria2 RPC",description:"使用 aria2 RPC 功能发送下载请求.",runAction:async(e,n)=>{const{infos:o}=e,{selectedRpcProfile:r}=n,{secretKey:i,dir:s,other:l}=r,d=document.URL.replace(window.location.search,""),m=o.map((e=>e.titledFragments.map((e=>{const n=[];i&&n.push(`token:${i}`),n.push([e.url]),n.push({referer:d,"user-agent":t.UserAgent,out:e.title,dir:s||void 0,...u(l)});return{params:n,id:encodeURIComponent(e.title)}})))).flat(),h=await(async(e,t)=>{const n=[];for(const o of t){let t;t="get"===e.method?await p(e,o):await f(e,o),n.push(t)}return n})(r,m);if(console.table(h),1===h.length){const e=h[0];e.success?a.Toast.success(`成功发送了请求, GID = ${e.message}`,"aria2 RPC",5e3):(0,c.logError)(e.message)}else{const e=h.filter((e=>e.success)).length,t=h.length-e;a.Toast.info(`发送了 ${h.length} 个请求, 成功 ${e} 个, 失败 ${t} 个.`,"aria2 RPC",5e3)}},component:()=>Promise.resolve().then(n.bind(n,345)).then((e=>e.default))},h={name:"downloadVideo.outputs.aria2",displayName:"下载视频 - aria2 输出支持",description:"为下载视频增加 aria2 文件导出和 RPC 输出支持.",setup:e=>{let{addData:t}=e;t("downloadVideo.outputs",(e=>{e.push(i),e.push(m)}))},commitHash:"e998998fc03ae60938410eb104a6691b560cf563",coreVersion:"2.8.10"}})(),o=o.plugin})()));