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
11
index.js
11
index.js
|
@ -91,7 +91,7 @@ async function handler(type, request) {
|
||||||
return await track(id, format, access_token, tagging)
|
return await track(id, format, access_token, tagging)
|
||||||
case 'album':
|
case 'album':
|
||||||
case 'playlist':
|
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)
|
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 response = await fetch(`https://api.deezer.com/${type}/${id}?access_token=${access_token}&limit=-1`)
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
if (json.error !== undefined) {
|
if (json.error !== undefined) {
|
||||||
|
@ -182,10 +182,15 @@ async function m3u8(type, id, format, access_token) {
|
||||||
var list = '#EXTM3U\n'
|
var list = '#EXTM3U\n'
|
||||||
|
|
||||||
for (const track of json.tracks.data) {
|
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') {
|
if (typeof result === 'object') {
|
||||||
return result
|
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`
|
list += `#EXTINF:${track.duration},${track.title}\n${result}\n`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue