blob: 506ce0ec6377845a4e2040bb5e5909da148104ac (
plain) (
tree)
|
|
#!/usr/bin/python3
import cgi
import os
import urllib.parse
d=cgi.parse()
try:
plist=d['plist'][0]
f=open(f'{os.environ["DOCUMENT_ROOT"]}/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','flac','opus','m4a'] 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()
|