diff options
Diffstat (limited to 'libs/music')
-rwxr-xr-x | libs/music/player.d/cgi-bin/m3u8.cgi | 7 | ||||
-rwxr-xr-x | libs/music/player.d/cgi-bin/pcm.cgi | 2 | ||||
-rw-r--r-- | libs/music/player.d/main_static.js | 8 |
3 files changed, 10 insertions, 7 deletions
diff --git a/libs/music/player.d/cgi-bin/m3u8.cgi b/libs/music/player.d/cgi-bin/m3u8.cgi index 506ce0e..3e463ca 100755 --- a/libs/music/player.d/cgi-bin/m3u8.cgi +++ b/libs/music/player.d/cgi-bin/m3u8.cgi @@ -18,9 +18,10 @@ print('Content-type: audio/mpegurl',end='\r\n') print(end='\r\n') f.readline() try: - fmt=d['type'][0] if d['type'][0] in ['ogg','flac','opus','m4a'] else 'ogg' + fmt=d['type'][0] if d['type'][0] in ['vorbis','flac','opus','m4a'] else 'vorbis' except KeyError: - fmt='ogg' + fmt='vorbis' +ext='ogg' if fmt == 'vorbis' else fmt for line in f: - print(f'https://filestorage.chrisoft.org/music/{fmt}/{urllib.parse.quote(line.strip())}.{fmt}') + print(f'https://filestorage.chrisoft.org/music/{fmt}/{urllib.parse.quote(line.strip())}.{ext}') f.close() diff --git a/libs/music/player.d/cgi-bin/pcm.cgi b/libs/music/player.d/cgi-bin/pcm.cgi index 34539ad..460b1db 100755 --- a/libs/music/player.d/cgi-bin/pcm.cgi +++ b/libs/music/player.d/cgi-bin/pcm.cgi @@ -4,7 +4,7 @@ from urllib.parse import quote,unquote def getfilelist(d): fmt='ogg' if 'fmt' not in d else d['fmt'] - AUDIO_BASE='//filestorage.chrisoft.org/music/ogg/' + AUDIO_BASE='//filestorage.chrisoft.org/music/vorbis/' ro={'status':200,'message':'OK'} if 'folder' not in d or d['folder']=='': diff --git a/libs/music/player.d/main_static.js b/libs/music/player.d/main_static.js index 9fc5bbe..4e7b8f5 100644 --- a/libs/music/player.d/main_static.js +++ b/libs/music/player.d/main_static.js @@ -47,7 +47,7 @@ NSPlayer={ current:null, shuffle:0, repeat:0, - served_formats:{'vorbis':{'mime':'audio/ogg; codecs=vorbis','disp':'ogg 224 kbps'},'flac':{'mime':'audio/flac','disp':'flac'},'opus':{'mime':'audio/ogg; codecs=opus','disp':'opus 96 kbps'},'m4a':{'mime':'audio/aac','disp':'aac 192kbps'}}, + served_formats:{'vorbis':{'mime':'audio/ogg; codecs=vorbis','disp':'ogg 224 kbps','ext':'ogg'},'flac':{'mime':'audio/flac','disp':'flac'},'opus':{'mime':'audio/ogg; codecs=opus','disp':'opus 96 kbps'},'m4a':{'mime':'audio/aac','disp':'aac 192kbps'}}, get_preferred_or_default_format:function() { if (sh.getcookie('preferredformat') in this.served_formats) @@ -91,7 +91,8 @@ NSPlayer={ navigator.mediaSession.metadata=new MediaMetadata({title:this.tracks[id].title,album:this.plistname}); NSUI.set_highlighted(this.plistname,this.tracks[id].title); const fmt=NSPlayer.get_preferred_or_default_format(); - NSUI.audio.src=`//filestorage.chrisoft.org/music/${fmt}/${this.tracks[id].title}.${fmt}`; + const ext=(NSPlayer.served_formats[fmt].ext !== undefined) ? NSPlayer.served_formats[fmt].ext : fmt; + NSUI.audio.src=`//filestorage.chrisoft.org/music/${fmt}/${this.tracks[id].title}.${ext}`; NSUI.audio.load(); return NSUI.audio.play(); }, @@ -343,7 +344,8 @@ NSUI={ const a=sh.newelem('a'); a.innerHTML=list[i].title; const fmt=NSPlayer.get_preferred_or_default_format(); - a.href=`//filestorage.chrisoft.org/music/${fmt}/${list[i].title}.${fmt}`; + const ext=(NSPlayer.served_formats[fmt].ext !== undefined) ? NSPlayer.served_formats[fmt].ext : fmt; + a.href=`//filestorage.chrisoft.org/music/${fmt}/${list[i].title}.${ext}`; a.ord=i; a.onclick=function(e){e.preventDefault();NSUI.switch_track.bind(NSUI,this.ord)();}; l.appendChild(a); |