diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-02-10 11:16:07 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-02-10 11:16:07 +0800 |
commit | 9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3 (patch) | |
tree | 339de0698c13e1763d3361d70fb1266621025c91 /libs/music/player.d/cgi-bin | |
download | web-9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3.tar.xz |
Initial commit.
Diffstat (limited to 'libs/music/player.d/cgi-bin')
-rw-r--r-- | libs/music/player.d/cgi-bin/.htaccess | 3 | ||||
-rwxr-xr-x | libs/music/player.d/cgi-bin/m3u8.cgi | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/libs/music/player.d/cgi-bin/.htaccess b/libs/music/player.d/cgi-bin/.htaccess new file mode 100644 index 0000000..e861984 --- /dev/null +++ b/libs/music/player.d/cgi-bin/.htaccess @@ -0,0 +1,3 @@ +Options +ExecCGI +AddHandler cgi-script cgi + diff --git a/libs/music/player.d/cgi-bin/m3u8.cgi b/libs/music/player.d/cgi-bin/m3u8.cgi new file mode 100755 index 0000000..c90871c --- /dev/null +++ b/libs/music/player.d/cgi-bin/m3u8.cgi @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import cgi +import urllib.parse +d=cgi.parse() +try: + plist=d['plist'][0] + f=open(f'/var/www/html/libs/music/player.d/playlists/{plist}.playlist','r',encoding='UTF-8') +except (OSError,KeyError) as e: + print('Status: 400 Bad Request',end='\r\n') + print('Content-type: text/plain',end='\r\n') + print(end='\r\n') + print('400. Shit.') + print(e) + exit() +print('Status: 200 OK',end='\r\n') +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','wav','flac'] else 'ogg' +except KeyError: + fmt='ogg' +for line in f: + print(f'https://filestorage.chrisoft.org/music/{fmt}/{urllib.parse.quote(line.strip())}.{fmt}') +f.close() |