diff --git a/Cargo.toml b/Cargo.toml index 57d88ff..27f9b57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,4 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" [profile.release] -# Tell `rustc` to optimize for small code size. -opt-level = "s" lto = true \ No newline at end of file diff --git a/dist/worker.js b/dist/worker.js index 8fd02af..7c86647 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:"f2d72d8ee7c76e0acf34"}[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:function({base:t="",routes:e=[]}={}){return{__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(])/,"\\.").replace(/\)\.\?\(([^\[]+)\[\^/g,"?)\\.?($1(?<=\\.)[^\\.")}/*$`),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/3gpp",ext:"3gp"},64:{num:"10",gw:"MP3_64",mime:"audio/mpeg",ext:"mp3"},128:{num:"1",gw:"MP3_128",mime:"audio/mpeg",ext:"mp3"},320:{num:"3",gw:"MP3_320",mime:"audio/mpeg",ext:"mp3"},flac:{num:"9",gw:"FLAC",mime:"audio/flac",ext:"flac"},mp4_ra1:{num:"13",gw:"MP4_RA1",mime:"audio/mp4",ext:"mp4"},mp4_ra2:{num:"14",gw:"MP4_RA2",mime:"audio/mp4",ext:"mp4"},mp4_ra3:{num:"15",gw:"MP4_RA3",mime:"audio/mp4",ext:"mp4"},mhm1_ra1:{num:"16",gw:"MHM1_RA1",mime:"audio/mp4",ext:"mp4"},mhm1_ra2:{num:"17",gw:"MHM1_RA2",mime:"audio/mp4",ext:"mp4"},mhm1_ra3:{num:"18",gw:"MHM1_RA3",mime:"audio/mp4",ext:"mp4"},sbc_256:{num:"12",gw:"SBC_256",mime:"",ext:"sbc"},misc:{num:"0",gw:"MP3_MISC",mime:"audio/mpeg",ext:"mp3"}};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"}});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,h,l){let p;if(e>=0){let t=await async function(){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})}}();if(t)return t;if(p=await o("song.getData",{SNG_ID:e}),"Response"===p.constructor.name)return p}else{let t=await async function(){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)})}}();if(t)return t;const r=await fetch(`https://api.deezer.com/track/${e}?access_token=${c}`);if(p=await r.json(),void 0!==p.error)return new Response(JSON.stringify(p.error),{status:403,headers:{"content-type":"application/json"}});p={SNG_ID:p.id,FILESIZE_MP3_MISC:p.filesize_misc,SNG_TITLE:p.title,ALB_TITLE:p.album.title,ART_NAME:p.artist.name,ARTISTS:[{ART_NAME:p.artist.name}],ISRC:"",ALB_PICTURE:p.md5_image,MD5_ORIGIN:p.md5_origin,MEDIA_VERSION:p.media_version},i="misc"}if(0==p["FILESIZE_"+a[i].gw])return new Response("Format unavailable",{status:403,headers:{"content-type":"text/plain"}});let g=!1,d=0,m=NaN;if(null!==l){const t=l.match(/^bytes=(\d*)-(\d*)/);null!==t&&(d=parseInt(t[1]),m=parseInt(t[2]),g=!0)}const y=await r.e(1).then(r.bind(null,9));let w;if(["320","flac"].includes(i)){let t;t=void 0!==p.FALLBACK?p.FALLBACK.TRACK_TOKEN:p.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"}});w=o.data[0].media[0].sources[0].url}else w=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)}(p,i,y.legacy_stream_url);let b=p.SNG_TITLE;p.VERSION&&(b+=" "+p.VERSION);let v,A={method:"GET",headers:{}},_={status:200,headers:{"content-type":a[i].mime,"content-disposition":`inline; filename="${b.replaceAll('"','\\"')} [${e}].${a[i].ext}"`,"accept-ranges":"bytes"}},E=0;if(h){let e=new n(t.alloc(0));if(e.padding=0,e.setFrame("TIT2",b).setFrame("TALB",p.ALB_TITLE).setFrame("TPE2",p.ART_NAME),void 0!==p.ARTISTS){let t=[];for(const e of p.ARTISTS)t.push(e.ART_NAME);e.setFrame("TPE1",t)}if(void 0!==p.TRACK_NUMBER&&e.setFrame("TRCK",p.TRACK_NUMBER),void 0!==p.DISK_NUMBER&&e.setFrame("TPOS",p.DISK_NUMBER),""!==p.ISRC&&e.setFrame("TSRC",p.ISRC),void 0!==p.PHYSICAL_RELEASE_DATE){const t=p.PHYSICAL_RELEASE_DATE.split("-");e.setFrame("TYER",t[0]),e.setFrame("TDAT",t[2]+t[1])}if(""!==p.ALB_PICTURE){const t=`https://cdns-images.dzcdn.net/images/cover/${p.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg`,r=await fetch(t),n=await r.arrayBuffer();e.setFrame("APIC",{type:3,data:n,description:"cover"})}e.addTag(),v=e.arrayBuffer,E=v.byteLength}let T,R,S=!1,P=!1,I=0,U=NaN,B=0,L=0;if(g){if(isNaN(d)&&(d=0),isNaN(m)||m++,d<0||m=R&&(L=0),_.status=206,_.headers["content-range"]=`bytes ${d}-${m-1}/${R+E}`);let{readable:O,writable:M}=new FixedLengthStream(C);const x=M.getWriter();h&&!S&&x.write(v);if(P)x.close();else{p.FALLBACK&&(e=p.FALLBACK.SNG_ID);const t=new y.Cipher(String(e));!async function(t,e,r,n,i,a,o){const s=e.getReader({mode:"byob"});let u=!1;for(;!u;){u=i+2048>=r;let e=(await s.readAtLeast(2048,new Uint8Array(2048))).value;i%6144==0&&2048==e.byteLength&&n.decrypt_chunk(e),0!==a&&(e=e.slice(a),a=0),u&&0!==o&&(e=e.slice(0,e.byteLength-o)),t.write(e),i+=2048}s.cancel(),t.close()}(x,T.body,U,t,I,B,L)}return new Response(O,_)}(l,p,g,e.headers.get("range"));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){ +!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:"619670b37fb0bb7de91c"}[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:function({base:t="",routes:e=[]}={}){return{__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(])/,"\\.").replace(/\)\.\?\(([^\[]+)\[\^/g,"?)\\.?($1(?<=\\.)[^\\.")}/*$`),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/3gpp",ext:"3gp"},64:{num:"10",gw:"MP3_64",mime:"audio/mpeg",ext:"mp3"},128:{num:"1",gw:"MP3_128",mime:"audio/mpeg",ext:"mp3"},320:{num:"3",gw:"MP3_320",mime:"audio/mpeg",ext:"mp3"},flac:{num:"9",gw:"FLAC",mime:"audio/flac",ext:"flac"},mp4_ra1:{num:"13",gw:"MP4_RA1",mime:"audio/mp4",ext:"mp4"},mp4_ra2:{num:"14",gw:"MP4_RA2",mime:"audio/mp4",ext:"mp4"},mp4_ra3:{num:"15",gw:"MP4_RA3",mime:"audio/mp4",ext:"mp4"},mhm1_ra1:{num:"16",gw:"MHM1_RA1",mime:"audio/mp4",ext:"mp4"},mhm1_ra2:{num:"17",gw:"MHM1_RA2",mime:"audio/mp4",ext:"mp4"},mhm1_ra3:{num:"18",gw:"MHM1_RA3",mime:"audio/mp4",ext:"mp4"},sbc_256:{num:"12",gw:"SBC_256",mime:"",ext:"sbc"},misc:{num:"0",gw:"MP3_MISC",mime:"audio/mpeg",ext:"mp3"}};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"}});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,h,l){let p;if(e>=0){let t=await async function(){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})}}();if(t)return t;if(p=await o("song.getData",{SNG_ID:e}),"Response"===p.constructor.name)return p}else{let t=await async function(){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)})}}();if(t)return t;const r=await fetch(`https://api.deezer.com/track/${e}?access_token=${c}`);if(p=await r.json(),void 0!==p.error)return new Response(JSON.stringify(p.error),{status:403,headers:{"content-type":"application/json"}});p={SNG_ID:p.id,FILESIZE_MP3_MISC:p.filesize_misc,SNG_TITLE:p.title,ALB_TITLE:p.album.title,ART_NAME:p.artist.name,ARTISTS:[{ART_NAME:p.artist.name}],ISRC:"",ALB_PICTURE:p.md5_image,MD5_ORIGIN:p.md5_origin,MEDIA_VERSION:p.media_version},i="misc"}if(0==p["FILESIZE_"+a[i].gw])return new Response("Format unavailable",{status:403,headers:{"content-type":"text/plain"}});let g=!1,d=0,m=NaN;if(null!==l){const t=l.match(/^bytes=(\d*)-(\d*)/);null!==t&&(d=parseInt(t[1]),m=parseInt(t[2]),g=!0)}const y=await r.e(1).then(r.bind(null,9));let w;if(["320","flac"].includes(i)){let t;t=void 0!==p.FALLBACK?p.FALLBACK.TRACK_TOKEN:p.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"}});w=o.data[0].media[0].sources[0].url}else w=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)}(p,i,y.legacy_stream_url);let b=p.SNG_TITLE;p.VERSION&&(b+=" "+p.VERSION);let v,A={method:"GET",headers:{}},_={status:200,headers:{"content-type":a[i].mime,"content-disposition":`inline; filename="${b.replaceAll('"','\\"')} [${e}].${a[i].ext}"`,"accept-ranges":"bytes"}},E=0;if(h){let e=new n(t.alloc(0));if(e.padding=0,e.setFrame("TIT2",b).setFrame("TALB",p.ALB_TITLE).setFrame("TPE2",p.ART_NAME),void 0!==p.ARTISTS){let t=[];for(const e of p.ARTISTS)t.push(e.ART_NAME);e.setFrame("TPE1",t)}if(void 0!==p.TRACK_NUMBER&&e.setFrame("TRCK",p.TRACK_NUMBER),void 0!==p.DISK_NUMBER&&e.setFrame("TPOS",p.DISK_NUMBER),""!==p.ISRC&&e.setFrame("TSRC",p.ISRC),void 0!==p.PHYSICAL_RELEASE_DATE){const t=p.PHYSICAL_RELEASE_DATE.split("-");e.setFrame("TYER",t[0]),e.setFrame("TDAT",t[2]+t[1])}if(""!==p.ALB_PICTURE){const t=`https://cdns-images.dzcdn.net/images/cover/${p.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg`,r=await fetch(t),n=await r.arrayBuffer();e.setFrame("APIC",{type:3,data:n,description:"cover"})}e.addTag(),v=e.arrayBuffer,E=v.byteLength}let T,R,S=!1,P=!1,I=0,U=NaN,B=0,L=0;if(g){if(isNaN(d)&&(d=0),isNaN(m)||m++,d<0||m=R&&(L=0),_.status=206,_.headers["content-range"]=`bytes ${d}-${m-1}/${R+E}`);let{readable:O,writable:M}=new FixedLengthStream(C);const x=M.getWriter();h&&!S&&x.write(v);if(P)x.close();else{p.FALLBACK&&(e=p.FALLBACK.SNG_ID);const t=new y.Cipher(String(e));!async function(t,e,r,n,i,a,o){const s=e.getReader({mode:"byob"});let u=!1;for(;!u;){u=i+2048>=r;let e=(await s.readAtLeast(2048,new Uint8Array(2048))).value;i%6144==0&&2048==e.byteLength&&n.decrypt_chunk(e),0!==a&&(e=e.slice(a),a=0),u&&0!==o&&(e=e.slice(0,e.byteLength-o)),t.write(e),i+=2048}s.cancel(),t.close()}(x,T.body,U,t,I,B,L)}return new Response(O,_)}(l,p,g,e.headers.get("range"));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/wrangler.toml b/wrangler.toml index 5d4d492..83e8ba3 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -6,7 +6,7 @@ workers_dev = true kv_namespaces = [ { binding = "KV", id = "974c0967a84e415daa054bbbcc7f80c6", preview_id = "cfcc6491f3484cbca664913836635113" } ] -compatibility_date = "2022-04-13" +compatibility_date = "2022-04-30" # [secrets] # ARL \ No newline at end of file