added tagging to albums/playlists
This commit is contained in:
parent
3e4a929938
commit
47f2be13e5
File diff suppressed because one or more lines are too long
15
index.js
15
index.js
|
@ -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,9 +182,14 @@ 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)
|
||||
if (typeof result === 'object') {
|
||||
return result
|
||||
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`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue