-
Notifications
You must be signed in to change notification settings - Fork 4
/
default.py
679 lines (600 loc) · 30.3 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
'''
FilmOn plugin for XBMC
Copyright (C) 2012 FilmOn.com
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/>.
'''
import urllib,urllib2,re,xbmcplugin,xbmcgui,xbmcaddon,xbmc,os
from datetime import date
from datetime import datetime
import settings
from hashlib import md5
import json
from threading import Timer
from t0mm0.common.net import Net
net = Net()
ADDON = xbmcaddon.Addon(id='plugin.video.filmon')
resolution=ADDON.getSetting('res')
language = ADDON.getLocalizedString
#Global Constants
USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
channel= 'http://www.filmon.com/channel/'
logo = 'http://static.filmon.com/couch/channels/'
api ='http://www.filmon.com/api/'
tvapi='http://www.filmon.com/tv/api/'
user=ADDON.getSetting('user')
passs=ADDON.getSetting('pass')
password = md5(passs).hexdigest()
keep_alive='http://www.filmon.com/api/keep-alive?session_key='
filmon='http://www.filmon.com/tv/themes/filmontv/img/mobile/filmon-logo-stb.png'
hubpath = xbmc.translatePath(os.path.join('special://home/addons', ''))
hubrepo=os.path.join(hubpath, 'repository.xbmchub')
mikey=os.path.join(hubpath, 'repository.Mikey1234')
if os.path.exists(mikey)==True:
for root, dirs, files in os.walk(mikey):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
os.rmdir(mikey)
def DownloaderClass(url,dest):
dp = xbmcgui.DialogProgress()
dp.create("FilmON","Please Wait While We Get You Prepared",'For FilmOns New Repo ','Thank You For Your Patience')
urllib.urlretrieve(url,dest,lambda nb, bs, fs, url=url: _pbhook(nb,bs,fs,url,dp))
def _pbhook(numblocks, blocksize, filesize, url=None,dp=None):
try:
percent = min((numblocks*blocksize*100)/filesize, 100)
print 'Downloaded '+str(percent)+'%'
dp.update(percent)
except:
percent = 100
dp.update(percent)
if dp.iscanceled():
print "DOWNLOAD CANCELLED" # need to get this part working
dp.close()
try:
dialog = xbmcgui.Dialog()
dialog.ok("FilmON", "FilmOn Is Moving Repo We Will Download", "The New Repo To get You Prepared")
if os.path.exists(hubrepo)==False:
print '############################################################ INSTALL XBMCHUB REPO ###############################################################'
url = 'http://xbmc-hub-repo.googlecode.com/svn/addons/repository.xbmchub/repository.xbmchub-1.0.1.zip'
path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
lib=os.path.join(path, 'repository.xbmchub-1.0.1.zip')
DownloaderClass(url,lib)
addonfolder = xbmc.translatePath(os.path.join('special://home/addons',''))
xbmc.executebuiltin("XBMC.Extract(%s,%s)"%(lib,addonfolder))
dialog = xbmcgui.Dialog()
dialog.ok("FilmON", "Please Reboot To Take Effect", "Brought To You By XBMCHUB.COM")
except:
pass
def keepAlive():
validWin = xbmcgui.getCurrentWindowId() in [10025, 12005]
if not validWin:
print '=======================Ending Session======================='
sess = xbmcgui.Window(10000).getProperty("SessionID")
logout=api+'logout?session_key=%s' % (sess)
req =urllib2.Request(logout)
response = urllib2.urlopen(req)
link=response.read()
response.close()
print '===============LOGGED OUT !!==============='
xbmcgui.Window(10000).clearProperty("SessionID")
return
ses = xbmcgui.Window(10000).getProperty("SessionID")
print '=======================KEEPING THE SESSION ALIVE =%s !!==========================='%(ses)
urllib2.urlopen(keep_alive+ses)
t = Timer(60.0, keepAlive)
t.start()
if not xbmcgui.Window(10000).getProperty("SessionID"):
#Starting Session
url= api+'init/'
req = urllib2.Request(url)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
match= re.compile('"session_key":"(.+?)"').findall (link)
sess=match[0]
if ADDON.getSetting('filmon') == 'true':
log=api+'login?session_key=%s&login=%s&password=%s' % (sess,user,password)
req =urllib2.Request(log)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
response.close()
xbmcgui.Window(10000).setProperty("SessionID", sess)
keepAlive()
print '=======================LOGGED IN !! ==========================='
if ADDON.getSetting('filmon') == 'false':
xbmcgui.Window(10000).setProperty("SessionID", sess)
keepAlive()
print '=======================NOT LOGGED IN !! ==========================='
if ADDON.getSetting('filmon') == 'true':
ADDON.setSetting(id='firstrun', value='true')
ses = xbmcgui.Window(10000).getProperty("SessionID")
def GROUPS():
if ADDON.getSetting('filmon') == 'true':
ADD_DIRECTORY_ITEM(language(30059),'url',5,'http://www.filmon.com/tv/themes/filmontv/img/mobile/filmon-logo-stb.png','','','','','','','','','')
if ADDON.getSetting('filmon') == 'true':
ADD_DIRECTORY_ITEM(language(30060),'url',9,'http://www.filmon.com/tv/themes/filmontv/images/category/favorites_stb.png','','','','','','','','','')
grp='http://www.filmon.com/api/groups?session_key=%s' % (ses)
link = net.http_GET(grp).content
data = json.loads(link)
for field in data:
url = field['group_id']
name = field['group']
iconimage= field['logo_148x148_uri']
name = name.encode("utf-8")
ADD_DIRECTORY_ITEM(name,url,3,iconimage,'','','','','','','','',name)
setView('tvshows', 'default')
def CHANNELS(name,url,group):
if ADDON.getSetting('firstrun') == 'false':
dialog = xbmcgui.Dialog()
if dialog.yesno(language(30021),language(30022),'',language(30023),language(30024),language(30025)):
if dialog.yesno(language(30021),'',' ',language(30026),language(30027),language(30028)):
keyemail = None
keyboard = xbmc.Keyboard('', language(30307))
keyboard.doModal()
if keyboard.isConfirmed():
keyemail = keyboard.getText()
if keyemail == None:
return False
keypassword = None
keyboard = xbmc.Keyboard('', language(30308))
keyboard.doModal()
if keyboard.isConfirmed():
keypassword = keyboard.getText()
if keypassword == None:
return False
try:
res='http://www.filmon.com/api/register?session_key=%s&email=%s&password=%s' % (ses,keyemail,keypassword)
req = urllib2.Request(res)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
if re.search((keyemail),link):
ADDON.setSetting('user', value=keyemail)
ADDON.setSetting('pass', value=keypassword)
ADDON.setSetting(id='firstrun', value='true')
ADDON.setSetting(id='filmon', value='true')
except:
dialog.ok(language(30021), language(30029), language(30030),language(30031))
try:
country=settings.RETURN_COUNTRIES(url)
city = ''
keyboard = xbmc.Keyboard('', language(30309))
keyboard.doModal()
if keyboard.isConfirmed():
city = keyboard.getText()
if city == None:
return False
values ={"country":country,"city":city}
res='http://www.filmon.com/api/accountLocation?session_key=%s' % (ses)
data = urllib.urlencode(values)
req = urllib2.Request(res,data)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
if re.search('Accepted',link):
dialog.ok(language(30021),language(30032), "",language(30033))
except:
dialog.ok(language(30021),language(30034),language(30035),language(30036))
else:
keyemail = None
keyboard = xbmc.Keyboard('', language(30307))
keyboard.doModal()
if keyboard.isConfirmed():
keyemail = keyboard.getText()
if keyemail == None:
return False
keypassword = None
keyboard = xbmc.Keyboard('', language(30308))
keyboard.doModal()
if keyboard.isConfirmed():
keypassword = keyboard.getText()
if keypassword == None:
return False
ADDON.setSetting('user', value=keyemail)
ADDON.setSetting('pass', value=keypassword)
ADDON.setSetting(id='firstrun', value='true')
ADDON.setSetting(id='filmon', value='true')
dialog.ok(language(30021),language(30037), "",language(30038))
else:
ADDON.setSetting(id='firstrun', value='true')
r='http://www.filmon.com/api/group/%s?session_key=%s' % (url,ses)
html = net.http_GET(r).content
link = html.encode('ascii', 'ignore')
data = json.loads(link, encoding='utf8')
channels = data['channels']
for field in data['channels']:
programme_id = field["id"]
name = field["title"]
icon = field["big_logo"]
iconimage = str(icon).replace('/logo','/extra_big_logo')
description = ''
name = name.encode("utf-8")
ADD_DIRECTORY_ITEM(name,'url',12,iconimage,description,programme_id,'','','','tvguide',programme_id,'',group)
setView('episodes', 'default')
def GET_STREAM_RESOLUTION(channels,resolution,watch_timeout):
print channels
print '============ RESOLUTION IS SET TO %s ============='%(str(resolution).replace('0','LOW').replace('1','HIGH').replace('2','AUTO SELECTED'))
watch_timeout=str(watch_timeout)
if resolution == '0':
quality = 'LOW'
if not re.search('low',str(channels),re.IGNORECASE):
quality = 'HIGH'
if resolution == '1':
quality = 'HIGH'
if resolution == '2':
quality = 'LOW'
if len(watch_timeout)>5:
quality = 'HIGH'
if not re.search('low',str(channels),re.IGNORECASE):
quality = 'HIGH'
print '=========== STREAMING %s QUALITY ================'% (quality)
for item in channels:
if item['quality'].upper() == quality:
return item
return None
def GET_STREAMS(url):
ses=GET_SESSION_ID()
url='http://www.filmon.com/api/channel/%s?session_key=%s' % (url,ses)
print '============ GETTING NEW SESSION_ID = %s =================='%(ses)
link = net.http_GET(url).content
data = json.loads(link)
channels= data['streams']
watch_timeout= data['watch-timeout']
stream = GET_STREAM_RESOLUTION(channels,resolution,watch_timeout)
if stream is not None:
foregex= stream['url']+'<'
playpath=stream['name']
name=stream['quality']
if re.search('m4v',playpath ,re.IGNORECASE):
app = 'vodlast'
swfUrl= 'http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf'
url= stream['url']+'/'+playpath
else:
try:
regex = re.compile('rtmp://(.+?)/live/(.+?)id=(.+?)<')
match = regex.search(foregex)
app = 'live/%sid=%s' %(match.group(2),match.group(3))
url= stream['url']
swfUrl= 'http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf'
except:
pass
try:
regex = re.compile('rtmp://(.+?)/(.+?)id=(.+?)"')
match1 = regex.search(foregex)
app = '%sid=%s' %(match1.group(2), match1.group(3))
swfUrl='http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf?v=28'
except:
pass
try:
regex = re.compile('rtmp://(.+?)/(.+?)/<')
match = regex.search(foregex)
app = '%s/' %(match.group(2))
url= stream['url']+'/'+playpath
swfUrl= 'http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf'
except:
pass
tcUrl=stream['url']
pageUrl = 'http://www.filmon.com/'
url= str(url)+' playpath='+str(playpath)+' app='+str(app)+' swfUrl='+str(swfUrl)+' tcUrl='+str(tcUrl)+' pageurl='+str(pageUrl)
return url
def GET_RECORDINGS(url):
url='http://www.filmon.com/api/dvr-list?session_key=%s&format=json'%(ses)
print url
link = net.http_GET(url).content
data = json.loads(link)
recordings = data['recordings']
for field in recordings:
rec = field['id']
name = field['title']
desc = field['description']
channel = field['channel_id']
time = field['time_start']
status = field['status']
url= field['stream_url']
time=float(time)
desc = desc.encode('utf-8')
d=date.fromtimestamp(time).strftime("%d/%m/%Y")
description='[B][%s][/B]\n%s'%(d,desc)
iconimage='https://static.filmon.com/couch/channels/%s/extra_big_logo.png' % str(channel)
if status=='Recorded':
status=language(30050)
name='%s %s' %(status,name)
name = name.encode('utf-8')
ADD_RECORD_LINK(name,url,iconimage,description,'','','','delete','','',rec)
if status=='Accepted':
status=language(30051)
name='%s %s' %(status,name)
name = name.encode('utf-8')
ADD_RECORD_LINK(name,url,iconimage,description,'','','','delete','','',rec)
if status=='Recording':
status=language(30052)
name='%s %s' %(status,name)
name = name.encode('utf-8')
ADD_RECORD_LINK(name,url,iconimage,description,'','','','delete','','',rec)
if status=='Failed':
status=language(30053)
name='%s %s' %(status,name)
name = name.encode('utf-8')
ADD_RECORD_LINK(name,url,iconimage,description,'','','','delete','','',rec)
setView('movies', 'epg')
def RECORD_PROGRAMME(url,programme_id,startdate_time):
url ='http://filmon.com/api/dvr-add?session_key=%s&channel_id=%s&programme_id=%s&start_time=%s' % (ses,url,programme_id,startdate_time)
try:
link = net.http_GET(url).content
try:
if re.search('true',link ,re.IGNORECASE):
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),language(30039),' ',language(30040))
if re.search('false',link ,re.IGNORECASE):
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),language(30041),' ',language(30042))
except:
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),language(30040),language(30043),language(30044))
except:
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),language(30311),language(30312),language(30313))
def DELETE_RECORDING(startdate_time):
url='http://www.filmon.com/api/dvr-remove?session_key=%s&recording_id=%s'%(ses,startdate_time)
try:
link = net.http_GET(url).content
if re.search('Task is removed',link ,re.IGNORECASE):
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),language(30045),'',language(30046))
else:
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),'',language(30047),'')
except:
dialog = xbmcgui.Dialog()
dialog.ok(language(30021),'',language(30047),'')
def TV_GUIDE(url,iconimage):
url= 'http://www.filmon.com/api/channel/%s?session_key=%s' % (url,ses)
link = net.http_GET(url).content
data = json.loads(link)
tvguide = data['tvguide']
for field in tvguide:
programme_id= field["programme"]
startdate_time= field["startdatetime"]
enddate_time= field["enddatetime"]
day= field["date_of_month"]
cid= field["channel_id"]
desc= field["programme_description"]
name= field["programme_name"]
startdate_time_float=float(startdate_time)
enddate_time_float=float(enddate_time)
start=datetime.fromtimestamp(startdate_time_float)
end=datetime.fromtimestamp(enddate_time_float)
startdate_time_cleaned=start.strftime('%H:%M')
enddate_time_cleaned=end.strftime('%H:%M')
name = '[%s %s] [B]%s[/B]'%(day,startdate_time_cleaned,name)
iconimage='http://static.filmon.com/couch/channels/%s/extra_big_logo.png'%(cid)
name = name.encode('utf-8')
description = desc.encode('utf-8')
url =str(cid)
ADD_DIRECTORY_ITEM(name,url,2,iconimage,description,'','','record','','',programme_id,startdate_time,'')
setView('movies', 'epg')
def RETURN_CHANNEL_NAME_FAVOURITES(url):
r='http://www.filmon.com/api/channel/%s?session_key=%s'%(url,ses)
link = net.http_GET(r).content
data=json.loads(link)
name=data['title']
name=name.encode('utf-8')
return name
def GET_FAVOURITES(url):
grp='http://www.filmon.com/api/favorites?session_key=%s&run=get'% (ses)
link = net.http_GET(grp).content
data=json.loads(link)
result=data['result']
for field in result:
programme_id=field['channel_id']
iconimage='http://static.filmon.com/couch/channels/%s/extra_big_logo.png'%(programme_id)
name=RETURN_CHANNEL_NAME_FAVOURITES(programme_id)
ADD_DIRECTORY_ITEM(name,url,12,iconimage,'','',programme_id,'','','tvguide',programme_id,'','')
setView('movies', 'default')
def ADD_FAVOURITES(url):
dialog = xbmcgui.Dialog()
grp='http://www.filmon.com/api/favorites?session_key=%s&channel_id=%s&run=add'%(ses,url)
link = net.http_GET(grp).content
dialog.ok(language(30021),language(30048),' ','')
def DELETE_FAVOURITES(url):
dialog = xbmcgui.Dialog()
grp='http://www.filmon.com/api/favorites?session_key=%s&channel_id=%s&run=remove'%(ses,url)
link = net.http_GET(grp).content
dialog.ok(language(30021),language(30049),' ','')
def GET_SESSION_ID():
url= api+'init/'
req = urllib2.Request(url)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
match= re.compile('"session_key":"(.+?)"').findall (link)
sess=match[0]
if ADDON.getSetting('filmon') == 'true':
log=api+'login?session_key=%s&login=%s&password=%s' % (sess,user,password)
req =urllib2.Request(log)
req.add_header('User-Agent', USER_AGENT)
response = urllib2.urlopen(req)
link=response.read()
response.close()
xbmcgui.Window(10000).setProperty("SessionID", sess)
if ADDON.getSetting('filmon') == 'false':
xbmcgui.Window(10000).setProperty("SessionID", sess)
return sess
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
def ADD_DIRECTORY_ITEM(name,url,mode,iconimage,description, favorites, deletefav, record, deleterecord, tvguide,programme_id,startdate_time,group):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&description="+urllib.quote_plus(description)+"&programme_id="+urllib.quote_plus(programme_id)+"&startdate_time="+urllib.quote_plus(startdate_time)+"&group="+urllib.quote_plus(group)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png",thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot":description} )
menu = []
if favorites:
menu.append((language(30054),'XBMC.RunPlugin(%s?name=None&url=%s&mode=10&iconimage=None&description=None)'%(sys.argv[0],favorites)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if deletefav:
menu.append((language(30055),'XBMC.RunPlugin(%s?name=None&url=%s&mode=11&iconimage=None&description=None)'%(sys.argv[0],deletefav)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if record:
menu.append((language(30056),'XBMC.RunPlugin(%s?name=None&url=%s&mode=6&iconimage=None&description=None&programme_id=%s&startdate_time=%s)'%(sys.argv[0],url,programme_id,startdate_time)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if deleterecord:
menu.append((language(30057),'XBMC.RunPlugin(%s?name=None&url=None&mode=7&iconimage=None&description=None&startdate_time=%s)'%(sys.argv[0],startdate_time)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if tvguide:
menu.append((language(30058),'XBMC.Container.Update(%s?name=None&url=%s&mode=8&iconimage=%s&description=None)'%(sys.argv[0],programme_id,iconimage)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if not mode==12:
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
else:
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
return ok
def PLAY_STREAM_LINK(name,url,iconimage,description, favorites, deletefav, record, deleterecord,tvguide,programme_id,startdate_time,group):
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
liz.setProperty("IsPlayable","true")
dp = xbmcgui.DialogProgress()
dp.create("FilmOn",'Please Wait While We Load Your Stream','')
url = GET_STREAMS(programme_id)
pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
pl.clear()
pl.add(url, liz)
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(pl)
dp.close()
def ADD_RECORD_LINK(name,url,iconimage,description, favorites, deletefav, record, deleterecord,tvguide,programme_id,startdate_time):
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
liz.setProperty("IsPlayable","true")
menu = []
if favorites:
menu.append((language(30054),'XBMC.RunPlugin(%s?name=None&url=%s&mode=10&iconimage=None&description=None)'%(sys.argv[0],programme_id)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if deletefav:
menu.append((language(30055),'XBMC.RunPlugin(%s?name=None&url=%s&mode=11&iconimage=None&description=None)'%(sys.argv[0],programme_id)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if record:
menu.append((language(30056),'XBMC.RunPlugin(%s?name=None&url=%s&mode=6&iconimage=None&description=None&pid=%s&st=%s)'%(sys.argv[0],url,programme_id,startdate_time)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if deleterecord:
menu.append((language(30057),'XBMC.RunPlugin(%s?name=None&url=None&mode=7&iconimage=None&description=None&startdate_time=%s)'%(sys.argv[0],startdate_time)))
liz.addContextMenuItems(items=menu, replaceItems=True)
if tvguide:
menu.append((language(30058),'XBMC.Container.Update(%s?name=None&url=%s&mode=8&iconimage=%s&description=None)'%(sys.argv[0],programme_id,iconimage)))
liz.addContextMenuItems(items=menu, replaceItems=True)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=False)
def setView(content, viewType):
# set content type so library shows more views and info
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if ADDON.getSetting('auto-view') == 'true':
xbmc.executebuiltin("Container.SetViewMode(%s)" % ADDON.getSetting(viewType) )
params=get_params()
url=None
name=None
mode=None
iconimage=None
description=None
favorites=None
deletefav=None
record=None
deleterecord=None
programme_id=None
startdate_time=None
group=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
iconimage=urllib.unquote_plus(params["iconimage"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
try:
description=urllib.unquote_plus(params["description"])
except:
pass
try:
programme_id=urllib.unquote_plus(params["programme_id"])
except:
pass
try:
startdate_time=urllib.unquote_plus(params["startdate_time"])
except:
pass
try:
group=urllib.unquote_plus(params["group"])
except:
pass
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
print "IconImage: "+str(iconimage)
if mode==None or url==None or len(url)<1:
print ""
GROUPS()
elif mode==2:
print ""+url
GET_STREAMS(url,iconimage)
elif mode==3:
print ""+url
CHANNELS(name,url,group)
elif mode==4:
print ""+url
Channel_Lists(url)
elif mode==5:
print ""+url
GET_RECORDINGS(url)
elif mode==6:
print ""+url
RECORD_PROGRAMME(url,programme_id,startdate_time)
elif mode==7:
print ""+url
DELETE_RECORDING(startdate_time)
elif mode==8:
print ""+url
TV_GUIDE(url,iconimage)
elif mode==9:
print ""+url
GET_FAVOURITES(url)
elif mode==10:
print ""+url
ADD_FAVOURITES(url)
elif mode==11:
print ""+url
DELETE_FAVOURITES(url)
elif mode==12:
print ""+url
PLAY_STREAM_LINK(name,url,iconimage,description, favorites, deletefav, record, deleterecord,'',programme_id,startdate_time,group)
xbmcplugin.endOfDirectory(int(sys.argv[1]))