added tagging to albums/playlists

This commit is contained in:
uh wot 2021-05-25 23:57:29 +02:00
parent 3e4a929938
commit 47f2be13e5
Signed by: uhwot
GPG Key ID: CB2454984587B781
2 changed files with 14 additions and 9 deletions

8
dist/worker.js vendored

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,7 @@ async function handler(type, request) {
return await track(id, format, access_token, tagging)
case 'album':
case 'playlist':
return await m3u8(type, id, format, access_token)
return await m3u8(type, id, format, access_token, tagging)
}
}
@ -172,7 +172,7 @@ async function track_url(json, format) {
return await url_gen(md5_origin, format, id, media_version)
}
async function m3u8(type, id, format, access_token) {
async function m3u8(type, id, format, access_token, tagging) {
const response = await fetch(`https://api.deezer.com/${type}/${id}?access_token=${access_token}&limit=-1`)
const json = await response.json()
if (json.error !== undefined) {
@ -182,10 +182,15 @@ async function m3u8(type, id, format, access_token) {
var list = '#EXTM3U\n'
for (const track of json.tracks.data) {
const result = await track_url(track, format)
let result
if (!tagging) {
result = await track_url(track, format)
if (typeof result === 'object') {
return result
}
} else {
result = `https://dz.uhwot.workers.dev/track/${track.id}?f=${format}&t=true`
}
list += `#EXTINF:${track.duration},${track.title}\n${result}\n`
}