summaryrefslogtreecommitdiff
path: root/libs/music/player.d/cgi-bin
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-14 22:45:27 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-14 22:45:27 +0800
commit98c5434a32cc546937550726aebf3cbc1b1b6b9e (patch)
tree61cceb107483b8246c2dacd88c10045b1683a3d0 /libs/music/player.d/cgi-bin
parent2702467eda7328115d827656e3804e063fe2341c (diff)
downloadweb-98c5434a32cc546937550726aebf3cbc1b1b6b9e.tar.xz
Pineapple Cloud Music.
Diffstat (limited to 'libs/music/player.d/cgi-bin')
-rwxr-xr-xlibs/music/player.d/cgi-bin/pcm.cgi31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/music/player.d/cgi-bin/pcm.cgi b/libs/music/player.d/cgi-bin/pcm.cgi
new file mode 100755
index 0000000..65aa0a6
--- /dev/null
+++ b/libs/music/player.d/cgi-bin/pcm.cgi
@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+import sys,os,cgi,json
+from urllib.parse import quote
+d=cgi.parse(fp=sys.stdin)
+
+print('Status: 200 OK',end='\r\n')
+print('Content-type: application/json',end='\r\n')
+print(end='\r\n')
+
+ro={'status':200,'message':'OK'}
+if 'folder' not in d or d['folder']=='':
+ plp=os.environ['DOCUMENT_ROOT']+'/libs/music/player.d/playlists/playlists'
+ alblist=list()
+ with open(plp,mode='r',encoding='utf-8') as f:
+ for line in f:
+ line=line.strip()
+ if len(line)>0:alblist.append(quote(line))
+ rro={'type':'fileList','data':{'subFolderList':alblist}}
+ ro['result']=rro
+ print(json.dumps(ro))
+else:
+ alp=os.environ['DOCUMENT_ROOT']+'/libs/music/player.d/playlists/'+d['folder'][0].strip('/')+'.playlist'
+ alblist=list()
+ with open(alp,mode='r',encoding='utf-8') as f:
+ for line in f:
+ line=line.strip()
+ if len(line)>0:
+ alblist.append({'fileName':quote(line),'fileSize':0,'modifiedTime':0})
+ rro={'type':'fileList','data':{'musicList':alblist[1:],'subFolderList':list()}}
+ ro['result']=rro
+ print(json.dumps(ro))