diff --git a/dist/worker.js b/dist/worker.js index 656a9c4..4bd4a23 100644 --- a/dist/worker.js +++ b/dist/worker.js @@ -1,4 +1,4 @@ -!function(t){self.webpackChunk=function(e,n){for(var i in n)t[i]=n[i];for(;e.length;)r[e.pop()]=1};var e={},r={0:1},n={};var i={11:function(){return{"./index_bg.js":{__wbindgen_throw:function(t,r){return e[10].exports.b(t,r)}}}}};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.e=function(t){var e=[];return e.push(Promise.resolve().then((function(){r[t]||importScripts(a.p+""+t+".worker.js")}))),({1:[11]}[t]||[]).forEach((function(t){var r=n[t];if(r)e.push(r);else{var o,s=i[t](),u=fetch(a.p+""+{11:"6778a0238c8462ed4a85"}[t]+".module.wasm");if(s instanceof Promise&&"function"==typeof WebAssembly.compileStreaming)o=Promise.all([WebAssembly.compileStreaming(u),s]).then((function(t){return WebAssembly.instantiate(t[0],t[1])}));else if("function"==typeof WebAssembly.instantiateStreaming)o=WebAssembly.instantiateStreaming(u,s);else{o=u.then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.instantiate(t,s)}))}e.push(n[t]=o.then((function(e){return a.w[t]=(e.instance||e).exports})))}})),Promise.all(e)},a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a.w={},a(a.s=1)}([function(t,e){t.exports={Router:({base:t="",routes:e=[]}={})=>({__proto__:new Proxy({},{get:(r,n,i)=>(r,...a)=>e.push([n.toUpperCase(),RegExp(`^${(t+r).replace(/(\/?)\*/g,"($1.*)?").replace(/\/$/,"").replace(/:(\w+)(\?)?(\.)?/g,"$2(?<$1>[^/]+)$2$3").replace(/\.(?=[\w(])/,"\\.")}/*$`),a])&&i}),routes:e,async handle(t,...r){let n,i,a=new URL(t.url);for(var[o,s,u]of(t.query=Object.fromEntries(a.searchParams),e))if((o===t.method||"ALL"===o)&&(i=a.pathname.match(s)))for(var f of(t.params=i.groups,u))if(void 0!==(n=await f(t.proxy||t,...r)))return n}})}},function(t,e,r){"use strict";r.r(e),function(t){var e=r(0);const n=r(7),i=Object(e.Router)(),a={aac_96:{num:"8",gw:"AAC_96",mime:"audio/aac"},64:{num:"10",gw:"MP3_64",mime:"audio/mpeg"},128:{num:"1",gw:"MP3_128",mime:"audio/mpeg"},320:{num:"3",gw:"MP3_320",mime:"audio/mpeg"},flac:{num:"9",gw:"FLAC",mime:"audio/flac"},mp4_ra1:{num:"13",gw:"MP4_RA1",mime:"audio/mp4"},mp4_ra2:{num:"14",gw:"MP4_RA2",mime:"audio/mp4"},mp4_ra3:{num:"15",gw:"MP4_RA3",mime:"audio/mp4"},mhm1_ra1:{num:"16",gw:"MHM1_RA1",mime:"audio/mp4"},mhm1_ra2:{num:"17",gw:"MHM1_RA2",mime:"audio/mp4"},mhm1_ra3:{num:"18",gw:"MHM1_RA3",mime:"audio/mp4"},sbc_256:{num:"12",gw:"SBC_256",mime:""},misc:{num:"0",gw:"MP3_MISC",mime:"audio/mpeg"}};async function o(t,e){"deezer.getUserData"===t&&(u=""),e||(e={});let r="arl="+ARL;f&&(r+="; sid="+f);const n={method:"POST",headers:new Headers({cookie:r}),body:JSON.stringify(e)},i=await fetch(`https://www.deezer.com/ajax/gw-light.php?method=${t}&input=3&api_version=1.0&api_token=${encodeURIComponent(u)}&cid=${Math.floor(1e9*Math.random())}`,n),a=await i.json();return 0!==a.error.length?new Response(JSON.stringify(a.error),{status:500,headers:{"content-type":"application/json"}}):("deezer.getUserData"===t&&(u=a.results.checkForm,await KV.put("checkForm",u),f=i.headers.get("set-cookie").split(",").map(t=>t.trimStart())[0],f=f.match(/^sid=(fr[\da-f]+)/)[1],await KV.put("sid",f)),a.results)}let s,u,f,c;i.get("/:type/:id",async e=>{const{query:i}=e;let{type:h,id:l}=e.params;if(!["track","album","playlist"].includes(h))return new Response("not found",{status:404,headers:{"content-type":"text/plain"}});if(l=parseInt(l),NaN===l||"track"!==h&&l<0)return new Response("Invalid ID",{status:400,headers:{"content-type":"text/plain"}});if("track"===h)if(l>=0){if(s=await KV.get("license_token"),u=await KV.get("checkForm"),f=await KV.get("sid"),null===s){const t=await o("deezer.getUserData");if("Response"===t.constructor.name)return t;if(0===t.USER.USER_ID)return new Response("Invalid arl",{status:500,headers:{"content-type":"text/plain"}});s=t.USER.OPTIONS.license_token,await KV.put("license_token",s,{expirationTtl:3600})}}else if(c=await KV.get("access_token"),null===c){const t=await fetch("https://connect.deezer.com/oauth/access_token.php?grant_type=client_credentials&client_id=447462&client_secret=a83bf7f38ad2f137e444727cfc3775cf&output=json"),e=await t.json();if(void 0!==e.error)return new Response("Couldn't get access token from Deezer",{status:500,headers:{"content-type":"text/plain"}});c=e.access_token,await KV.put("access_token",c,{expirationTtl:parseInt(e.expires)})}let p=i.f;if(void 0===p)p="320";else if(p=p.toLowerCase(),void 0===a[p]){let t=[];Object.values(a).forEach(e=>t.push(e.num));let e=t.indexOf(p);if(-1===e)return new Response("Invalid format",{status:400,headers:{"content-type":"text/plain"}});p=Object.keys(a)[e]}let g=i.t;switch(g=("true"===g||"1"===g)&&["misc","128","320"].includes(p),h){case"track":return await async function(e,i,u){let f;if(e>=0){if(f=await o("song.getData",{SNG_ID:e}),"Response"===f.constructor.name)return f}else{const t=await fetch(`https://api.deezer.com/track/${e}?access_token=${c}`);if(f=await t.json(),void 0!==f.error)return new Response(JSON.stringify(f.error),{status:403,headers:{"content-type":"application/json"}});f={SNG_ID:f.id,FILESIZE_MP3_MISC:f.filesize_misc,SNG_TITLE:f.title,ALB_TITLE:f.album.title,ART_NAME:f.artist.name,ARTISTS:[{ART_NAME:f.artist.name}],ISRC:"",ALB_PICTURE:f.md5_image,MD5_ORIGIN:f.md5_origin,MEDIA_VERSION:f.media_version},i="misc"}if(0==f["FILESIZE_"+a[i].gw])return new Response("Format unavailable",{status:403,headers:{"content-type":"text/plain"}});const h=await r.e(1).then(r.bind(null,9));let l;if(["320","flac"].includes(i)){let t;t=void 0!==f.FALLBACK?f.FALLBACK.TRACK_TOKEN:f.TRACK_TOKEN;const e={license_token:s,media:[{type:"FULL",formats:[{cipher:"BF_CBC_STRIPE",format:a[i].gw}]}],track_tokens:[t]},r={method:"POST",body:JSON.stringify(e)},n=await fetch("https://media.deezer.com/v1/get_url",r);if(200!==n.status)return new Response("Couldn't get stream URL",{status:403,headers:{"content-type":"text/plain"}});const o=await n.json();if(void 0===o.data[0].media)return new Response("Couldn't get stream URL",{status:403,headers:{"content-type":"text/plain"}});l=o.data[0].media[0].sources[0].url}else l=await function(t,e,r){t.FALLBACK&&(t=t.FALLBACK);const n=t.SNG_ID.toString(),i=t.MD5_ORIGIN,o=t.MEDIA_VERSION;return e=a[e].num,r(i,e,n,o)}(f,i,h.legacy_stream_url);const p=await fetch(l);if(200!==p.status)return new Response("Couldn't get track stream",{status:403,headers:{"content-type":"text/plain"}});let g;if(u){g=new n(t.alloc(0)),g.padding=0;let e=f.SNG_TITLE;if(void 0!==f.VERSION&&(e+=" "+f.VERSION),g.setFrame("TIT2",e).setFrame("TALB",f.ALB_TITLE).setFrame("TPE2",f.ART_NAME),void 0!==f.ARTISTS){let t=[];for(const e of f.ARTISTS)t.push(e.ART_NAME);g.setFrame("TPE1",t)}if(void 0!==f.TRACK_NUMBER&&g.setFrame("TRCK",f.TRACK_NUMBER),void 0!==f.DISK_NUMBER&&g.setFrame("TPOS",f.DISK_NUMBER),""!==f.ISRC&&g.setFrame("TSRC",f.ISRC),void 0!==f.PHYSICAL_RELEASE_DATE){const t=f.PHYSICAL_RELEASE_DATE.split("-");g.setFrame("TYER",t[0]),g.setFrame("TDAT",t[2]+t[1])}if(""!==f.ALB_PICTURE){const t=`https://cdns-images.dzcdn.net/images/cover/${f.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg`,e=await fetch(t),r=await e.arrayBuffer();g.setFrame("APIC",{type:3,data:r,description:"cover"})}g.addTag()}let{readable:d,writable:m}=new TransformStream;const y=m.getWriter();u&&y.write(g.arrayBuffer);f.FALLBACK&&(e=f.FALLBACK.SNG_ID);const w=new h.Cipher(String(e)),b=parseInt(p.headers.get("Content-Length"));return async function(t,e,r,n){const i=e.getReader({mode:"byob"});let a=0,o=!1;for(;!o;){let e;o=a+2048>r,e=o?new Int8Array(r-a):new Int8Array(2048);let s=0;for(;s!==e.length;){let t=(await i.read(new Int8Array(e.length-s))).value;e.set(t,s),s+=t.length}a%6144!=0||o||n.decrypt_chunk(e),await t.write(e),a+=2048}await i.cancel(),await t.close()}(y,p.body,b,w),new Response(d,{status:200,headers:{"content-type":a[i].mime}})}(l,p,g);case"album":case"playlist":return await async function(t,e,r,n,i){const a=await fetch(`https://api.deezer.com/${t}/${e}?limit=-1`),o=await a.json();if(void 0!==o.error)return new Response(JSON.stringify(o.error),{status:403,headers:{"content-type":"application/json"}});let s="#EXTM3U\n";for(const t of o.tracks.data){t.id<0&&(r="misc");let e=`https://${i}/track/${t.id}?f=${r}&t=${+n}`;s+=`#EXTINF:${t.duration},${t.title}\n${e}\n`}return new Response(s,{status:200,headers:{"content-type":"audio/mpegurl"}})}(h,l,p,g,e.headers.get("host"))}}),i.get("/",()=>new Response(r(8),{status:200,headers:{"content-type":"text/html"}})),i.all("*",()=>new Response("not found",{status:404,headers:{"content-type":"text/plain"}})),addEventListener("fetch",t=>t.respondWith(i.handle(t.request)))}.call(this,r(2).Buffer)},function(t,e,r){"use strict";(function(t){ +!function(t){self.webpackChunk=function(e,n){for(var i in n)t[i]=n[i];for(;e.length;)r[e.pop()]=1};var e={},r={0:1},n={};var i={11:function(){return{"./index_bg.js":{__wbindgen_throw:function(t,r){return e[10].exports.b(t,r)}}}}};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.e=function(t){var e=[];return e.push(Promise.resolve().then((function(){r[t]||importScripts(a.p+""+t+".worker.js")}))),({1:[11]}[t]||[]).forEach((function(t){var r=n[t];if(r)e.push(r);else{var o,s=i[t](),u=fetch(a.p+""+{11:"6778a0238c8462ed4a85"}[t]+".module.wasm");if(s instanceof Promise&&"function"==typeof WebAssembly.compileStreaming)o=Promise.all([WebAssembly.compileStreaming(u),s]).then((function(t){return WebAssembly.instantiate(t[0],t[1])}));else if("function"==typeof WebAssembly.instantiateStreaming)o=WebAssembly.instantiateStreaming(u,s);else{o=u.then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.instantiate(t,s)}))}e.push(n[t]=o.then((function(e){return a.w[t]=(e.instance||e).exports})))}})),Promise.all(e)},a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a.w={},a(a.s=1)}([function(t,e){t.exports={Router:({base:t="",routes:e=[]}={})=>({__proto__:new Proxy({},{get:(r,n,i)=>(r,...a)=>e.push([n.toUpperCase(),RegExp(`^${(t+r).replace(/(\/?)\*/g,"($1.*)?").replace(/\/$/,"").replace(/:(\w+)(\?)?(\.)?/g,"$2(?<$1>[^/]+)$2$3").replace(/\.(?=[\w(])/,"\\.")}/*$`),a])&&i}),routes:e,async handle(t,...r){let n,i,a=new URL(t.url);for(var[o,s,u]of(t.query=Object.fromEntries(a.searchParams),e))if((o===t.method||"ALL"===o)&&(i=a.pathname.match(s)))for(var f of(t.params=i.groups,u))if(void 0!==(n=await f(t.proxy||t,...r)))return n}})}},function(t,e,r){"use strict";r.r(e),function(t){var e=r(0);const n=r(7),i=Object(e.Router)(),a={aac_96:{num:"8",gw:"AAC_96",mime:"audio/aac"},64:{num:"10",gw:"MP3_64",mime:"audio/mpeg"},128:{num:"1",gw:"MP3_128",mime:"audio/mpeg"},320:{num:"3",gw:"MP3_320",mime:"audio/mpeg"},flac:{num:"9",gw:"FLAC",mime:"audio/flac"},mp4_ra1:{num:"13",gw:"MP4_RA1",mime:"audio/mp4"},mp4_ra2:{num:"14",gw:"MP4_RA2",mime:"audio/mp4"},mp4_ra3:{num:"15",gw:"MP4_RA3",mime:"audio/mp4"},mhm1_ra1:{num:"16",gw:"MHM1_RA1",mime:"audio/mp4"},mhm1_ra2:{num:"17",gw:"MHM1_RA2",mime:"audio/mp4"},mhm1_ra3:{num:"18",gw:"MHM1_RA3",mime:"audio/mp4"},sbc_256:{num:"12",gw:"SBC_256",mime:""},misc:{num:"0",gw:"MP3_MISC",mime:"audio/mpeg"}};async function o(t,e){"deezer.getUserData"===t&&(u=""),e||(e={});let r="arl="+ARL;f&&(r+="; sid="+f);const n={method:"POST",headers:new Headers({cookie:r}),body:JSON.stringify(e)},i=await fetch(`https://www.deezer.com/ajax/gw-light.php?method=${t}&input=3&api_version=1.0&api_token=${encodeURIComponent(u)}&cid=${Math.floor(1e9*Math.random())}`,n),a=await i.json();return 0!==a.error.length?new Response(JSON.stringify(a.error),{status:500,headers:{"content-type":"application/json"}}):("deezer.getUserData"===t&&(u=a.results.checkForm,await KV.put("checkForm",u),f=i.headers.get("set-cookie").split(",").map(t=>t.trimStart())[0],f=f.match(/^sid=(fr[\da-f]+)/)[1],await KV.put("sid",f)),a.results)}let s,u,f,c;i.get("/:type/:id",async e=>{const{query:i}=e;let{type:h,id:l}=e.params;if(!["track","album","playlist"].includes(h))return new Response("not found",{status:404,headers:{"content-type":"text/plain"}});if(l=parseInt(l),NaN===l||"track"!==h&&l<0)return new Response("Invalid ID",{status:400,headers:{"content-type":"text/plain"}});if("track"===h)if(l>=0){if(s=await KV.get("license_token"),u=await KV.get("checkForm"),f=await KV.get("sid"),null===s){const t=await o("deezer.getUserData");if("Response"===t.constructor.name)return t;if(0===t.USER.USER_ID)return new Response("Invalid arl",{status:500,headers:{"content-type":"text/plain"}});s=t.USER.OPTIONS.license_token,await KV.put("license_token",s,{expirationTtl:3600})}}else if(c=await KV.get("access_token"),null===c){const t=await fetch("https://connect.deezer.com/oauth/access_token.php?grant_type=client_credentials&client_id=447462&client_secret=a83bf7f38ad2f137e444727cfc3775cf&output=json"),e=await t.json();if(void 0!==e.error)return new Response("Couldn't get access token from Deezer",{status:500,headers:{"content-type":"text/plain"}});c=e.access_token,await KV.put("access_token",c,{expirationTtl:parseInt(e.expires)})}let p=i.f;if(void 0===p)p="320";else if(p=p.toLowerCase(),void 0===a[p]){let t=[];Object.values(a).forEach(e=>t.push(e.num));let e=t.indexOf(p);if(-1===e)return new Response("Invalid format",{status:400,headers:{"content-type":"text/plain"}});p=Object.keys(a)[e]}let g=i.t;switch(g=("true"===g||"1"===g)&&(["misc","128","320"].includes(p)||"track"!==h),h){case"track":return await async function(e,i,u){let f;if(e>=0){if(f=await o("song.getData",{SNG_ID:e}),"Response"===f.constructor.name)return f}else{const t=await fetch(`https://api.deezer.com/track/${e}?access_token=${c}`);if(f=await t.json(),void 0!==f.error)return new Response(JSON.stringify(f.error),{status:403,headers:{"content-type":"application/json"}});f={SNG_ID:f.id,FILESIZE_MP3_MISC:f.filesize_misc,SNG_TITLE:f.title,ALB_TITLE:f.album.title,ART_NAME:f.artist.name,ARTISTS:[{ART_NAME:f.artist.name}],ISRC:"",ALB_PICTURE:f.md5_image,MD5_ORIGIN:f.md5_origin,MEDIA_VERSION:f.media_version},i="misc"}if(0==f["FILESIZE_"+a[i].gw])return new Response("Format unavailable",{status:403,headers:{"content-type":"text/plain"}});const h=await r.e(1).then(r.bind(null,9));let l;if(["320","flac"].includes(i)){let t;t=void 0!==f.FALLBACK?f.FALLBACK.TRACK_TOKEN:f.TRACK_TOKEN;const e={license_token:s,media:[{type:"FULL",formats:[{cipher:"BF_CBC_STRIPE",format:a[i].gw}]}],track_tokens:[t]},r={method:"POST",body:JSON.stringify(e)},n=await fetch("https://media.deezer.com/v1/get_url",r);if(200!==n.status)return new Response("Couldn't get stream URL",{status:403,headers:{"content-type":"text/plain"}});const o=await n.json();if(void 0===o.data[0].media)return new Response("Couldn't get stream URL",{status:403,headers:{"content-type":"text/plain"}});l=o.data[0].media[0].sources[0].url}else l=await function(t,e,r){t.FALLBACK&&(t=t.FALLBACK);const n=t.SNG_ID.toString(),i=t.MD5_ORIGIN,o=t.MEDIA_VERSION;return e=a[e].num,r(i,e,n,o)}(f,i,h.legacy_stream_url);const p=await fetch(l);if(200!==p.status)return new Response("Couldn't get track stream",{status:403,headers:{"content-type":"text/plain"}});let g;if(u){g=new n(t.alloc(0)),g.padding=0;let e=f.SNG_TITLE;if(void 0!==f.VERSION&&(e+=" "+f.VERSION),g.setFrame("TIT2",e).setFrame("TALB",f.ALB_TITLE).setFrame("TPE2",f.ART_NAME),void 0!==f.ARTISTS){let t=[];for(const e of f.ARTISTS)t.push(e.ART_NAME);g.setFrame("TPE1",t)}if(void 0!==f.TRACK_NUMBER&&g.setFrame("TRCK",f.TRACK_NUMBER),void 0!==f.DISK_NUMBER&&g.setFrame("TPOS",f.DISK_NUMBER),""!==f.ISRC&&g.setFrame("TSRC",f.ISRC),void 0!==f.PHYSICAL_RELEASE_DATE){const t=f.PHYSICAL_RELEASE_DATE.split("-");g.setFrame("TYER",t[0]),g.setFrame("TDAT",t[2]+t[1])}if(""!==f.ALB_PICTURE){const t=`https://cdns-images.dzcdn.net/images/cover/${f.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg`,e=await fetch(t),r=await e.arrayBuffer();g.setFrame("APIC",{type:3,data:r,description:"cover"})}g.addTag()}let{readable:d,writable:m}=new TransformStream;const y=m.getWriter();u&&y.write(g.arrayBuffer);f.FALLBACK&&(e=f.FALLBACK.SNG_ID);const w=new h.Cipher(String(e)),b=parseInt(p.headers.get("Content-Length"));return async function(t,e,r,n){const i=e.getReader({mode:"byob"});let a=0,o=!1;for(;!o;){let e;o=a+2048>r,e=o?new Int8Array(r-a):new Int8Array(2048);let s=0;for(;s!==e.length;){let t=(await i.read(new Int8Array(e.length-s))).value;e.set(t,s),s+=t.length}a%6144!=0||o||n.decrypt_chunk(e),await t.write(e),a+=2048}await i.cancel(),await t.close()}(y,p.body,b,w),new Response(d,{status:200,headers:{"content-type":a[i].mime}})}(l,p,g);case"album":case"playlist":return await async function(t,e,r,n,i){const a=await fetch(`https://api.deezer.com/${t}/${e}?limit=-1`),o=await a.json();if(void 0!==o.error)return new Response(JSON.stringify(o.error),{status:403,headers:{"content-type":"application/json"}});let s="#EXTM3U\n";for(const t of o.tracks.data){let e=r;t.id<0&&(e="misc");let a=`https://${i}/track/${t.id}?f=${e}&t=${+n}`;s+=`#EXTINF:${t.duration},${t.title}\n${a}\n`}return new Response(s,{status:200,headers:{"content-type":"audio/mpegurl"}})}(h,l,p,g,e.headers.get("host"))}}),i.get("/",()=>new Response(r(8),{status:200,headers:{"content-type":"text/html"}})),i.all("*",()=>new Response("not found",{status:404,headers:{"content-type":"text/plain"}})),addEventListener("fetch",t=>t.respondWith(i.handle(t.request)))}.call(this,r(2).Buffer)},function(t,e,r){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * diff --git a/index.js b/index.js index 59cfe8d..44ab0c0 100644 --- a/index.js +++ b/index.js @@ -134,7 +134,7 @@ router.get('/:type/:id', async request => { } let tagging = query.t - tagging = (tagging === 'true' || tagging === '1') && ['misc', '128', '320'].includes(format) + tagging = (tagging === 'true' || tagging === '1') && (['misc', '128', '320'].includes(format) || type !== 'track') switch (type) { case 'track': @@ -369,10 +369,11 @@ async function m3u8(type, id, format, tagging, host) { let list = '#EXTM3U\n' for (const track of json.tracks.data) { + let format_tmp = format if (track.id < 0) { // user-uploaded track - format = 'misc' + format_tmp = 'misc' } - let result = `https://${host}/track/${track.id}?f=${format}&t=${+ tagging}` + let result = `https://${host}/track/${track.id}?f=${format_tmp}&t=${+ tagging}` list += `#EXTINF:${track.duration},${track.title}\n${result}\n` }