From 9dbf2dcde96a7207ba26c164217da9710f653001 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Thu, 13 May 2021 18:16:11 +0200 Subject: [PATCH] Changed api/addToQueue from get to post --- public/js/bundle.js | 2 +- src/utils/downloads.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/bundle.js b/public/js/bundle.js index 63f7127..b4aafbb 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -2506,7 +2506,7 @@ a { `;styleInject(css_248z$2);class CustomSocket extends WebSocket{constructor(a){super(a);this.listeners={}}emit(a,n){if(this.readyState!==WebSocket.OPEN)return!1;this.send(JSON.stringify({key:a,data:n}))}on(a,n){Object.keys(this.listeners).indexOf(a)==-1&&(console.log("on:",a),this.listeners[a]=n,this.addEventListener("message",i=>{const r=JSON.parse(i.data);r.key===a&&n(r.data)}))}off(a){Object.keys(this.listeners).indexOf(a)!=-1&&(console.log("off:",a),this.removeEventListener("message",this.listeners[a]),delete this.listeners[a])}}const socket=new CustomSocket("ws://"+location.host+"/");var __vue_render__$w=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__$w=[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__$w=function(e){!e||e("data-v-07f63f2b_0",{source:".lds-ring[data-v-07f63f2b]{display:inline-block;position:relative;width:80px;height:80px}.lds-ring div[data-v-07f63f2b]{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-07f63f2b 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.lds-ring div[data-v-07f63f2b]:nth-child(1){animation-delay:-.45s}.lds-ring div[data-v-07f63f2b]:nth-child(2){animation-delay:-.3s}.lds-ring div[data-v-07f63f2b]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-data-v-07f63f2b{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}",map:void 0,media:void 0})},__vue_scope_id__$w="data-v-07f63f2b",__vue_module_identifier__$d=void 0,__vue_is_functional_template__$w=!0;function __vue_normalize__$w(e,a,n,i,r,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,r&&(o.functional=!0)),o._scopeId=i;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$d(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$d.styles||(__vue_create_injector__$d.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(r,s){if(document.querySelector('style[data-vue-ssr-id~="'+r+'"]'))return;const l=n?s.media||"default":r,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(r)){let o=s.source,u=c.ids.length;if(c.ids.push(r),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 d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` -`);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var BaseLoadingPlaceholder=__vue_normalize__$w({render:__vue_render__$w,staticRenderFns:__vue_staticRenderFns__$w},__vue_inject_styles__$w,{},__vue_scope_id__$w,__vue_is_functional_template__$w,__vue_module_identifier__$d,__vue_create_injector__$d);function fetchData(e,a={},n="GET"){const i=new URL(`${window.location.origin}/api/${e}`);return Object.keys(a).forEach(r=>{i.searchParams.append(r,a[r])}),fetch(i.href,{method:n}).then(r=>r.json()).catch(()=>{})}function sendToServer(e,a){const n=new URL(`${window.location.origin}/api/${e}`);Object.keys(a).forEach(i=>{n.searchParams.append(i,a[i])}),fetch(n.href).catch(console.error)}function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");sendToServer("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,i;return n=Math.floor(e/60),a=Math.floor(n/60),i=e-n*60,n-=a*60,[a,n,i]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce$1(e,a,n){var i;return function(){var r=this,s=arguments,l=function(){i=null,n||e.apply(r,s)},c=n&&!i;clearTimeout(i),i=setTimeout(l,a),c&&e.apply(r,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)?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof r!="undefined")return r}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce:debounce$1};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$u={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,i)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+i,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:i}=window,r=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(r>i){const l=r-i+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__$u=script$u;var __vue_render__$v=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(i){return n("button",{directives:[{name:"show",rawName:"v-show",value:i.show,expression:"option.show"}],key:i.label,staticClass:"btn menu-option",on:{click:function(r){return r.preventDefault(),i.action(r)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(i.label))])])}),0)},__vue_staticRenderFns__$v=[];const __vue_inject_styles__$v=function(e){!e||e("data-v-17a20187_0",{source:".context-menu[data-v-17a20187]{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-17a20187]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-17a20187]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-17a20187]{text-transform:capitalize}button[data-v-17a20187]{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-17a20187]:focus{outline:0}button[data-v-17a20187]:active{background-color:unset;transform:unset}button[data-v-17a20187]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$v="data-v-17a20187",__vue_module_identifier__$c=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,i,r,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,r&&(o.functional=!0)),o._scopeId=i;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$c(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$c.styles||(__vue_create_injector__$c.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(r,s){if(document.querySelector('style[data-vue-ssr-id~="'+r+'"]'))return;const l=n?s.media||"default":r,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(r)){let o=s.source,u=c.ids.length;if(c.ids.push(r),s.map&&(o+=` +`);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var BaseLoadingPlaceholder=__vue_normalize__$w({render:__vue_render__$w,staticRenderFns:__vue_staticRenderFns__$w},__vue_inject_styles__$w,{},__vue_scope_id__$w,__vue_is_functional_template__$w,__vue_module_identifier__$d,__vue_create_injector__$d);function fetchData(e,a={},n="GET"){const i=new URL(`${window.location.origin}/api/${e}`);return Object.keys(a).forEach(r=>{i.searchParams.append(r,a[r])}),fetch(i.href,{method:n}).then(r=>r.json()).catch(()=>{})}function sendAddToQueue(e,a=null){if(!e)throw new Error("No URL given to sendAddToQueue function!");fetchData("addToQueue",{url:e,bitrate:a},"POST")}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,i;return n=Math.floor(e/60),a=Math.floor(n/60),i=e-n*60,n-=a*60,[a,n,i]}function numberWithDots(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function debounce$1(e,a,n){var i;return function(){var r=this,s=arguments,l=function(){i=null,n||e.apply(r,s)},c=n&&!i;clearTimeout(i),i=setTimeout(l,a),c&&e.apply(r,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)?n.split(".").reduce((s,l)=>{if(s)return s[l]},e):e[n];if(typeof r!="undefined")return r}return null}var Utils={isValidURL,convertDuration,convertDurationSeparated,numberWithDots,debounce:debounce$1};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$u={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,i)=>{e[n.objName]={label:`${this.$t("globals.download",{thing:n.label})}`,show:!1,position:a+i,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:i}=window,r=e+this.$refs.contextMenu.getBoundingClientRect().width,s=a+this.$refs.contextMenu.getBoundingClientRect().height;if(r>i){const l=r-i+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__$u=script$u;var __vue_render__$v=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(i){return n("button",{directives:[{name:"show",rawName:"v-show",value:i.show,expression:"option.show"}],key:i.label,staticClass:"btn menu-option",on:{click:function(r){return r.preventDefault(),i.action(r)}}},[n("span",{staticClass:"menu-option__text"},[e._v(e._s(i.label))])])}),0)},__vue_staticRenderFns__$v=[];const __vue_inject_styles__$v=function(e){!e||e("data-v-17a20187_0",{source:".context-menu[data-v-17a20187]{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-17a20187]{display:flex;align-items:center;width:100%;height:40px;padding-left:10px;padding-right:10px;color:var(--foreground);cursor:pointer}.menu-option[data-v-17a20187]:hover{background:var(--table-highlight);filter:brightness(150%)}.menu-option__text[data-v-17a20187]{text-transform:capitalize}button[data-v-17a20187]{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-17a20187]:focus{outline:0}button[data-v-17a20187]:active{background-color:unset;transform:unset}button[data-v-17a20187]:hover{background:unset;border:unset}",map:void 0,media:void 0})},__vue_scope_id__$v="data-v-17a20187",__vue_module_identifier__$c=void 0,__vue_is_functional_template__$v=!1;function __vue_normalize__$v(e,a,n,i,r,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,r&&(o.functional=!0)),o._scopeId=i;{let u;if(a&&(u=function(d){a.call(this,l(d))}),u!==void 0)if(o.functional){const d=o.render;o.render=function(h,m){return u.call(m),d(h,m)}}else{const d=o.beforeCreate;o.beforeCreate=d?[].concat(d,u):[u]}}return o}function __vue_create_injector__$c(){const e=document.head||document.getElementsByTagName("head")[0],a=__vue_create_injector__$c.styles||(__vue_create_injector__$c.styles={}),n=typeof navigator!="undefined"&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(r,s){if(document.querySelector('style[data-vue-ssr-id~="'+r+'"]'))return;const l=n?s.media||"default":r,c=a[l]||(a[l]={ids:[],parts:[],element:void 0});if(!c.ids.includes(r)){let o=s.source,u=c.ids.length;if(c.ids.push(r),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 d=c.element=document.createElement("style");d.type="text/css",s.media&&d.setAttribute("media",s.media),n&&(d.setAttribute("data-group",l),d.setAttribute("data-next-index","0")),e.appendChild(d)}if(n&&(u=parseInt(c.element.getAttribute("data-next-index")),c.element.setAttribute("data-next-index",u+1)),c.element.styleSheet)c.parts.push(o),c.element.styleSheet.cssText=c.parts.filter(Boolean).join(` `);else{const d=document.createTextNode(o),f=c.element.childNodes;f[u]&&c.element.removeChild(f[u]),f.length?c.element.insertBefore(d,f[u]):c.element.appendChild(d)}}}}var TheContextMenu=__vue_normalize__$v({render:__vue_render__$v,staticRenderFns:__vue_staticRenderFns__$v},__vue_inject_styles__$v,__vue_script__$u,__vue_scope_id__$v,__vue_is_functional_template__$v,__vue_module_identifier__$c,__vue_create_injector__$c);/*! diff --git a/src/utils/downloads.js b/src/utils/downloads.js index 5f3287f..5e78b54 100644 --- a/src/utils/downloads.js +++ b/src/utils/downloads.js @@ -1,4 +1,4 @@ -import { sendToServer } from '@/utils/api' +import { fetchData } from '@/utils/api' /** * @param {string} url @@ -7,7 +7,7 @@ import { sendToServer } from '@/utils/api' export function sendAddToQueue(url, bitrate = null) { if (!url) throw new Error('No URL given to sendAddToQueue function!') - sendToServer('addToQueue', { url, bitrate }) + fetchData('addToQueue', { url, bitrate }, 'POST') } export function aggregateDownloadLinks(releases) {