From b846b96f7a860f49fcd72f595cf22c7ea144de78 Mon Sep 17 00:00:00 2001 From: Roberto Tonino Date: Mon, 1 Mar 2021 21:58:43 +0100 Subject: [PATCH] refactor: simplified and renamed get function --- public/js/bundle.js | 10 +++++----- src/app.js | 41 ++++++++++++++++++++--------------------- src/use/main-search.js | 5 ++--- src/use/search.js | 4 ++-- src/utils/api.js | 17 ++++++++--------- src/utils/downloads.js | 4 ++-- 6 files changed, 39 insertions(+), 42 deletions(-) diff --git a/public/js/bundle.js b/public/js/bundle.js index d9f8df3..8f2ec1e 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -2494,7 +2494,7 @@ a { `;styleInject(css_248z$8);let wasEventListenerAdded=!1;class CustomSocket extends WebSocket{constructor(a){super(a)}emit(a,n){if(this.readyState!==WebSocket.OPEN)return!1;this.send(JSON.stringify({key:a,data:n}))}on(a,n){wasEventListenerAdded||(wasEventListenerAdded=!0,this.addEventListener("message",r=>{const i=JSON.parse(r.data);i.key===a&&n(i.data)}))}off(){console.log("off!")}}const socket=new CustomSocket("ws://"+location.host+"/");var __vue_render__=function(e,a){var n=a._c;return n("div",{directives:[{name:"show",rawName:"v-show",value:!a.props.hidden,expression:"!props.hidden"}],staticClass:"flex justify-center items-center flex-col flex-1 h-full",class:a.props.additionalClasses},[n("span",{staticClass:"mb-5"},[a._v(a._s(a.props.text||"Loading..."))]),a._v(" "),a._m(0)])},__vue_staticRenderFns__=[function(e,a){var n=a._c;return n("div",{staticClass:"lds-ring"},[n("div"),a._v(" "),n("div"),a._v(" "),n("div"),a._v(" "),n("div")])}];const __vue_inject_styles__=function(e){if(!e)return;e("data-v-20045564_0",{source:".lds-ring[data-v-20045564]{display:inline-block;position:relative;width:80px;height:80px}.lds-ring div[data-v-20045564]{box-sizing:border-box;display:block;position:absolute;width:64px;height:64px;margin:8px;border:8px solid #fff;border-radius:50%;animation:lds-ring-data-v-20045564 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.lds-ring div[data-v-20045564]:nth-child(1){animation-delay:-.45s}.lds-ring div[data-v-20045564]:nth-child(2){animation-delay:-.3s}.lds-ring div[data-v-20045564]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-data-v-20045564{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",map:void 0,media:void 0})},__vue_scope_id__="data-v-20045564",__vue_module_identifier__=void 0,__vue_is_functional_template__=!0;function __vue_normalize__(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="BaseLoadingPlaceholder.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let d;if(a&&(d=function(u){a.call(this,l(u))}),d!==void 0)if(o.functional){const u=o.render;o.render=function(h,m){return d.call(m),u(h,m)}}else{const u=o.beforeCreate;o.beforeCreate=u?[].concat(u,d):[d]}}return o}function __vue_create_injector__(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__.styles||(__vue_create_injector__.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,d=c.ids.length;if(c.ids.push(i),s.map&&(o+=` /*# sourceURL=`+s.map.sources[0]+" */",o+=` /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const u=c.element=document.createElement("style");u.type="text/css",s.media&&u.setAttribute("media",s.media),n&&(u.setAttribute("data-group",l),u.setAttribute("data-next-index","0")),e.appendChild(u)}if(n&&(d=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",d+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` -`);else{const u=document.createTextNode(o),f=c.element.childNodes;f[d]&&c.element.removeChild(f[d]),f.length?c.element.insertBefore(u,f[d]):c.element.appendChild(u)}}}}var BaseLoadingPlaceholder=__vue_normalize__({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},__vue_inject_styles__,{},__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,__vue_create_injector__);const get=function(e,a){let n=`/api/${e}`;if(a){let r=Object.keys(a).map(i=>encodeURIComponent(i)+"="+encodeURIComponent(a[i])).join("&");n+="?"+r}return fetch(n).then(r=>r.json())};function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");get("addToQueue",{url:e,bitrate:a})}function aggregateDownloadLinks(e){let a=[];return e.forEach(n=>{a.push(n.link)}),a.join(";")}function generatePath(e){if(!e)throw new Error("No element passed to the generatePath function!");let a=[e];for(;(e=e.parentNode)&&e!==document;)a.push(e);return a}function isValidURL(e){let a=e.toLowerCase();if(a.startsWith("http")){if(a.indexOf("deezer.com")>=0||a.indexOf("deezer.page.link")>=0||a.indexOf("open.spotify.com")>=0||a.indexOf("link.tospotify.com")>=0)return!0}else if(a.startsWith("spotify:"))return!0;return!1}function convertDuration(e){let a,n;return a=Math.floor(e/60),n=e-a*60,n<10&&(n="0"+n),a+":"+n}function convertDurationSeparated(e){let a,n,r;return n=Math.floor(e/60),a=Math.floor(n/60),r=e-n*60,n-=a*60,[a,n,r]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce(e,a,n){var r;return function(){var i=this,s=arguments,l=function(){r=null,n||e.apply(i,s)},c=n&&!r;clearTimeout(r),r=setTimeout(l,a),c&&e.apply(i,s)}}function copyToClipboard(e){const a=document.createElement("input");document.body.appendChild(a),a.setAttribute("type","text"),a.setAttribute("value",e),a.select(),a.setSelectionRange(0,99999),document.execCommand("copy"),a.remove()}function getPropertyWithFallback(e,...a){for(const n of a){let r=/\./.test(n),i=r?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof i!="undefined")return i}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce};const downloadQualities=[{objName:"flac",label:"FLAC",value:9},{objName:"320kbps",label:"MP3 320kbps",value:3},{objName:"128kbps",label:"MP3 128kbps",value:1},{objName:"realityAudioHQ",label:"360 Reality Audio [HQ]",value:15},{objName:"realityAudioMQ",label:"360 Reality Audio [MQ]",value:14},{objName:"realityAudioLQ",label:"360 Reality Audio [LQ]",value:13}];var script={data(){return{menuOpen:!1,xPos:0,yPos:0,deezerHref:"",generalHref:"",imgSrc:""}},computed:{options(){const e={cut:{label:this.$t("globals.cut"),show:!1,position:1,action:()=>{document.execCommand("Cut")}},copy:{label:this.$t("globals.copy"),show:!1,position:2,action:()=>{document.execCommand("Copy")}},copyLink:{label:this.$t("globals.copyLink"),show:!1,position:3,action:()=>{copyToClipboard(this.generalHref)}},copyImageLink:{label:this.$t("globals.copyImageLink"),show:!1,position:4,action:()=>{copyToClipboard(this.imgSrc)}},copyDeezerLink:{label:this.$t("globals.copyDeezerLink"),show:!1,position:5,action:()=>{copyToClipboard(this.deezerHref)}},paste:{label:this.$t("globals.paste"),show:!1,position:6,action:()=>{clipboard in navigator?navigator.clipboard.readText().then(n=>{document.execCommand("insertText",void 0,n)}):document.execCommand("paste")}}};let a=Object.values(e).length+1;return downloadQualities.forEach((n,r)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+r,action:sendAddToQueue.bind(null,this.deezerHref,n.value)}}),e},sortedOptions(){return Object.values(this.options).sort((e,a)=>e.position{this.menuOpen=!1,this.options.copyLink.show=!1,this.options.copyDeezerLink.show=!1,this.options.copyImageLink.show=!1,downloadQualities.forEach(e=>{this.options[e.objName].show=!1})}).catch(e=>{console.error(e)})},positionMenu(e,a){this.xPos=`${e}px`,this.yPos=`${a}px`,this.$nextTick().then(()=>{const{innerHeight:n,innerWidth:r}=window,i=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(i>r){const l=i-r+15;this.xPos=`${e-l}px`}if(s>n){const l=s-n+15;this.yPos=`${a-l}px`}})},showDeezerOptions(e){e||(this.options.copyDeezerLink.show=!0),downloadQualities.forEach(a=>{this.options[a.objName].show=!0})}}};const __vue_script__=script;var __vue_render__$1=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.menuOpen,expression:"menuOpen"}],ref:"contextMenu",staticClass:"context-menu",style:{top:e.yPos,left:e.xPos}},e._l(e.sortedOptions,function(r){return n("button",{directives:[{name:"show",rawName:"v-show",value:r.show,expression:"option.show"}],key:r.label,staticClass:"btn menu-option",on:{click:function(i){return i.preventDefault(),r.action(i)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(r.label))])])}),0)},__vue_staticRenderFns__$1=[];const __vue_inject_styles__$1=function(e){if(!e)return;e("data-v-ce73bd68_0",{source:".context-menu[data-v-ce73bd68]{position:absolute;top:0;left:0;min-width:100px;border-radius:7px;background:var(--secondary-background);box-shadow:4px 10px 18px 0 rgba(0,0,0,.15);overflow:hidden;z-index:10000}.menu-option[data-v-ce73bd68]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-ce73bd68]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-ce73bd68]{text-transform:capitalize}button[data-v-ce73bd68]{color:var(--primary-text);color:unset;background-color:var(--primary-color);background-color:unset;min-width:unset;position:unset;border:unset;border-radius:unset;font-family:unset;font-weight:unset;font-size:unset;padding:unset;margin-right:unset;height:unset;text-transform:unset;cursor:unset;transition:unset}button[data-v-ce73bd68]:focus{outline:0}button[data-v-ce73bd68]:active{background-color:unset;transform:unset}button[data-v-ce73bd68]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$1="data-v-ce73bd68",__vue_module_identifier__$1=void 0,__vue_is_functional_template__$1=!1;function __vue_normalize__$1(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="TheContextMenu.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let d;if(a&&(d=function(u){a.call(this,l(u))}),d!==void 0)if(o.functional){const u=o.render;o.render=function(h,m){return d.call(m),u(h,m)}}else{const u=o.beforeCreate;o.beforeCreate=u?[].concat(u,d):[d]}}return o}function __vue_create_injector__$1(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$1.styles||(__vue_create_injector__$1.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,d=c.ids.length;if(c.ids.push(i),s.map&&(o+=` +`);else{const u=document.createTextNode(o),f=c.element.childNodes;f[d]&&c.element.removeChild(f[d]),f.length?c.element.insertBefore(u,f[d]):c.element.appendChild(u)}}}}var BaseLoadingPlaceholder=__vue_normalize__({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},__vue_inject_styles__,{},__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,__vue_create_injector__);function fetchApi(e,a){const n=new URL(`${window.location.origin}/api/${e}`);return Object.keys(a).forEach(r=>{n.searchParams.append(r,a[r])}),fetch(n.href).then(r=>r.json())}function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");fetchApi("addToQueue",{url:e,bitrate:a})}function aggregateDownloadLinks(e){let a=[];return e.forEach(n=>{a.push(n.link)}),a.join(";")}function generatePath(e){if(!e)throw new Error("No element passed to the generatePath function!");let a=[e];for(;(e=e.parentNode)&&e!==document;)a.push(e);return a}function isValidURL(e){let a=e.toLowerCase();if(a.startsWith("http")){if(a.indexOf("deezer.com")>=0||a.indexOf("deezer.page.link")>=0||a.indexOf("open.spotify.com")>=0||a.indexOf("link.tospotify.com")>=0)return!0}else if(a.startsWith("spotify:"))return!0;return!1}function convertDuration(e){let a,n;return a=Math.floor(e/60),n=e-a*60,n<10&&(n="0"+n),a+":"+n}function convertDurationSeparated(e){let a,n,r;return n=Math.floor(e/60),a=Math.floor(n/60),r=e-n*60,n-=a*60,[a,n,r]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce(e,a,n){var r;return function(){var i=this,s=arguments,l=function(){r=null,n||e.apply(i,s)},c=n&&!r;clearTimeout(r),r=setTimeout(l,a),c&&e.apply(i,s)}}function copyToClipboard(e){const a=document.createElement("input");document.body.appendChild(a),a.setAttribute("type","text"),a.setAttribute("value",e),a.select(),a.setSelectionRange(0,99999),document.execCommand("copy"),a.remove()}function getPropertyWithFallback(e,...a){for(const n of a){let r=/\./.test(n),i=r?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof i!="undefined")return i}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce};const downloadQualities=[{objName:"flac",label:"FLAC",value:9},{objName:"320kbps",label:"MP3 320kbps",value:3},{objName:"128kbps",label:"MP3 128kbps",value:1},{objName:"realityAudioHQ",label:"360 Reality Audio [HQ]",value:15},{objName:"realityAudioMQ",label:"360 Reality Audio [MQ]",value:14},{objName:"realityAudioLQ",label:"360 Reality Audio [LQ]",value:13}];var script={data(){return{menuOpen:!1,xPos:0,yPos:0,deezerHref:"",generalHref:"",imgSrc:""}},computed:{options(){const e={cut:{label:this.$t("globals.cut"),show:!1,position:1,action:()=>{document.execCommand("Cut")}},copy:{label:this.$t("globals.copy"),show:!1,position:2,action:()=>{document.execCommand("Copy")}},copyLink:{label:this.$t("globals.copyLink"),show:!1,position:3,action:()=>{copyToClipboard(this.generalHref)}},copyImageLink:{label:this.$t("globals.copyImageLink"),show:!1,position:4,action:()=>{copyToClipboard(this.imgSrc)}},copyDeezerLink:{label:this.$t("globals.copyDeezerLink"),show:!1,position:5,action:()=>{copyToClipboard(this.deezerHref)}},paste:{label:this.$t("globals.paste"),show:!1,position:6,action:()=>{clipboard in navigator?navigator.clipboard.readText().then(n=>{document.execCommand("insertText",void 0,n)}):document.execCommand("paste")}}};let a=Object.values(e).length+1;return downloadQualities.forEach((n,r)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+r,action:sendAddToQueue.bind(null,this.deezerHref,n.value)}}),e},sortedOptions(){return Object.values(this.options).sort((e,a)=>e.position{this.menuOpen=!1,this.options.copyLink.show=!1,this.options.copyDeezerLink.show=!1,this.options.copyImageLink.show=!1,downloadQualities.forEach(e=>{this.options[e.objName].show=!1})}).catch(e=>{console.error(e)})},positionMenu(e,a){this.xPos=`${e}px`,this.yPos=`${a}px`,this.$nextTick().then(()=>{const{innerHeight:n,innerWidth:r}=window,i=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(i>r){const l=i-r+15;this.xPos=`${e-l}px`}if(s>n){const l=s-n+15;this.yPos=`${a-l}px`}})},showDeezerOptions(e){e||(this.options.copyDeezerLink.show=!0),downloadQualities.forEach(a=>{this.options[a.objName].show=!0})}}};const __vue_script__=script;var __vue_render__$1=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{directives:[{name:"show",rawName:"v-show",value:e.menuOpen,expression:"menuOpen"}],ref:"contextMenu",staticClass:"context-menu",style:{top:e.yPos,left:e.xPos}},e._l(e.sortedOptions,function(r){return n("button",{directives:[{name:"show",rawName:"v-show",value:r.show,expression:"option.show"}],key:r.label,staticClass:"btn menu-option",on:{click:function(i){return i.preventDefault(),r.action(i)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(r.label))])])}),0)},__vue_staticRenderFns__$1=[];const __vue_inject_styles__$1=function(e){if(!e)return;e("data-v-ce73bd68_0",{source:".context-menu[data-v-ce73bd68]{position:absolute;top:0;left:0;min-width:100px;border-radius:7px;background:var(--secondary-background);box-shadow:4px 10px 18px 0 rgba(0,0,0,.15);overflow:hidden;z-index:10000}.menu-option[data-v-ce73bd68]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-ce73bd68]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-ce73bd68]{text-transform:capitalize}button[data-v-ce73bd68]{color:var(--primary-text);color:unset;background-color:var(--primary-color);background-color:unset;min-width:unset;position:unset;border:unset;border-radius:unset;font-family:unset;font-weight:unset;font-size:unset;padding:unset;margin-right:unset;height:unset;text-transform:unset;cursor:unset;transition:unset}button[data-v-ce73bd68]:focus{outline:0}button[data-v-ce73bd68]:active{background-color:unset;transform:unset}button[data-v-ce73bd68]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$1="data-v-ce73bd68",__vue_module_identifier__$1=void 0,__vue_is_functional_template__$1=!1;function __vue_normalize__$1(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};o.__file="TheContextMenu.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r;{let d;if(a&&(d=function(u){a.call(this,l(u))}),d!==void 0)if(o.functional){const u=o.render;o.render=function(h,m){return d.call(m),u(h,m)}}else{const u=o.beforeCreate;o.beforeCreate=u?[].concat(u,d):[d]}}return o}function __vue_create_injector__$1(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$1.styles||(__vue_create_injector__$1.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(i,s){if(document.querySelector('style[data-vue-ssr-id~="'+i+'"]'))return;const l=n?s.media||"default":i,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(i)){let o=s.source,d=c.ids.length;if(c.ids.push(i),s.map&&(o+=` /*# sourceURL=`+s.map.sources[0]+" */",o+=` /*# sourceMappingURL=data:application/json;base64,`+btoa(unescape(encodeURIComponent(JSON.stringify(s.map))))+" */"),n&&(c.element=c.element||document.querySelector("style[data-group="+l+"]")),!c.element){const u=c.element=document.createElement("style");u.type="text/css",s.media&&u.setAttribute("media",s.media),n&&(u.setAttribute("data-group",l),u.setAttribute("data-next-index","0")),e.appendChild(u)}if(n&&(d=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",d+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` `);else{const u=document.createTextNode(o),f=c.element.childNodes;f[d]&&c.element.removeChild(f[d]),f.length?c.element.insertBefore(u,f[d]):c.element.appendChild(u)}}}}var TheContextMenu=__vue_normalize__$1({render:__vue_render__$1,staticRenderFns:__vue_staticRenderFns__$1},__vue_inject_styles__$1,__vue_script__,__vue_scope_id__$1,__vue_is_functional_template__$1,__vue_module_identifier__$1,__vue_create_injector__$1);/*! @@ -2530,7 +2530,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var __assign=function(){return __assign=Object.assign||function(a){for(var n,r=1,i=arguments.length;r=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,a){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],l;try{for(;(a===void 0||a-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){l={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(l)throw l.error}}return s}function __spread(){for(var e=[],a=0;a{if(a===e)return;localStorage.setItem("selectedTheme",e),document.documentElement.dataset.theme=e,animateAllElements()});function animateAllElements(){const e=document.querySelectorAll("*");e.forEach(a=>{a.classList.add("changing-theme")}),document.documentElement.addEventListener("transitionend",function a(){e.forEach(n=>{n.classList.remove("changing-theme")}),document.documentElement.removeEventListener("transitionend",a)})}const useTheme=()=>({THEMES,currentTheme});var deemixIcon=`\r + A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`,e));var w=function(C,R){d(),n(C,R,o)},x=u(w);if(r.immediate){var A=x,M=function(C,R){M=A,w(C,R)};x=function(C,R){M(C,R)}}var D=e.$watch(k,x,{immediate:r.immediate,deep:y,sync:l}),T=e._watchers[e._watchers.length-1];return isReactive(T.value)&&((i=T.value.__ob__)===null||i===void 0?void 0:i.dep)&&y&&T.value.__ob__.dep.addSub({update:function(){T.run()}}),patchWatcherTeardown(T,d),function(){D()}}function watch(e,a,n){var r=null;typeof a=="function"?r=a:(n=a,r=null);var i=getWatcherOption(n),s=getWatcherVM();return createWatcher$1(s,e,r,i)}function computed(e){var a,n=(a=getCurrentInstance())===null||a===void 0?void 0:a.proxy,r,i;typeof e=="function"?r=e:(r=e.get,i=e.set);var s,l;if(n&&!n.$isServer){var c=getVueInternalClasses(),o=c.Watcher,d=c.Dep,u;l=function(){return u||(u=new o(n,r,noopFn,{lazy:!0})),u.dirty&&u.evaluate(),d.target&&u.depend(),u.value},s=function(h){i&&i(h)}}else{var f=defineComponentInstance(getVueConstructor(),{computed:{$$state:{get:r,set:i}}});n&&n.$on("hook:destroyed",function(){return f.$destroy()}),l=function(){return f.$$state},s=function(h){f.$$state=h}}return createRef({get:l,set:s})}function set$1(e,a,n){var r=e.__composition_api_state__=e.__composition_api_state__||{};r[a]=n}function get(e,a){return(e.__composition_api_state__||{})[a]}var vmStateManager={set:set$1,get};function asVmProperty(e,a,n){var r=e.$options.props;!(a in e)&&!(r&&hasOwn$1(r,a))&&(isRef(n)?proxy$1(e,a,{get:function(){return n.value},set:function(i){n.value=i}}):e[a]=n)}function updateTemplateRef(e){var a=vmStateManager.get(e,"rawBindings")||{};if(!a||!Object.keys(a).length)return;for(var n=e.$refs,r=vmStateManager.get(e,"refs")||[],i=0;i{if(a===e)return;localStorage.setItem("selectedTheme",e),document.documentElement.dataset.theme=e,animateAllElements()});function animateAllElements(){const e=document.querySelectorAll("*");e.forEach(a=>{a.classList.add("changing-theme")}),document.documentElement.addEventListener("transitionend",function a(){e.forEach(n=>{n.classList.remove("changing-theme")}),document.documentElement.removeEventListener("transitionend",a)})}const useTheme=()=>({THEMES,currentTheme});var deemixIcon=`\r \r \r \r @@ -2939,7 +2939,7 @@ PERFORMANCE OF THIS SOFTWARE. `)]),e._v(" "),n("p",{staticClass:"mb-2 text-base"},[e._v("For security reasons you will need to provide your own Client ID and Secret")]),e._v(" "),n("h2",{staticClass:"mt-6 text-3xl"},[e._v("How do I get my Client ID and Secret?")]),e._v(" "),e._m(0),e._v(" "),e._m(1),e._v(" "),e._m(2),e._v(" "),e._m(3),e._v(" "),n("p",{staticClass:"mb-2 text-base"},[e._v("Now you can copy-paste those results in the appropriate fields in the settings.")]),e._v(" "),n("h2",{staticClass:"mt-6 text-3xl"},[e._v("How do I get my Spotify Username?")]),e._v(" "),e._m(4)])},__vue_staticRenderFns__$c=[function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v("Connect to "),n("a",{attrs:{href:"https://developer.spotify.com/dashboard",target:"_blank"}},[e._v("Spotify for Developers's Dashboard")]),e._v(" and login with your Spotify account.")])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v(` Click on "Create an App".`),n("br"),e._v(" "),n("img",{attrs:{src:"https://i.imgur.com/YFz7rHj.png",alt:"Create an App button on Spotify for Developers's Dashboard"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v(` Fill out the "App name" and "App description" fields and check both checkboxes. Then click on the "Create" button.`),n("br"),e._v(" "),n("img",{attrs:{src:"https://i.imgur.com/A9cvDkK.png",alt:"Create an app form"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v(` - Now you can see the Client ID. If you click on "Show Client Secret" the client secret will be revealed.`),n("br"),e._v(" "),n("img",{attrs:{src:"https://i.imgur.com/foEfIhO.png",alt:"Screen of client ID and Secret"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v("You can get your Spotify Username from the "),n("a",{attrs:{href:"https://www.spotify.com/it/account/overview/",target:"_blank"}},[e._v("Overview page on Spotify's Website")]),e._v(".")])}];const __vue_inject_styles__$c=void 0,__vue_scope_id__$c=void 0,__vue_is_functional_template__$c=!1;function __vue_normalize__$c(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="InfoSpotifyFeatures.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var InfoSpotifyFeatures=__vue_normalize__$c({render:__vue_render__$c,staticRenderFns:__vue_staticRenderFns__$c},__vue_inject_styles__$c,__vue_script__$a,__vue_scope_id__$c,__vue_is_functional_template__$c),freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto=Object.prototype,hasOwnProperty$2=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag(e){var a=hasOwnProperty$2.call(e,symToStringTag),n=e[symToStringTag];try{e[symToStringTag]=void 0;var r=!0}catch(s){}var i=nativeObjectToString.call(e);return r&&(a?e[symToStringTag]=n:delete e[symToStringTag]),i}var objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;function objectToString(e){return nativeObjectToString$1.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function baseGetTag(e){return e==null?e===void 0?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return e!=null&&typeof e=="object"}var symbolTag="[object Symbol]";function isSymbol(e){return typeof e=="symbol"||isObjectLike(e)&&baseGetTag(e)==symbolTag}function arrayMap(e,a){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n-1}var MAX_SAFE_INTEGER=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,a){var n=typeof e;return a=a??MAX_SAFE_INTEGER,!!a&&(n=="number"||n!="symbol"&&reIsUint.test(e))&&(e>-1&&e%1==0)&&e-1&&e%1==0&&e<=MAX_SAFE_INTEGER$1}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction$2(e)}var objectProto$3=Object.prototype;function isPrototype(e){var a=e&&e.constructor,n=typeof a=="function"&&a.prototype||objectProto$3;return e===n}function baseTimes(e,a){for(var n=-1,r=Array(e);++n-1}function listCacheSet(e,a){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,a])):n[r][1]=a,this}function ListCache(e){var a=-1,n=e==null?0:e.length;for(this.clear();++ac))return!1;var d=s.get(e);if(d&&s.get(a))return d==a;var u=-1,f=!0,h=n&COMPARE_UNORDERED_FLAG?new SetCache:void 0;for(s.set(e,a),s.set(a,e);++u=a||C<0||f&&R>=s}function w(){var T=now();if(k(T))return x(T);c=setTimeout(w,y(T))}function x(T){return c=void 0,h&&r?m(T):(r=i=void 0,l)}function A(){c!==void 0&&clearTimeout(c),d=0,r=o=i=c=void 0}function M(){return c===void 0?l:x(now())}function D(){var T=now(),C=k(T);if(r=arguments,i=this,o=T,C){if(c===void 0)return v(o);if(f)return clearTimeout(c),c=setTimeout(w,a),m(o)}return c===void 0&&(c=setTimeout(w,a)),l}return D.cancel=A,D.flush=M,D}function arrayIncludesWith(e,a,n){for(var r=-1,i=e==null?0:e.length;++ra||s&&l&&o&&!c&&!d||r&&l&&o||!n&&o||!i)return 1;if(!r&&!s&&!d&&e=c)return o;var d=n[r];return o*(d=="desc"?-1:1)}}return e.index-a.index}function baseOrderBy(e,a,n){var r=-1;a=arrayMap(a.length?a:[identity$1],baseUnary(baseIteratee));var i=baseMap(e,function(s,l,c){var o=arrayMap(a,function(d){return d(s)});return{criteria:o,index:++r,value:s}});return baseSortBy(i,function(s,l){return compareMultiple(s,l,n)})}function orderBy(e,a,n,r){return e==null?[]:(isArray$2(a)||(a=a==null?[]:[a]),n=r?void 0:n,isArray$2(n)||(n=n==null?[]:[n]),baseOrderBy(e,a,n))}var INFINITY$2=1/0,createSet=Set$1&&1/setToArray(new Set$1([,-0]))[1]==INFINITY$2?function(e){return new Set$1(e)}:noop$2,LARGE_ARRAY_SIZE$1=200;function baseUniq(e,a,n){var r=-1,i=arrayIncludes,s=e.length,l=!0,c=[],o=c;if(n)l=!1,i=arrayIncludesWith;else if(s>=LARGE_ARRAY_SIZE$1){var d=a?null:createSet(e);if(d)return setToArray(d);l=!1,i=cacheHas,o=new SetCache}else o=a?[]:c;e:for(;++r{socket.on("show_artist",r=>{socket.off("show_artist"),a(r)})})}function standardizeData(e,a){if(e.hasLoaded){const{data:n}=e,r=[];for(const i of n){let s=a(i);r.push(s)}return{data:r,hasLoaded:e.hasLoaded}}else return null}var script$b=defineComponent({components:{BaseTabs,BaseTab},setup(e,a){const n=reactive({currentTab:"",sortKey:"releaseDate",sortOrder:"desc",artistReleases:{},artistName:"",artistPicture:"",currentRelease:computed(()=>n.artistReleases[n.currentTab])}),r=computed(()=>a.root.$router.currentRoute.params.id),i=ref$2(!1);getArtistData(unref(r)).then(l=>{i.value=!0;const c={data:[l],hasLoaded:unref(i)},{data:[{artistName:o,artistPictureXL:d,artistReleases:u}]}=standardizeData(c,formatArtistData);Object.assign(n,{artistName:o,artistPicture:d,artistReleases:u,currentTab:Object.keys(u)[0]})}).catch(l=>console.error(l));const s=computed(()=>{if(!unref(i))return[];let l=n.sortKey;return l==="releaseTracksNumber"&&(l=c=>new Number(c.releaseTracksNumber)),orderBy(n.currentRelease,l,n.sortOrder)});return{...toRefs(n),downloadLink:computed(()=>`https://www.deezer.com/artist/${unref(r)}`),headerStyle:computed(()=>({backgroundImage:`linear-gradient(to bottom, transparent 0%, var(--main-background) 100%), url(${n.artistPicture})`})),sortedData:s,sendAddToQueue,checkNewRelease}},data(){const e=this.$t.bind(this),a=this.$tc.bind(this);return{head:[{title:a("globals.listTabs.title",1),sortKey:"releaseTitle"},{title:e("globals.listTabs.releaseDate"),sortKey:"releaseDate"},{title:a("globals.listTabs.track",2),sortKey:"releaseTracksNumber"},{title:"",width:null}]}},methods:{sortBy(e){e===this.sortKey?this.sortOrder=this.sortOrder==="asc"?"desc":"asc":(this.sortKey=e,this.sortOrder="asc")}}});const __vue_script__$b=script$b;var __vue_render__$d=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{staticClass:"relative image-header"},[n("header",{staticClass:"flex items-center",style:e.headerStyle},[n("h1",{staticClass:"m-0"},[e._v(e._s(e.artistName))]),e._v(" "),n("div",{staticClass:"grid w-16 h-16 ml-auto rounded-full cursor-pointer bg-primary text-grayscale-870 place-items-center",attrs:{"aria-label":"download",role:"button","data-cm-link":e.downloadLink},on:{click:function(r){return r.stopPropagation(),e.sendAddToQueue(e.downloadLink)}}},[n("i",{staticClass:"text-4xl material-icons",attrs:{title:e.$t("globals.download_hint")}},[e._v("get_app")])])]),e._v(" "),n("BaseTabs",e._l(e.artistReleases,function(r,i){return n("BaseTab",{key:i,class:{active:e.currentTab===i},on:{click:function(s){e.currentTab=i}}},[e._v(` + Now you can see the Client ID. If you click on "Show Client Secret" the client secret will be revealed.`),n("br"),e._v(" "),n("img",{attrs:{src:"https://i.imgur.com/foEfIhO.png",alt:"Screen of client ID and Secret"}})])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("p",{staticClass:"mb-2 text-base"},[e._v("You can get your Spotify Username from the "),n("a",{attrs:{href:"https://www.spotify.com/it/account/overview/",target:"_blank"}},[e._v("Overview page on Spotify's Website")]),e._v(".")])}];const __vue_inject_styles__$c=void 0,__vue_scope_id__$c=void 0,__vue_is_functional_template__$c=!1;function __vue_normalize__$c(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="InfoSpotifyFeatures.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var InfoSpotifyFeatures=__vue_normalize__$c({render:__vue_render__$c,staticRenderFns:__vue_staticRenderFns__$c},__vue_inject_styles__$c,__vue_script__$a,__vue_scope_id__$c,__vue_is_functional_template__$c),freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto=Object.prototype,hasOwnProperty$2=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag(e){var a=hasOwnProperty$2.call(e,symToStringTag),n=e[symToStringTag];try{e[symToStringTag]=void 0;var r=!0}catch(s){}var i=nativeObjectToString.call(e);return r&&(a?e[symToStringTag]=n:delete e[symToStringTag]),i}var objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;function objectToString(e){return nativeObjectToString$1.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function baseGetTag(e){return e==null?e===void 0?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return e!=null&&typeof e=="object"}var symbolTag="[object Symbol]";function isSymbol(e){return typeof e=="symbol"||isObjectLike(e)&&baseGetTag(e)==symbolTag}function arrayMap(e,a){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n-1}var MAX_SAFE_INTEGER=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,a){var n=typeof e;return a=a??MAX_SAFE_INTEGER,!!a&&(n=="number"||n!="symbol"&&reIsUint.test(e))&&(e>-1&&e%1==0)&&e-1&&e%1==0&&e<=MAX_SAFE_INTEGER$1}function isArrayLike(e){return e!=null&&isLength(e.length)&&!isFunction$2(e)}var objectProto$3=Object.prototype;function isPrototype(e){var a=e&&e.constructor,n=typeof a=="function"&&a.prototype||objectProto$3;return e===n}function baseTimes(e,a){for(var n=-1,r=Array(e);++n-1}function listCacheSet(e,a){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,a])):n[r][1]=a,this}function ListCache(e){var a=-1,n=e==null?0:e.length;for(this.clear();++ac))return!1;var d=s.get(e);if(d&&s.get(a))return d==a;var u=-1,f=!0,h=n&COMPARE_UNORDERED_FLAG?new SetCache:void 0;for(s.set(e,a),s.set(a,e);++u=a||C<0||f&&R>=s}function w(){var T=now();if(k(T))return x(T);c=setTimeout(w,y(T))}function x(T){return c=void 0,h&&r?m(T):(r=i=void 0,l)}function A(){c!==void 0&&clearTimeout(c),d=0,r=o=i=c=void 0}function M(){return c===void 0?l:x(now())}function D(){var T=now(),C=k(T);if(r=arguments,i=this,o=T,C){if(c===void 0)return v(o);if(f)return clearTimeout(c),c=setTimeout(w,a),m(o)}return c===void 0&&(c=setTimeout(w,a)),l}return D.cancel=A,D.flush=M,D}function arrayIncludesWith(e,a,n){for(var r=-1,i=e==null?0:e.length;++ra||s&&l&&o&&!c&&!d||r&&l&&o||!n&&o||!i)return 1;if(!r&&!s&&!d&&e=c)return o;var d=n[r];return o*(d=="desc"?-1:1)}}return e.index-a.index}function baseOrderBy(e,a,n){var r=-1;a=arrayMap(a.length?a:[identity$1],baseUnary(baseIteratee));var i=baseMap(e,function(s,l,c){var o=arrayMap(a,function(d){return d(s)});return{criteria:o,index:++r,value:s}});return baseSortBy(i,function(s,l){return compareMultiple(s,l,n)})}function orderBy(e,a,n,r){return e==null?[]:(isArray$2(a)||(a=a==null?[]:[a]),n=r?void 0:n,isArray$2(n)||(n=n==null?[]:[n]),baseOrderBy(e,a,n))}var INFINITY$2=1/0,createSet=Set$1&&1/setToArray(new Set$1([,-0]))[1]==INFINITY$2?function(e){return new Set$1(e)}:noop$2,LARGE_ARRAY_SIZE$1=200;function baseUniq(e,a,n){var r=-1,i=arrayIncludes,s=e.length,l=!0,c=[],o=c;if(n)l=!1,i=arrayIncludesWith;else if(s>=LARGE_ARRAY_SIZE$1){var d=a?null:createSet(e);if(d)return setToArray(d);l=!1,i=cacheHas,o=new SetCache}else o=a?[]:c;e:for(;++r{socket.on("show_artist",r=>{socket.off("show_artist"),a(r)})})}function standardizeData(e,a){if(e.hasLoaded){const{data:n}=e,r=[];for(const i of n){let s=a(i);r.push(s)}return{data:r,hasLoaded:e.hasLoaded}}else return null}var script$b=defineComponent({components:{BaseTabs,BaseTab},setup(e,a){const n=reactive({currentTab:"",sortKey:"releaseDate",sortOrder:"desc",artistReleases:{},artistName:"",artistPicture:"",currentRelease:computed(()=>n.artistReleases[n.currentTab])}),r=computed(()=>a.root.$router.currentRoute.params.id),i=ref$2(!1);getArtistData(unref(r)).then(l=>{i.value=!0;const c={data:[l],hasLoaded:unref(i)},{data:[{artistName:o,artistPictureXL:d,artistReleases:u}]}=standardizeData(c,formatArtistData);Object.assign(n,{artistName:o,artistPicture:d,artistReleases:u,currentTab:Object.keys(u)[0]})}).catch(l=>console.error(l));const s=computed(()=>{if(!unref(i))return[];let l=n.sortKey;return l==="releaseTracksNumber"&&(l=c=>new Number(c.releaseTracksNumber)),orderBy(n.currentRelease,l,n.sortOrder)});return{...toRefs(n),downloadLink:computed(()=>`https://www.deezer.com/artist/${unref(r)}`),headerStyle:computed(()=>({backgroundImage:`linear-gradient(to bottom, transparent 0%, var(--main-background) 100%), url(${n.artistPicture})`})),sortedData:s,sendAddToQueue,checkNewRelease}},data(){const e=this.$t.bind(this),a=this.$tc.bind(this);return{head:[{title:a("globals.listTabs.title",1),sortKey:"releaseTitle"},{title:e("globals.listTabs.releaseDate"),sortKey:"releaseDate"},{title:a("globals.listTabs.track",2),sortKey:"releaseTracksNumber"},{title:"",width:null}]}},methods:{sortBy(e){e===this.sortKey?this.sortOrder=this.sortOrder==="asc"?"desc":"asc":(this.sortKey=e,this.sortOrder="asc")}}});const __vue_script__$b=script$b;var __vue_render__$d=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("div",{staticClass:"relative image-header"},[n("header",{staticClass:"flex items-center",style:e.headerStyle},[n("h1",{staticClass:"m-0"},[e._v(e._s(e.artistName))]),e._v(" "),n("div",{staticClass:"grid w-16 h-16 ml-auto rounded-full cursor-pointer bg-primary text-grayscale-870 place-items-center",attrs:{"aria-label":"download",role:"button","data-cm-link":e.downloadLink},on:{click:function(r){return r.stopPropagation(),e.sendAddToQueue(e.downloadLink)}}},[n("i",{staticClass:"text-4xl material-icons",attrs:{title:e.$t("globals.download_hint")}},[e._v("get_app")])])]),e._v(" "),n("BaseTabs",e._l(e.artistReleases,function(r,i){return n("BaseTab",{key:i,class:{active:e.currentTab===i},on:{click:function(s){e.currentTab=i}}},[e._v(` `+e._s(e.$tc("globals.listTabs."+i,2))+` `)])}),1),e._v(" "),n("table",{staticClass:"table"},[n("thead",[n("tr",e._l(e.head,function(r){return n("th",{key:r.title,staticClass:"uppercase-first-letter",class:{"sort-asc":r.sortKey===e.sortKey&&e.sortOrder=="asc","sort-desc":r.sortKey===e.sortKey&&e.sortOrder=="desc",sortable:r.sortKey,clickable:r.sortKey},style:{width:r.width?r.width:"auto"},on:{click:function(i){r.sortKey&&e.sortBy(r.sortKey)}}},[e._v(` `+e._s(r.title)+` @@ -3040,7 +3040,7 @@ PERFORMANCE OF THIS SOFTWARE. `+e._s(e.$t("globals.by",{artist:r.artistName})+" - "+e.$tc("globals.listTabs.trackN",r.playlistTracksNumber))+` `)])],1)}),0)]],2)},__vue_staticRenderFns__$p=[];const __vue_inject_styles__$p=void 0,__vue_scope_id__$p=void 0,__vue_is_functional_template__$p=!1;function __vue_normalize__$p(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="ResultsPlaylists.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var ResultsPlaylists=__vue_normalize__$p({render:__vue_render__$p,staticRenderFns:__vue_staticRenderFns__$p},__vue_inject_styles__$p,__vue_script__$n,__vue_scope_id__$p,__vue_is_functional_template__$p),script$o={components:{TopResult,ResultsTracks,ResultsAlbums,ResultsArtists,ResultsPlaylists},props:{viewInfo:{type:Object,required:!1}},computed:{thereAreResults(){let e=!!this.viewInfo;if(!e)return!1;let a=this.viewInfo.ORDER.every(n=>n==="TOP_RESULT"?this.viewInfo[n].length===0:this.viewInfo[n].data.length===0);return!a}},methods:{convertDuration,upperCaseFirstLowerCaseRest,standardizeData,formatSingleTrack,formatAlbums,formatArtist,formatPlaylist,checkSectionResults(e){return e==="TOP_RESULT"?!!this.viewInfo.TOP_RESULT[0]:!!this.viewInfo[e].data[0]}}};const __vue_script__$o=script$o;var __vue_render__$q=function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("section",[e.thereAreResults?e._l(e.viewInfo.ORDER,function(r){return n("section",{key:r,staticClass:"float-none py-5 border-t border-grayscale-500 first:border-t-0"},[e.checkSectionResults(r)?[n("h2",{staticClass:"mb-6 capitalize",class:{"text-4xl text-center":r==="TOP_RESULT","inline-block cursor-pointer text-3xl hover:text-primary transition-colors duration-200 ease-in-out":r!=="TOP_RESULT"},on:{click:function(i){return e.$emit("change-search-tab",r)}}},[e._v(` `+e._s(e.$tc("globals.listTabs."+r.toLowerCase(),2))+` - `)]),e._v(" "),r==="TOP_RESULT"?n("TopResult",{attrs:{info:e.viewInfo.TOP_RESULT[0]},on:{"add-to-queue":function(i){return e.$emit("add-to-queue",i)}}}):r==="TRACK"?n("ResultsTracks",{attrs:{viewInfo:e.standardizeData(e.viewInfo.TRACK,e.formatSingleTrack),itemsToShow:6},on:{"add-to-queue":function(i){return e.$emit("add-to-queue",i)}}}):r=="ALBUM"?n("ResultsAlbums",{attrs:{viewInfo:e.standardizeData(e.viewInfo.ALBUM,e.formatAlbums),itemsToShow:6},on:{"add-to-queue":function(i){return e.$emit("add-to-queue",i)}}}):r=="PLAYLIST"?n("ResultsPlaylists",{attrs:{viewInfo:e.standardizeData(e.viewInfo.PLAYLIST,e.formatPlaylist),itemsToShow:6},on:{"add-to-queue":function(i){return e.$emit("add-to-queue",i)}}}):r==="ARTIST"?n("ResultsArtists",{attrs:{viewInfo:e.standardizeData(e.viewInfo.ARTIST,e.formatArtist),itemsToShow:6},on:{"add-to-queue":function(i){return e.$emit("add-to-queue",i)}}}):e._e()]:e._e()],2)}):n("div",[n("h1",[e._v(e._s(e.$t("search.noResults")))])])],2)},__vue_staticRenderFns__$q=[];const __vue_inject_styles__$q=void 0,__vue_scope_id__$q=void 0,__vue_is_functional_template__$q=!1;function __vue_normalize__$q(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="ResultsAll.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var ResultsAll=__vue_normalize__$q({render:__vue_render__$q,staticRenderFns:__vue_staticRenderFns__$q},__vue_inject_styles__$q,__vue_script__$o,__vue_scope_id__$q,__vue_is_functional_template__$q);const searchResult=ref$2({});function performMainSearch(e){get("mainSearch",{term:e}).then(a=>{searchResult.value=a})}function useMainSearch(){return{searchResult,performMainSearch}}const result=ref$2({});function performSearch({term:e,type:a,start:n=0,nb:r=30}){get("search",{term:e,type:a,start:n,nb:r}).then(i=>{result.value=i})}function useSearch(){return{result,performSearch}}const resetObj={data:[],next:0,total:0,hasLoaded:!1},lastTab=ref$2(null);var script$p=defineComponent({components:{BaseLoadingPlaceholder,BaseTabs,BaseTab},props:{performScrolledSearch:{type:Boolean,required:!1}},setup(e,a){const n=reactive({currentTab:{name:"",searchType:"",component:{},viewInfo:"",formatFunc:()=>{}},results:{query:"",allTab:{ORDER:[],TOP_RESULT:[],ALBUM:{hasLoaded:!1},ARTIST:{hasLoaded:!1},TRACK:{hasLoaded:!1},PLAYLIST:{hasLoaded:!1}},trackTab:{...resetObj},albumTab:{...resetObj},artistTab:{...resetObj},playlistTab:{...resetObj}},tabs:[{name:a.root.$i18n.t("globals.listTabs.all"),searchType:"all",component:ResultsAll,viewInfo:"allTab"},{name:a.root.$i18n.tc("globals.listTabs.track",2),searchType:"track",component:ResultsTracks,viewInfo:"trackTab",formatFunc:formatSingleTrack},{name:a.root.$i18n.tc("globals.listTabs.album",2),searchType:"album",component:ResultsAlbums,viewInfo:"albumTab",formatFunc:formatAlbums},{name:a.root.$i18n.tc("globals.listTabs.artist",2),searchType:"artist",component:ResultsArtists,viewInfo:"artistTab",formatFunc:formatArtist},{name:a.root.$i18n.tc("globals.listTabs.playlist",2),searchType:"playlist",component:ResultsPlaylists,viewInfo:"playlistTab",formatFunc:formatPlaylist}]}),{searchResult:r,performMainSearch:i}=useMainSearch(),{result:s,performSearch:l}=useSearch(),c=computed(()=>a.root.$route.query.term),o=computed(()=>n.results.query===""),d=ref$2(!1),u=computed(()=>Object.keys(r.value).length!==0),f=computed(()=>r.value.QUERY!==c.value);u.value&&!f.value&&onMounted(()=>{h(r.value)}),c.value&&(!u.value||f.value)&&(i(c.value),d.value=!0);function h(m){d.value=!1,n.results.query=m.QUERY,n.results.allTab=m,n.results.allTab.TRACK.hasLoaded=!0,n.results.allTab.ALBUM.hasLoaded=!0,n.results.allTab.ARTIST.hasLoaded=!0,n.results.allTab.PLAYLIST.hasLoaded=!0,lastTab.value&&lastTab.value.searchType!=="all"?(n.currentTab=lastTab.value,l({term:m.QUERY,type:n.currentTab.searchType})):n.currentTab=n.tabs.find(v=>v.searchType==="all")}return watch(r,h),watch(s,m=>{const{next:v,total:y,type:k,data:w}=m,x=`${k}Tab`;let A=y;if(v&&(A=parseInt(v.match(/index=(\d*)/)[1])),n.results[x].total!==y&&(n.results[x].total=y),n.results[x].next!==A){n.results[x].next=A;const M=n.results[x].data.concat(w),D=uniqWith(M,(T,C)=>T.id===C.id);n.results[x].data=D}n.results[x].hasLoaded=!0}),n.currentTab=n.tabs.find(m=>m.searchType==="all"),{...toRefs(n),isSearching:d,isQueryEmpty:o,searchResult:r,performMainSearch:i,performSearch:l}},computed:{loadedTabs(){const e=[];for(const a in this.results)if(this.results.hasOwnProperty(a)&&a!=="query"){const n=this.results[a];n.hasLoaded&&e.push(a.replace(/Tab/g,""))}return e}},methods:{numberWithDots,convertDuration,addToQueue(e){sendAddToQueue(e.currentTarget.dataset.link)},getViewInfo(){return this.currentTab.searchType==="all"?this.results.allTab:standardizeData(this.results[this.currentTab.viewInfo],this.currentTab.formatFunc)},changeSearchTab(e){e=e.toLowerCase();const a=this.tabs.find(n=>n.searchType===e);if(!a){console.error(`No tab ${e} found`);return}window.scrollTo(0,0),this.currentTab=a,lastTab.value=a},scrolledSearch(){if(this.currentTab.searchType==="all")return;const e=`${this.currentTab.searchType}Tab`,a=this.results[e].next{searchResult.value=a})}function useMainSearch(){return{searchResult,performMainSearch}}const result=ref$2({});function performSearch({term:e,type:a,start:n=0,nb:r=30}){fetchApi("search",{term:e,type:a,start:n,nb:r}).then(i=>{result.value=i})}function useSearch(){return{result,performSearch}}const resetObj={data:[],next:0,total:0,hasLoaded:!1},lastTab=ref$2(null);var script$p=defineComponent({components:{BaseLoadingPlaceholder,BaseTabs,BaseTab},props:{performScrolledSearch:{type:Boolean,required:!1}},setup(e,a){const n=reactive({currentTab:{name:"",searchType:"",component:{},viewInfo:"",formatFunc:()=>{}},results:{query:"",allTab:{ORDER:[],TOP_RESULT:[],ALBUM:{hasLoaded:!1},ARTIST:{hasLoaded:!1},TRACK:{hasLoaded:!1},PLAYLIST:{hasLoaded:!1}},trackTab:{...resetObj},albumTab:{...resetObj},artistTab:{...resetObj},playlistTab:{...resetObj}},tabs:[{name:a.root.$i18n.t("globals.listTabs.all"),searchType:"all",component:ResultsAll,viewInfo:"allTab"},{name:a.root.$i18n.tc("globals.listTabs.track",2),searchType:"track",component:ResultsTracks,viewInfo:"trackTab",formatFunc:formatSingleTrack},{name:a.root.$i18n.tc("globals.listTabs.album",2),searchType:"album",component:ResultsAlbums,viewInfo:"albumTab",formatFunc:formatAlbums},{name:a.root.$i18n.tc("globals.listTabs.artist",2),searchType:"artist",component:ResultsArtists,viewInfo:"artistTab",formatFunc:formatArtist},{name:a.root.$i18n.tc("globals.listTabs.playlist",2),searchType:"playlist",component:ResultsPlaylists,viewInfo:"playlistTab",formatFunc:formatPlaylist}]}),{searchResult:r,performMainSearch:i}=useMainSearch(),{result:s,performSearch:l}=useSearch(),c=computed(()=>a.root.$route.query.term),o=computed(()=>n.results.query===""),d=ref$2(!1),u=computed(()=>Object.keys(r.value).length!==0),f=computed(()=>r.value.QUERY!==c.value);u.value&&!f.value&&onMounted(()=>{h(r.value)}),c.value&&(!u.value||f.value)&&(i(c.value),d.value=!0);function h(m){d.value=!1,n.results.query=m.QUERY,n.results.allTab=m,n.results.allTab.TRACK.hasLoaded=!0,n.results.allTab.ALBUM.hasLoaded=!0,n.results.allTab.ARTIST.hasLoaded=!0,n.results.allTab.PLAYLIST.hasLoaded=!0,lastTab.value&&lastTab.value.searchType!=="all"?(n.currentTab=lastTab.value,l({term:m.QUERY,type:n.currentTab.searchType})):n.currentTab=n.tabs.find(v=>v.searchType==="all")}return watch(r,h),watch(s,m=>{const{next:v,total:y,type:k,data:w}=m,x=`${k}Tab`;let A=y;if(v&&(A=parseInt(v.match(/index=(\d*)/)[1])),n.results[x].total!==y&&(n.results[x].total=y),n.results[x].next!==A){n.results[x].next=A;const M=n.results[x].data.concat(w),D=uniqWith(M,(T,C)=>T.id===C.id);n.results[x].data=D}n.results[x].hasLoaded=!0}),n.currentTab=n.tabs.find(m=>m.searchType==="all"),{...toRefs(n),isSearching:d,isQueryEmpty:o,searchResult:r,performMainSearch:i,performSearch:l}},computed:{loadedTabs(){const e=[];for(const a in this.results)if(this.results.hasOwnProperty(a)&&a!=="query"){const n=this.results[a];n.hasLoaded&&e.push(a.replace(/Tab/g,""))}return e}},methods:{numberWithDots,convertDuration,addToQueue(e){sendAddToQueue(e.currentTarget.dataset.link)},getViewInfo(){return this.currentTab.searchType==="all"?this.results.allTab:standardizeData(this.results[this.currentTab.viewInfo],this.currentTab.formatFunc)},changeSearchTab(e){e=e.toLowerCase();const a=this.tabs.find(n=>n.searchType===e);if(!a){console.error(`No tab ${e} found`);return}window.scrollTo(0,0),this.currentTab=a,lastTab.value=a},scrolledSearch(){if(this.currentTab.searchType==="all")return;const e=`${this.currentTab.searchType}Tab`,a=this.results[e].next @@ -4827,5 +4827,5 @@ PERFORMANCE OF THIS SOFTWARE. `)]),e._v(" "),n("td",[e._v(e._s(r.artists[0].name))]),e._v(" "),n("td",[e._v(e._s(r.album.name))]),e._v(" "),n("td",[e._v(e._s(e.convertDuration(Math.floor(r.duration_ms/1e3))))]),e._v(" "),n("td",[n("input",{directives:[{name:"model",rawName:"v-model",value:r.selected,expression:"track.selected"}],staticClass:"clickable",attrs:{type:"checkbox"},domProps:{checked:Array.isArray(r.selected)?e._i(r.selected,null)>-1:r.selected},on:{change:function(s){var l=r.selected,c=s.target,o=!!c.checked;if(Array.isArray(l)){var d=null,u=e._i(l,d);c.checked?u<0&&e.$set(r,"selected",l.concat([d])):u>-1&&e.$set(r,"selected",l.slice(0,u).concat(l.slice(u+1)))}else e.$set(r,"selected",o)}}})])])})],2)]),e._v(" "),e.label?n("span",{staticStyle:{opacity:"0.4","margin-top":"8px",display:"inline-block","font-size":"13px"}},[e._v(e._s(e.label))]):e._e(),e._v(" "),n("footer",{staticClass:"bg-background-main"},[n("button",{staticClass:"mr-2 btn btn-primary",attrs:{"data-link":e.link},on:{click:function(r){return r.stopPropagation(),e.addToQueue(r)}}},[e._v(` `+e._s(""+e.$t("globals.download",{thing:e.$tc("globals.listTabs."+e.type,1)}))+` `)]),e._v(" "),n("button",{staticClass:"flex items-center btn btn-primary",attrs:{"data-link":e.selectedLinks()},on:{click:function(r){return r.stopPropagation(),e.addToQueue(r)}}},[e._v(` - `+e._s(e.$t("tracklist.downloadSelection"))),n("i",{staticClass:"ml-2 material-icons"},[e._v("file_download")])])])])},__vue_staticRenderFns__$v=[function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("th",[n("i",{staticClass:"material-icons"},[e._v("music_note")])])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("th",[n("i",{staticClass:"material-icons"},[e._v("timer")])])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("td",[n("div",{staticClass:"table__cell-content table__cell-content--vertical-center",staticStyle:{opacity:"0.54"}},[n("i",{staticClass:"material-icons"},[e._v("album")])])])}];const __vue_inject_styles__$v=void 0,__vue_scope_id__$v=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="Tracklist.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var Tracklist=__vue_normalize__$v({render:__vue_render__$v,staticRenderFns:__vue_staticRenderFns__$v},__vue_inject_styles__$v,__vue_script__$t,__vue_scope_id__$v,__vue_is_functional_template__$v);Vue.use(VueRouter);const routes=[{path:window.location.pathname,name:"Home",component:Home,meta:{notKeepAlive:!0}},{path:"/tracklist/:type/:id",name:"Tracklist",component:Tracklist},{path:"/artist/:id",name:"Artist",component:Artist,meta:{notKeepAlive:!0}},{path:"/album/:id",name:"Album",component:Tracklist},{path:"/playlist/:id",name:"Playlist",component:Tracklist},{path:"/spotify-playlist/:id",name:"Spotify Playlist",component:Tracklist},{path:"/charts",name:"Charts",component:Charts,meta:{notKeepAlive:!0}},{path:"/favorites",name:"Favorites",component:Favorites,meta:{notKeepAlive:!0}},{path:"/errors",name:"Errors",component:Errors},{path:"/link-analyzer",name:"Link Analyzer",component:LinkAnalyzer},{path:"/info-arl",name:"ARL",component:InfoArl},{path:"/info-spotify",name:"Spotify Features",component:InfoSpotifyFeatures},{path:"/settings",name:"Settings",component:Settings},{path:"/search",name:"Search",component:Search,meta:{notKeepAlive:!0}},{path:"*",component:Home}],router=new VueRouter({mode:"history",routes,scrollBehavior(e,a,n){return{x:0,y:0}}});router.beforeEach((e,a,n)=>{let r=null;switch(e.name){case"Tracklist":r={type:e.params.type,id:e.params.id};break;case"Album":r={type:"album",id:e.params.id};break;case"Playlist":r={type:"playlist",id:e.params.id};break;case"Spotify Playlist":r={type:"spotifyplaylist",id:e.params.id};break}r&&socket.emit("getTracklist",r),n()});function startApp(){new Vue({store,router,i18n,render:e=>e(App)}).$mount("#app"),fetch("connect").then(e=>e.json()).then(e=>{if(store.dispatch("setAppInfo",e.update),e.autologin){console.log("Autologin");let a=localStorage.getItem("arl"),n=localStorage.getItem("accountNum");if(a){a=a.trim();let r;n!=0?r=get("login",{arl:a,force:!0,child:n||0}):r=get("login",{arl:a}),r.then(loggedIn)}}})}function initClient(){store.dispatch("setClientMode",!0),setClientModeKeyBindings()}document.addEventListener("DOMContentLoaded",startApp),window.addEventListener("pywebviewready",initClient),document.addEventListener("paste",e=>{if(e.target.localName==="input")return;let a=e.clipboardData.getData("Text");if(isValidURL(a))router.currentRoute.name==="Link Analyzer"?socket.emit("analyzeLink",a):(a.indexOf(` + `+e._s(e.$t("tracklist.downloadSelection"))),n("i",{staticClass:"ml-2 material-icons"},[e._v("file_download")])])])])},__vue_staticRenderFns__$v=[function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("th",[n("i",{staticClass:"material-icons"},[e._v("music_note")])])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("th",[n("i",{staticClass:"material-icons"},[e._v("timer")])])},function(){var e=this,a=e.$createElement,n=e._self._c||a;return n("td",[n("div",{staticClass:"table__cell-content table__cell-content--vertical-center",staticStyle:{opacity:"0.54"}},[n("i",{staticClass:"material-icons"},[e._v("album")])])])}];const __vue_inject_styles__$v=void 0,__vue_scope_id__$v=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,r,i,s,l,c){const o=(typeof n=="function"?n.options:n)||{};return o.__file="Tracklist.vue",o.render||(o.render=e.render,o.staticRenderFns=e.staticRenderFns,o._compiled=!0,i&&(o.functional=!0)),o._scopeId=r,o}var Tracklist=__vue_normalize__$v({render:__vue_render__$v,staticRenderFns:__vue_staticRenderFns__$v},__vue_inject_styles__$v,__vue_script__$t,__vue_scope_id__$v,__vue_is_functional_template__$v);Vue.use(VueRouter);const routes=[{path:window.location.pathname,name:"Home",component:Home,meta:{notKeepAlive:!0}},{path:"/tracklist/:type/:id",name:"Tracklist",component:Tracklist},{path:"/artist/:id",name:"Artist",component:Artist,meta:{notKeepAlive:!0}},{path:"/album/:id",name:"Album",component:Tracklist},{path:"/playlist/:id",name:"Playlist",component:Tracklist},{path:"/spotify-playlist/:id",name:"Spotify Playlist",component:Tracklist},{path:"/charts",name:"Charts",component:Charts,meta:{notKeepAlive:!0}},{path:"/favorites",name:"Favorites",component:Favorites,meta:{notKeepAlive:!0}},{path:"/errors",name:"Errors",component:Errors},{path:"/link-analyzer",name:"Link Analyzer",component:LinkAnalyzer},{path:"/info-arl",name:"ARL",component:InfoArl},{path:"/info-spotify",name:"Spotify Features",component:InfoSpotifyFeatures},{path:"/settings",name:"Settings",component:Settings},{path:"/search",name:"Search",component:Search,meta:{notKeepAlive:!0}},{path:"*",component:Home}],router=new VueRouter({mode:"history",routes,scrollBehavior(e,a,n){return{x:0,y:0}}});router.beforeEach((e,a,n)=>{let r=null;switch(e.name){case"Tracklist":r={type:e.params.type,id:e.params.id};break;case"Album":r={type:"album",id:e.params.id};break;case"Playlist":r={type:"playlist",id:e.params.id};break;case"Spotify Playlist":r={type:"spotifyplaylist",id:e.params.id};break}r&&socket.emit("getTracklist",r),n()});async function startApp(){new Vue({store,router,i18n,render:a=>a(App)}).$mount("#app");const e=await(await fetch("connect")).json();if(store.dispatch("setAppInfo",e.update),e.autologin){console.info("Autologin successful");let a=localStorage.getItem("arl");const n=localStorage.getItem("accountNum");if(a){a=a.trim();let r;n!==0?r=fetchApi("login",{arl:a,force:!0,child:n||0}):r=fetchApi("login",{arl:a}),r.then(loggedIn)}}}function initClient(){store.dispatch("setClientMode",!0),setClientModeKeyBindings()}document.addEventListener("DOMContentLoaded",startApp),window.addEventListener("pywebviewready",initClient),document.addEventListener("paste",e=>{if(e.target.localName==="input")return;let a=e.clipboardData.getData("Text");if(isValidURL(a))router.currentRoute.name==="Link Analyzer"?socket.emit("analyzeLink",a):(a.indexOf(` `)!=-1&&(a=a.replace(/\n/g,";")),sendAddToQueue(a));else{let n=document.querySelector("#searchbar");n.select(),n.setSelectionRange(0,99999)}});function setClientModeKeyBindings(){document.addEventListener("keyup",e=>{e.altKey&&e.key==="ArrowLeft"&&router.back(),e.altKey&&e.key==="ArrowRight"&&router.forward()})}socket.on("message",function(e){console.log(e)});function loggedIn(e){const{status:a,user:n}=e;switch(a){case 1:case 3:toast(i18n.t("toasts.loggedIn"),"done",!0,"login-toast"),store.dispatch("login",e);break;case 2:toast(i18n.t("toasts.alreadyLogged"),"done",!0,"login-toast"),store.dispatch("setUser",n);break;case 0:toast(i18n.t("toasts.loginFailed"),"close",!0,"login-toast"),store.dispatch("removeARL");break;case-1:toast(i18n.t("toasts.deezerNotAvailable"),"close",!0,"login-toast");return}}socket.on("restoringQueue",function(){toast(i18n.t("toasts.restoringQueue"),"loading",!1,"restoring_queue")}),socket.on("cancellingCurrentItem",function(e){toast(i18n.t("toasts.cancellingCurrentItem"),"loading",!1,"cancelling_"+e)}),socket.on("currentItemCancelled",function(e){toast(i18n.t("toasts.currentItemCancelled"),"done",!0,"cancelling_"+e)}),socket.on("startAddingArtist",function(e){toast(i18n.t("toasts.startAddingArtist",{artist:e.name}),"loading",!1,"artist_"+e.id)}),socket.on("finishAddingArtist",function(e){toast(i18n.t("toasts.finishAddingArtist",{artist:e.name}),"done",!0,"artist_"+e.id)}),socket.on("startConvertingSpotifyPlaylist",function(e){toast(i18n.t("toasts.startConvertingSpotifyPlaylist"),"loading",!1,"spotifyplaylist_"+e)}),socket.on("finishConvertingSpotifyPlaylist",function(e){toast(i18n.t("toasts.finishConvertingSpotifyPlaylist"),"done",!0,"spotifyplaylist_"+e)}),socket.on("errorMessage",function(e){toast(e,"error")}),socket.on("queueError",function(e){e.errid?toast(e.link+" - "+i18n.t(`errors.ids.${e.errid}`),"error"):toast(e.link+" - "+e.error,"error")}),socket.on("alreadyInQueue",function(e){toast(i18n.t("toasts.alreadyInQueue",{item:e.title}),"playlist_add_check")}),socket.on("loginNeededToDownload",function(e){toast(i18n.t("toasts.loginNeededToDownload"),"report")}),socket.on("startGeneratingItems",function(e){toast(i18n.t("toasts.startGeneratingItems",{n:e.total}),"loading",!1,"batch_"+e.uuid)}),socket.on("finishGeneratingItems",function(e){toast(i18n.t("toasts.finishGeneratingItems",{n:e.total}),"done",!0,"batch_"+e.uuid)}); diff --git a/src/app.js b/src/app.js index 1825583..a26873a 100644 --- a/src/app.js +++ b/src/app.js @@ -19,13 +19,13 @@ import router from '@/router' import store from '@/store' import { socket } from '@/utils/socket' -import { get } from '@/utils/api' +import { fetchApi } from '@/utils/api' import { toast } from '@/utils/toasts' import { isValidURL } from '@/utils/utils' import { sendAddToQueue } from '@/utils/downloads' /* ===== App initialization ===== */ -function startApp() { +async function startApp() { new Vue({ store, router, @@ -33,29 +33,28 @@ function startApp() { render: h => h(App) }).$mount('#app') - fetch('connect') - .then(response => response.json()) - .then(data => { - store.dispatch('setAppInfo', data.update) + const connectResponse = await (await fetch('connect')).json() - if (data.autologin) { - console.log('Autologin') - let arl = localStorage.getItem('arl') - let accountNum = localStorage.getItem('accountNum') + store.dispatch('setAppInfo', connectResponse.update) - if (arl) { - arl = arl.trim() - let result + if (connectResponse.autologin) { + console.info('Autologin successful') + let arl = localStorage.getItem('arl') + const accountNum = localStorage.getItem('accountNum') - if (accountNum != 0) { - result = get('login', { arl: arl, force: true, child: accountNum || 0 }) - } else { - result = get('login', { arl }) - } - result.then(loggedIn) - } + if (arl) { + arl = arl.trim() + let result + + if (accountNum !== 0) { + result = fetchApi('login', { arl, force: true, child: accountNum || 0 }) + } else { + result = fetchApi('login', { arl }) } - }) + + result.then(loggedIn) + } + } } function initClient() { diff --git a/src/use/main-search.js b/src/use/main-search.js index e10d076..a850b70 100644 --- a/src/use/main-search.js +++ b/src/use/main-search.js @@ -1,11 +1,10 @@ import { ref } from '@vue/composition-api' -import { get } from '@/utils/api' +import { fetchApi } from '@/utils/api' const searchResult = ref({}) function performMainSearch(searchTerm) { - get('mainSearch', { term: searchTerm }) - .then(data => { + fetchApi('mainSearch', { term: searchTerm }).then(data => { searchResult.value = data }) } diff --git a/src/use/search.js b/src/use/search.js index 299dfa6..7cdef54 100644 --- a/src/use/search.js +++ b/src/use/search.js @@ -1,10 +1,10 @@ import { ref } from '@vue/composition-api' -import { get } from '@/utils/api' +import { fetchApi } from '@/utils/api' const result = ref({}) function performSearch({ term, type, start = 0, nb = 30 }) { - get('search', { + fetchApi('search', { term, type, start, diff --git a/src/utils/api.js b/src/utils/api.js index 22ba66d..7e537e0 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -1,10 +1,9 @@ -export const get = function(key, data){ - let url = `/api/${key}` - if (data){ - let query = Object.keys(data) - .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(data[k])) - .join('&') - url += '?'+query - } - return fetch(url).then(response => response.json()) +export function fetchApi(key, data) { + const url = new URL(`${window.location.origin}/api/${key}`) + + Object.keys(data).forEach(key => { + url.searchParams.append(key, data[key]) + }) + + return fetch(url.href).then(response => response.json()) } diff --git a/src/utils/downloads.js b/src/utils/downloads.js index f6216fe..c74a98a 100644 --- a/src/utils/downloads.js +++ b/src/utils/downloads.js @@ -1,4 +1,4 @@ -import { get } from '@/utils/api' +import { fetchApi } from '@/utils/api' /** * @param {string} url @@ -7,7 +7,7 @@ import { get } from '@/utils/api' export function sendAddToQueue(url, bitrate = null) { if (!url) throw new Error('No URL given to sendAddToQueue function!') - get('addToQueue', { url, bitrate }) + fetchApi('addToQueue', { url, bitrate }) } export function aggregateDownloadLinks(releases) {