Commit | Line | Data |
---|---|---|
b61367d1 | 1 | #!/usr/bin/python3 |
51a600c2 CE |
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 | ||
51a600c2 CE |
21 | import cgi, cgitb |
22 | from datetime import datetime | |
23 | import hashlib | |
24 | import numbers | |
25 | import os | |
26 | import random | |
27 | import subprocess | |
b61367d1 CE |
28 | import sys |
29 | from kodijson import Kodi | |
51a600c2 CE |
30 | from yattag import Doc |
31 | ||
32 | import partyparty | |
33 | from partyparty import Song, SongControls, Search, Playlist, PartyManager | |
34 | ||
35 | cgitb.enable() | |
36 | ||
37 | print ("content-type: text/html; charset=utf-8\n\n") | |
38 | sys.stdout.flush () | |
39 | print ("<!DOCTYPE html>\n<html><head><title>partyparty beb</title></head><body>") | |
40 | print (partyparty.css ()) | |
7517b9d5 CE |
41 | # Override max-width of song since controls will be zero width |
42 | print ('<style>.flex_row p { font-size: 175%; max-width: 100% !important; min-width: 50% }</style>'); | |
43 | ||
44 | PAGE_SELF = os.environ['SCRIPT_NAME'].rsplit('/', 1)[-1] if 'SCRIPT_NAME' in os.environ else '' | |
45 | ||
46 | 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">reload</a> | <a href="normals.cgi?browseartists=1">browse library</a>') | |
51a600c2 | 47 | |
51a600c2 CE |
48 | |
49 | ||
50 | ||
51 | class NormalsPlaylist (Playlist): | |
52 | def get_playlist (self): | |
b61367d1 | 53 | return Playlist.get_playlist (self)#[0:10] |
51a600c2 CE |
54 | |
55 | class NormalsManager (PartyManager): | |
56 | DEFAULT_QUEUE_DIVISOR = 1 | |
57 | ||
b61367d1 | 58 | xbmc = partyparty.connect (Kodi ("http://localhost:8080/jsonrpc")) |
51a600c2 CE |
59 | |
60 | manager = NormalsManager (cgi.FieldStorage ()) | |
61 | manager.process () | |
62 | playlist = NormalsPlaylist () | |
63 | ||
64 | print ('<a name="search"></a>') | |
65 | Search ().show_quick_search (thereal=True) | |
66 | ||
67 | print ('<a name="playlist"></a><h1>What\'s Playing</h1>') | |
68 | print (playlist.show (controls = [])) | |
69 | ||
70 | print ('</body></html>') |