-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.py
97 lines (79 loc) · 3.43 KB
/
default.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'''
ustvnow XBMC Plugin
Copyright (C) 2011 t0mm0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from resources.lib import Addon, ustvnow
import sys
import urllib
import xbmc, xbmcgui, xbmcplugin
Addon.plugin_url = sys.argv[0]
Addon.plugin_handle = int(sys.argv[1])
Addon.plugin_queries = Addon.parse_query(sys.argv[2][1:])
email = Addon.get_setting('email')
password = Addon.get_setting('password')
ustv = ustvnow.Ustvnow(email, password)
Addon.log('plugin url: ' + Addon.plugin_url)
Addon.log('plugin queries: ' + str(Addon.plugin_queries))
Addon.log('plugin handle: ' + str(Addon.plugin_handle))
mode = Addon.plugin_queries['mode']
if mode == 'main':
Addon.log(mode)
Addon.add_directory({'mode': 'live'}, Addon.get_string(30001))
Addon.add_directory({'mode': 'recordings'}, Addon.get_string(30002))
elif mode == 'live':
Addon.log(mode)
stream_type = ['rtmp', 'rtsp'][int(Addon.get_setting('stream_type'))]
channels = ustv.get_channels(int(Addon.get_setting('quality')),
stream_type)
for c in channels:
Addon.add_video_item(c['url'],
{'title': '%s - %s' % (c['name'],
c['now']['title']),
'plot': c['now']['plot']},
img=c['icon'])
elif mode == 'recordings':
Addon.log(mode)
stream_type = ['rtmp', 'rtsp'][int(Addon.get_setting('stream_type'))]
recordings = ustv.get_recordings(int(Addon.get_setting('quality')),
stream_type)
for r in recordings:
cm_del = (Addon.get_string(30003),
'XBMC.RunPlugin(%s/?mode=delete&del=%s)' %
(Addon.plugin_url, urllib.quote(r['del_url'])))
title = '%s (%s on %s)' % (r['title'], r['rec_date'], r['channel'])
Addon.add_video_item(r['stream_url'], {'title': title,
'plot': r['plot']},
img=r['icon'], cm=[cm_del], cm_replace=True)
elif mode == 'delete':
dialog = xbmcgui.Dialog()
ret = dialog.yesno(Addon.get_string(30000), Addon.get_string(30004),
Addon.get_string(30005))
if ret == 1:
ustv.delete_recording(Addon.plugin_queries['del'])
elif mode=='play':
name = Addon.plugin_queries['name']
print "Play USTVNOW"
try:
stream_type = 'rtmp'
channels = []
quality = int(Addon.get_setting('quality'))
channels = ustv.get_channels(quality,stream_type)
for c in channels:
if c['name'] == name:
print "URL = "+c['url']
print "setResolvedUrl"
item = xbmcgui.ListItem(path=c['url'])
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
except:
pass
Addon.end_of_directory()