some code cleanup

This commit is contained in:
uh wot 2021-09-01 22:20:58 +02:00
parent 695fd9ebc2
commit 5046b57c6c
Signed by: uhwot
GPG Key ID: CB2454984587B781
1 changed files with 32 additions and 32 deletions

View File

@ -6,35 +6,35 @@ addEventListener('fetch', event => {
})
const format_string_to_num = {
'aac_96': '8',
'64': '10',
'128': '1',
'320': '3',
'flac': '9',
'mp4_ra1': '13',
'mp4_ra2': '14',
'mp4_ra3': '15',
'mhm1_ra1': '16',
'mhm1_ra2': '17',
'mhm1_ra3': '18',
'sbc_256': '12',
'misc': '0',
aac_96: '8',
64: '10',
128: '1',
320: '3',
flac: '9',
mp4_ra1: '13',
mp4_ra2: '14',
mp4_ra3: '15',
mhm1_ra1: '16',
mhm1_ra2: '17',
mhm1_ra3: '18',
sbc_256: '12',
misc: '0',
}
const format_string_to_gw = {
'aac_96': 'AAC_96',
'64': 'MP3_64',
'128': 'MP3_128',
'320': 'MP3_320',
'flac': 'FLAC',
'mp4_ra1': 'MP4_RA1',
'mp4_ra2': 'MP4_RA2',
'mp4_ra3': 'MP4_RA3',
'mhm1_ra1': 'MHM1_RA1',
'mhm1_ra2': 'MHM1_RA2',
'mhm1_ra3': 'MHM1_RA3',
'sbc_256': 'SBC_256',
'misc': 'MP3_MISC',
aac_96: 'AAC_96',
64: 'MP3_64',
128: 'MP3_128',
320: 'MP3_320',
flac: 'FLAC',
mp4_ra1: 'MP4_RA1',
mp4_ra2: 'MP4_RA2',
mp4_ra3: 'MP4_RA3',
mhm1_ra1: 'MHM1_RA1',
mhm1_ra2: 'MHM1_RA2',
mhm1_ra3: 'MHM1_RA3',
sbc_256: 'SBC_256',
misc: 'MP3_MISC',
}
async function gw_api_call(method, params) {
@ -66,7 +66,7 @@ async function gw_api_call(method, params) {
return new Response(JSON.stringify(json.error), { status: 500, headers: { 'content-type': 'application/json' } })
}
if (method === "deezer.getUserData") {
if (method === 'deezer.getUserData') {
checkForm = json.results.checkForm
await KV.put('checkForm', checkForm)
@ -158,10 +158,10 @@ async function track(id, format, tagging) {
license_token: license_token,
media: [
{
type: "FULL",
type: 'FULL',
formats: [
{
cipher: "BF_CBC_STRIPE",
cipher: 'BF_CBC_STRIPE',
format: format_string_to_gw[format]
}
]
@ -220,7 +220,7 @@ async function track(id, format, tagging) {
id3.setFrame('TPOS', json.DISK_NUMBER)
}
if (json.ISRC !== "") {
if (json.ISRC !== '') {
id3.setFrame('TSRC', json.ISRC)
}
@ -230,7 +230,7 @@ async function track(id, format, tagging) {
id3.setFrame('TDAT', split[2] + split[1])
}
if (json.ALB_PICTURE !== "") {
if (json.ALB_PICTURE !== '') {
const url = `https://cdns-images.dzcdn.net/images/cover/${json.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg`
const cover = await fetch(url)
const coverBuffer = await cover.arrayBuffer()
@ -320,7 +320,7 @@ async function m3u8(type, id, format, tagging, host) {
const response = await fetch(`https://api.deezer.com/${type}/${id}?limit=-1`)
const json = await response.json()
if (json.error !== undefined) {
return new Response(JSON.stringify(json.error), { status: 403, headers: { 'content-type': "application/json" } })
return new Response(JSON.stringify(json.error), { status: 403, headers: { 'content-type': 'application/json' } })
}
let list = '#EXTM3U\n'