d05378bb6b0f1854321ccbabb300c4e2d4043a16
[clinton/unknownlamer-kodi-addons.git] / party-upload / normals.cgi
1 #!/usr/bin/python
2
3 # Simple PartyMode Web Console
4 # Limited interface for normal party goers
5 # Copyright (c) 2015,2016 Clinton Ebadi <clinton@unknownlamer.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 # limit playlist view to next five
20
21 import sys
22 reload(sys)
23 sys.setdefaultencoding ('utf-8')
24
25 import cgi, cgitb
26 from datetime import datetime
27 import hashlib
28 import numbers
29 import os
30 import random
31 import subprocess
32 from xbmcjson import XBMC
33 from yattag import Doc
34
35 import partyparty
36 from partyparty import Song, SongControls, Search, Playlist, PartyManager
37
38 cgitb.enable()
39
40 print ("content-type: text/html; charset=utf-8\n\n")
41 sys.stdout.flush ()
42 print ("<!DOCTYPE html>\n<html><head><title>partyparty beb</title></head><body>")
43 print (partyparty.css ())
44
45 print '<p style="font-size: 5rem"><a href="upload.html">Upload A Song</a> | <a href="youtube.html">Add From YouTube</a> | <a href="normals.cgi">home</a> | <a href="normals.cgi?browseartists=1">browse</a></p>'
46
47
48
49 class NormalsPlaylist (Playlist):
50 def get_playlist (self):
51 return Playlist.get_playlist (self)[0:6]
52
53 class NormalsManager (PartyManager):
54 DEFAULT_QUEUE_DIVISOR = 1
55
56 xbmc = partyparty.connect (XBMC ("http://localhost:8080/jsonrpc"))
57
58 manager = NormalsManager (cgi.FieldStorage ())
59 manager.process ()
60 playlist = NormalsPlaylist ()
61
62 print ('<a name="search"></a>')
63 Search ().show_quick_search (thereal=True)
64
65 print ('<a name="playlist"></a><h1>What\'s Playing</h1>')
66 print (playlist.show (controls = []))
67
68 print ('</body></html>')