-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommon.py
More file actions
1229 lines (1092 loc) · 60.7 KB
/
common.py
File metadata and controls
1229 lines (1092 loc) · 60.7 KB
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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### ############################################################################################################
### #
### # Author: # The Highway
### # Description: # Common File For:
### #
### ############################################################################################################
### ############################################################################################################
### Imports ###
import xbmc,xbmcplugin,xbmcgui,xbmcaddon,xbmcvfs
import os,sys,string,StringIO,logging,random,array,time,datetime,re
import urllib,urllib2,htmllib
from config import *
#import urlresolver
#import copy
#try: import json
#except ImportError: import simplejson as json
#try: import StorageServer
#except: import storageserverdummy as StorageServer
#cache = StorageServer.StorageServer(plugin_id)
try: from addon.common.net import Net
except:
try: from t0mm0.common.net import Net
except:
try: from c_t0mm0_common_net import Net
except: pass
try: from addon.common.addon import Addon
except:
try: from t0mm0.common.addon import Addon
except:
try: from c_t0mm0_common_addon import Addon
except: pass
#try: from sqlite3 import dbapi2 as sqlite; print "Loading sqlite3 as DB engine"
#except: from pysqlite2 import dbapi2 as sqlite; print "Loading pysqlite2 as DB engine"
#try: from script.module.metahandler import metahandlers
#except: from metahandler import metahandlers
#import c_Extract as extract #extract.all(lib,addonfolder,dp)
#import cHiddenDownloader as downloader #downloader.download(url,destfile,destpath,useResolver=True)
### ############################################################################################################
__plugin__=ps('__plugin__'); __authors__=ps('__authors__'); __credits__=ps('__credits__');
### ############################################################################################################
##### Addon / Plugin Basic Setup #####
_addon_id=ps('_addon_id'); _plugin_id=ps('_addon_id');
try: _addon=Addon(ps('_addon_id'), sys.argv);
except: print"addon: sys.argv not found."; _addon=Addon(ps('_addon_id'), 0);
addon=_addon;
_plugin=xbmcaddon.Addon(id=ps('_addon_id'));
try:
try: import StorageServer as StorageServer
except:
try: import c_StorageServer as StorageServer
except:
try: import storageserverdummy as StorageServer
except:
try: import c_storageserverdummy as StorageServer
except: pass
cache=StorageServer.StorageServer(ps('_addon_id'))
except: pass
##### Paths #####
#_database_name=ps('_database_name')
#_database_file=os.path.join(xbmc.translatePath("special://database"),ps('_database_name')+'.db');
#DB=_database_file;
_domain_url=ps('_domain_url'); _du=ps('_domain_url');
_addonPath =xbmc.translatePath(_plugin.getAddonInfo('path'))
_artPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_art')))
_scrPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_scr')))
_bgmPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_bgm')))
_sndPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_snd')))
_datapath =xbmc.translatePath(_addon.get_profile());
_artIcon =_addon.get_icon();
_artFanart =_addon.get_fanart()
##### Important Functions with some dependencies #####
def addstv(id,value=''): _addon.addon.setSetting(id=id,value=value) ## Save Settings
def addst(r,s=''): return _addon.get_setting(r) ## Get Settings
def addpr(r,s=''): return _addon.queries.get(r,s) ## Get Params
def tfalse(r,d=False): ## Get True / False
if (r.lower()=='true' ) or (r.lower()=='t') or (r.lower()=='y') or (r.lower()=='1') or (r.lower()=='yes'): return True
elif (r.lower()=='false') or (r.lower()=='f') or (r.lower()=='n') or (r.lower()=='0') or (r.lower()=='no'): return False
else: return d
def tfalse_old(r,d=False): ## Get True / False
if (r.lower()=='true' ): return True
elif (r.lower()=='false'): return False
else: return d
def sndP(f,fe='.wav'):
y=sndP2(f,fe=fe)
if isFile(y)==False: y=sndP2(f,fe='.wav')
if isFile(y)==False: y=sndP2(f,fe='.ogg')
if isFile(y)==False: y=sndP2(f,fe='.MID')
if isFile(y)==False: y=sndP2(f,fe='.snd')
if isFile(y)==False: y=sndP2(f,fe='.mod')
if isFile(y)==False: y=sndP2(f,fe='.mp3')
if isFile(y)==False: y=''
return y ### for Making path+filename+ext data for Art Images. ###
def sndP2(f,fe='.wav'): return fixPath(xbmc.translatePath(os.path.join(_sndPath,f+fe))) ### for Making path+filename+ext data for Art Images. ###
def bgmP(f,fe='.ogg'): return xbmc.translatePath(os.path.join(_bgmPath,f+fe)) ### for Making path+filename+ext data for Art Images. ###
def ScrT(f,fe=''): return xbmc.translatePath(os.path.join(_scrPath,f+fe)) ### for Making path+filename+ext data for Art Images. ###
def art(f,fe=''): return xbmc.translatePath(os.path.join(_artPath,f+fe)) ### for Making path+filename+ext data for Art Images. ###
def artg(f,fe='.gif'): return art(f,fe)
def artb(f,fe='.bmp'): return art(f,fe)
def artp(f,fe='.png'): return art(f,fe)
def artj(f,fe='.jpg'): return art(f,fe)
##### Settings #####
_setting={};
_setting['enableMeta'] = _enableMeta =tfalse(addst("enableMeta"))
_setting['debug-enable']= _debugging =tfalse(addst("debug-enable"));
_setting['debug-show'] = _shoDebugging =tfalse(addst("debug-show"))
debugging=_debugging
##### Variables #####
_default_section_=ps('default_section');
net=Net();
BASE_URL=ps('_domain_url');
### ############################################################################################################
### ############################################################################################################
def eod(): _addon.end_of_directory()
def notification(header="", message="", sleep=5000 ): xbmc.executebuiltin( "XBMC.Notification(%s,%s,%i)" % ( header, message, sleep ) )
def myNote(header='',msg='',delay=5000,image='http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/US_99_%281961%29.svg/40px-US_99_%281961%29.svg.png'): _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
def cFL( t,c=ps('default_cFL_color')): return '[COLOR '+c+']'+t+'[/COLOR]' ### For Coloring Text ###
def cFL_(t,c=ps('default_cFL_color')): return '[COLOR '+c+']'+t[0:1]+'[/COLOR]'+t[1:] ### For Coloring Text (First Letter-Only) ###
def WhereAmI(t): ### for Writing Location Data to log file ###
if (_debugging==True): print 'Where am I: '+t
def deb(s,t): ### for Writing Debug Data to log file ###
if (_debugging==True): print s+': '+t
def debob(t): ### for Writing Debug Object to log file ###
if (_debugging==True): print t
def nolines(t):
it=t.splitlines(); t=''
for L in it: t=t+L
t=((t.replace("\r","")).replace("\n",""))
return t
def isPath(path): return os.path.exists(path)
def isFile(filename): return os.path.isfile(filename)
def getFileExtension(filename):
ext_pos = filename.rfind('.')
if ext_pos != -1: return filename[ext_pos+1:]
else: return ''
def get_immediate_subdirectories(directory):
return [name for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))]
def findInSubdirectory(filename, subdirectory=''):
if subdirectory: path = subdirectory
else: path = _addonPath
for root, _, names in os.walk(path):
if filename in names: return os.path.join(root, filename)
raise 'File not found'
def get_xbmc_os():
try: xbmc_os = os.environ.get('OS')
except: xbmc_os = "unknown"
return xbmc_os
def get_xbmc_version():
rev_re = re.compile('r(\d+)')
try: xbmc_version = xbmc.getInfoLabel('System.BuildVersion')
except: xbmc_version = 'Unknown'
return xbmc_version
def get_xbmc_revision():
rev_re = re.compile('r(\d+)')
try: xbmc_version = xbmc.getInfoLabel('System.BuildVersion')
except: xbmc_version = 'Unknown'
try: xbmc_rev=int(rev_re.search(xbmc_version).group(1)); deb("addoncompat.py: XBMC Revision",xbmc_rev)
except: xbmc_rev=0; deb("addoncompat.py: XBMC Revision not available - Version String",xbmc_version)
return xbmc_rev
def _SaveFile(path,data):
file=open(path,'w')
file.write(data)
file.close()
def _OpenFile(path):
deb('File',path)
if os.path.isfile(path): ## File found.
deb('Found',path)
file = open(path, 'r')
contents=file.read()
file.close()
return contents
else: return '' ## File not found.
def _OpenFileA(path):
deb('File',path)
if os.path.isfile(path): ## File found.
try:
f=open(path)
lines=f.readlines()
f.close()
return lines
except: return ''
else: return '' ## File not found.
def _CreateDirectory(dir_path):
dir_path = dir_path.strip()
if not os.path.exists(dir_path): os.makedirs(dir_path)
def _get_dir(mypath, dirname): #...creates sub-directories if they are not found.
subpath = os.path.join(mypath, dirname)
if not os.path.exists(subpath): os.makedirs(subpath)
return subpath
def askSelection(option_list=[],txtHeader=''):
if (option_list==[]):
debob('askSelection() >> option_list is empty')
return None
dialogSelect = xbmcgui.Dialog();
index=dialogSelect.select(txtHeader, option_list)
return index
def iFL(t): return '[I]'+t+'[/I]' ### For Italic Text ###
def bFL(t): return '[B]'+t+'[/B]' ### For Bold Text ###
def _FL(t,c,e=''): ### For Custom Text Tags ###
if (e==''): d=''
else: d=' '+e
return '['+c.upper()+d+']'+t+'[/'+c.upper()+']'
try:
def aSortMeth(sM,h=int(sys.argv[1])):
xbmcplugin.addSortMethod(handle=h, sortMethod=sM)
except:
def aSortMeth(sM,h=int(0)):
xbmcplugin.addSortMethod(handle=h, sortMethod=sM)
def set_view(content='none',view_mode=50,do_sort=False):
deb('content type: ',str(content))
deb('view mode: ',str(view_mode))
try: h=int(sys.argv[1])
except: h=int(0)
if (content is not 'none'): xbmcplugin.setContent(h, content)
if (tfalse(addst("auto-view"))==True): xbmc.executebuiltin("Container.SetViewMode(%s)" % str(view_mode))
def showkeyboard(txtMessage="",txtHeader="",passwordField=False):
if txtMessage=='None': txtMessage=''
keyboard = xbmc.Keyboard(txtMessage, txtHeader, passwordField)#("text to show","header text", True="password field"/False="show text")
keyboard.doModal()
if keyboard.isConfirmed():
return keyboard.getText()
else:
return False # return ''
def ParseDescription(plot): ## Cleans up the dumb number stuff thats ugly.
if ("&" in plot): plot=plot.replace('&' ,'&')#'
if (" " in plot): plot=plot.replace(' ' ," ")
if ('&#' in plot) and (';' in plot):
if ("–" in plot): plot=plot.replace("–","-") #unknown
if ("‘" in plot): plot=plot.replace("‘","'")
if ("’" in plot): plot=plot.replace("’","'")
if ("“" in plot): plot=plot.replace('“','"')
if ("”" in plot): plot=plot.replace('”','"')
if ("×" in plot): plot=plot.replace('×' ,'x')
if ("'" in plot): plot=plot.replace(''' ,"'")
if ("ô" in plot): plot=plot.replace('ô' ,"o")
if ("·" in plot): plot=plot.replace('·' ,"-")
if ("û" in plot): plot=plot.replace('û' ,"u")
if ("à" in plot): plot=plot.replace('à' ,"a")
if ("ƥ" in plot): plot=plot.replace('ƥ',"")
if ("é" in plot): plot=plot.replace('é' ,"e")
if ("â" in plot): plot=plot.replace('â' ,"a")
if ("&" in plot): plot=plot.replace('&' ,"&")
#if (chr(239) in plot): plot=plot.replace(chr(239) ,"'")
#plot=plot.replace(chr('0x92'),"'")
if ('&#' in plot) and (';' in plot):
try: matches=re.compile('&#(.+?);').findall(plot)
except: matches=''
if (matches is not ''):
for match in matches:
if (match is not '') and (match is not ' ') and ("&#"+match+";" in plot):
try: plot=plot.replace("&#"+match+";" ,"")
except: pass
#if ("\xb7" in plot): plot=plot.replace('\xb7' ,"-")
#if ('&#' in plot) and (';' in plot): plot=unescape_(plot)
for i in xrange(127,256):
try: plot=plot.replace(chr(i),"")
except: pass
return plot
def unescape_(s):
p = htmllib.HTMLParser(None)
p.save_bgn()
p.feed(s)
return p.save_end()
def messupText(t,_html=False,_ende=False,_a=False,Slashes=False):
if (_html==True):
try: t=HTMLParser.HTMLParser().unescape(t)
except: t=t
try: t=ParseDescription(t)
except: t=t
if (_ende==True):
try: t=t.encode('ascii', 'ignore'); t=t.decode('iso-8859-1')
except: t=t
if (_a==True):
try: t=_addon.decode(t); t=_addon.unescape(t)
except: t=t
if (Slashes==True):
try: t=t.replace( '_',' ')
except: t=t
#t=t.replace("text:u","")
return t
def nURL(url,method='get',form_data={},headers={},html='',proxy='',User_Agent='',cookie_file='',load_cookie=False,save_cookie=False):
if url=='': return ''
dhtml=''+html
if len(User_Agent) > 0: net.set_user_agent(User_Agent)
else: net.set_user_agent(ps('User-Agent'))
if len(proxy) > 9: net.set_proxy(proxy)
if (len(cookie_file) > 0) and (load_cookie==True): net.set_cookies(cookie_file)
if method.lower()=='get':
try: html=net.http_GET(url,headers=headers).content
except: html=dhtml
elif method.lower()=='post':
try: html=net.http_POST(url,form_data=form_data,headers=headers).content #,compression=False
except: html=dhtml
elif method.lower()=='head':
try: html=net.http_HEAD(url,headers=headers).content
except: html=dhtml
if (len(html) > 0) and (len(cookie_file) > 0) and (save_cookie==True): net.save_cookies(cookie_file)
return html
def BusyAnimationShow(): xbmc.executebuiltin('ActivateWindow(busydialog)')
def BusyAnimationHide(): xbmc.executebuiltin('Dialog.Close(busydialog,true)')
def closeAllDialogs(): xbmc.executebuiltin('Dialog.Close(all, true)')
def popYN(title='',line1='',line2='',line3='',n='',y=''):
diag=xbmcgui.Dialog()
r=diag.yesno(title,line1,line2,line3,n,y)
if r: return r
else: return False
#del diag
def popOK(msg="",title="",line2="",line3=""):
dialog=xbmcgui.Dialog()
#ok=dialog.ok(title, msg, line2, line3)
dialog.ok(title, msg, line2, line3)
def spAfterSplit(t,ss):
if ss in t: t=t.split(ss)[1]
return t
def spBeforeSplit(t,ss):
if ss in t: t=t.split(ss)[0]
return t
def TP(s): return xbmc.translatePath(s)
def TPap(s,fe='.py'): return xbmc.translatePath(os.path.join(_addonPath,s+fe))
def CopyAFile(tFrom,tTo):
try:
import shutil
shutil.copy(tFrom,tTo)
except: pass
def checkHostProblems(url,b=False,t=True):
if ('embed.yourupload.com/' in url) or ('novamov.com/' in url) or ('veevr.com/' in url): b=t
#if 'embed.yourupload.com/' in url: b=t
#elif 'novamov.com/' in url: b=t
return b
### #Metahandler
#try: from script.module.metahandler import metahandlers
#except: from metahandler import metahandlers
#grab=metahandlers.MetaData(preparezip=False)
#def GRABMETA(name,types):
# type=types
# EnableMeta=tfalse(addst("enableMeta"))
# if (EnableMeta==True):
# if ('movie' in type):
# ### grab.get_meta(media_type, name, imdb_id='', tmdb_id='', year='', overlay=6)
# meta=grab.get_meta('movie',name,'',None,None,overlay=6)
# infoLabels={'rating': meta['rating'],'duration': meta['duration'],'genre': meta['genre'],'mpaa':"rated %s"%meta['mpaa'],'plot': meta['plot'],'title': meta['title'],'writer': meta['writer'],'cover_url': meta['cover_url'],'director': meta['director'],'cast': meta['cast'],'backdrop': meta['backdrop_url'],'backdrop_url': meta['backdrop_url'],'tmdb_id': meta['tmdb_id'],'year': meta['year'],'votes': meta['votes'],'tagline': meta['tagline'],'premiered': meta['premiered'],'trailer_url': meta['trailer_url'],'studio': meta['studio'],'imdb_id': meta['imdb_id'],'thumb_url': meta['thumb_url']}
# #infoLabels={'rating': meta['rating'],'duration': meta['duration'],'genre': meta['genre'],'mpaa':"rated %s"%meta['mpaa'],'plot': meta['plot'],'title': meta['title'],'writer': meta['writer'],'cover_url': meta['cover_url'],'director': meta['director'],'cast': meta['cast'],'backdrop_url': meta['backdrop_url'],'backdrop_url': meta['backdrop_url'],'tmdb_id': meta['tmdb_id'],'year': meta['year']}
# elif ('tvshow' in type):
# meta=grab.get_meta('tvshow',name,'','',None,overlay=6)
# #print meta
# infoLabels={'rating': meta['rating'],'genre': meta['genre'],'mpaa':"rated %s"%meta['mpaa'],'plot': meta['plot'],'title': meta['title'],'cover_url': meta['cover_url'],'cast': meta['cast'],'studio': meta['studio'],'banner_url': meta['banner_url'],'backdrop_url': meta['backdrop_url'],'status': meta['status'],'premiered': meta['premiered'],'imdb_id': meta['imdb_id'],'tvdb_id': meta['tvdb_id'],'year': meta['year'],'imgs_prepacked': meta['imgs_prepacked'],'overlay': meta['overlay'],'duration': meta['duration']}
# #infoLabels={'rating': meta['rating'],'genre': meta['genre'],'mpaa':"rated %s"%meta['mpaa'],'plot': meta['plot'],'title': meta['title'],'cover_url': meta['cover_url'],'cast': meta['cast'],'studio': meta['studio'],'banner_url': meta['banner_url'],'backdrop_url': meta['backdrop_url'],'status': meta['status']}
# else: infoLabels={}
# else: infoLabels={}
# return infoLabels
def MetaGrab(media_type,meta_name,imdb_id='',tmdb_id='',year='',season='',episode=''):
default_infoLabels={'overlay':6,'title':meta_name,'tvdb_id':'','imdb_id':'','cover_url':_artIcon,'poster':_artIcon,'trailer_url':'','trailer':'','TVShowTitle':meta_name,'backdrop_url':_artFanart,'banner_url':''}
try: from metahandler import metahandlers
except: debob("filed to import metahandler"); return default_infoLabels
grab=metahandlers.MetaData(preparezip=False)
try: EnableMeta=tfalse(addst("enableMeta"))
except: EnableMeta=True
if (EnableMeta==True):
if ('movie' in media_type) or (media_type=='m'):
infoLabels=grab.get_meta("movie",meta_name,imdb_id=imdb_id,tmdb_id=tmdb_id,year=year)
elif ('tvshow' in media_type) or (media_type=='t'):
infoLabels=grab.get_meta("tvshow",meta_name,imdb_id=imdb_id)
elif ('episode' in media_type) or (media_type=='e'):
if len(imdb_id)==0:
t_infoLabels=grab.get_meta("tvshow",meta_name,imdb_id=imdb_id)
imdb_id=t_infoLabels['imdb_id']
try:
iseason=int(season)
iepisode=int(episode)
infoLabels=grab.get_episode_meta(tvshowtitle=meta_name,imdb_id=tv_meta['imdb_id'],season=iseason,episode=iepisode)
except: infoLabels={'overlay':6,'title':str(season)+'x'+str(episode),'tvdb_id':'','imdb_id':'','cover_url':_artIcon,'poster':_artIcon,'TVShowTitle':meta_name}
else: infoLabels=default_infoLabels
#
else: infoLabels=default_infoLabels
return infoLabels
#
### ############################################################################################################
class TextBox2: ## Usage Example: TextBox_FromUrl().load('https://raw.github.com/HIGHWAY99/plugin.video.theanimehighway/master/README.md')
WINDOW = 10147; CONTROL_LABEL = 1; CONTROL_TEXTBOX = 5; HEADER_MESSAGE = "%s - ( v%s )" % (__plugin__,addon.get_version()) # set heading
def load_url(self, URL_PATH, HEADER_MESSAGE2=''):
deb('text window from url: ',URL_PATH) #self.URL_PATH
try: text=nURL(URL_PATH)#(self.URL_PATH)
except: text=''
self.load_window(); self.set_header(HEADER_MESSAGE2); self.set_text(text)
def load_file(self, FILE_NAME='changelog.txt', HEADER_MESSAGE2='', FILE_PATH=_addonPath):
txt_path = os.path.join(FILE_PATH,FILE_NAME)
deb('text window from file: ',txt_path)
f = open(txt_path)
text = f.read()
self.load_window(); self.set_header(HEADER_MESSAGE2); self.set_text(text)
def load_string(self, text_string='', HEADER_MESSAGE2=''):
self.load_window(); self.set_header(HEADER_MESSAGE2); self.set_text(text_string)
def load_window(self, sleeptime=500):
xbmc.executebuiltin("ActivateWindow(%d)" % ( self.WINDOW, )) # activate the text viewer window
self.win = xbmcgui.Window(self.WINDOW) # get window
xbmc.sleep(sleeptime) # give window time to initialize
def set_header(self, HEADER_MESSAGE2=''):
if (HEADER_MESSAGE2==''): HEADER_MESSAGE2=self.HEADER_MESSAGE
self.win.getControl(self.CONTROL_LABEL).setLabel(HEADER_MESSAGE2)
def set_text(self, text=''):
self.win.getControl(self.CONTROL_TEXTBOX).setText(text)
def RefreshList(): xbmc.executebuiltin("XBMC.Container.Refresh")
def String2TextBox(message='',HeaderMessage=''): TextBox2().load_string(message,HeaderMessage); #RefreshList()
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
##### Player Functions #####
def PlayItCustomL(url,stream_url,img,title,studio=''):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
listitem=xbmcgui.ListItem(title,iconImage=img,thumbnailImage=img); listitem.setInfo('video',{'Title':title,'Genre':'Live','Studio':studio})
PL=xbmc.PlayList(xbmc.PLAYLIST_VIDEO); PL.clear(); #PL.add(stream_url,listitem)
#
html=nURL(stream_url); deb('Length of html',str(len(html)));
matches=re.compile('\n+\s*(.*?://.*)\s*\n+').findall(html)
#debob(matches)
if len(matches) > 0:
for match in matches:
#debob(match)
PL.add(match,listitem)
#
try: _addon.resolve_url(url)
except: t=''
try: play=xbmc.Player(PlayerMeth); play.play(PL)
except: t=''
def PlayItCustomL2A(url,stream_url,img,title,studio=''):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
listitem=xbmcgui.ListItem(title,iconImage=img,thumbnailImage=img); listitem.setInfo('video',{'Title':title,'Genre':'Live','Studio':studio})
PL=xbmc.PlayList(xbmc.PLAYLIST_VIDEO); PL.clear(); #PL.add(stream_url,listitem)
html=nURL(stream_url); deb('Length of html',str(len(html)));
html=html.replace('#EXT-X-STREAM-INF:PROGRAM-ID=','#EXT-X-STREAM-INF:NAME="'+title+'",PROGRAM-ID=')
PlaylistFile=xbmc.translatePath(os.path.join(_addonPath,'resources','playlist.txt')); debob(PlaylistFile)
_SaveFile(PlaylistFile,html)
PL.add(PlaylistFile,listitem)
try: _addon.resolve_url(url)
except: t=''
try: play=xbmc.Player(PlayerMeth); play.play(PL)
except: t=''
def PlayItCustom(url,stream_url,img,title,studio=''):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
listitem=xbmcgui.ListItem(thumbnailImage=img); listitem.setInfo('video',{'Title':title,'Genre':'Live','Studio':studio})
PL=xbmc.PlayList(xbmc.PLAYLIST_VIDEO); PL.clear(); PL.add(stream_url,listitem)
try: _addon.resolve_url(url)
except: t=''
try: play=xbmc.Player(PlayerMeth); play.play(PL)
except: t=''
def PlayURL(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
try: _addon.resolve_url(url)
except: t=''
try: play.play(url)
except: t=''
def PlayURLs(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
filename=xbmc.translatePath(os.path.join(_addonPath,'resources','test.strm'))
try: _addon.resolve_url(url)
except: pass
if ':' in url: uPre=url.split(':')[0]
else: uPre='____'
if (uPre.lower()=='mss') or (uPre.lower()=='mssh') or (uPre.lower()=='rtsp'):
_SaveFile(filename,url)
try: play.play(filename) #(url)
except: pass
elif (uPre.lower()=='http'):
import urlresolver
try:
stream_url=urlresolver.HostedMediaFile(url).resolve()
play.play(stream_url)
except:
try: play.play(url)
except: pass
else:
try: play.play(url)
except: pass
#
def PlayURLs2(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
filename=xbmc.translatePath(os.path.join(_addonPath,'resources','test.strm'))
try: _addon.resolve_url(url)
except: pass
if ':' in url: uPre=url.split(':')[0]
else: uPre='____'
if (uPre.lower()=='mss') or (uPre.lower()=='mssh') or (uPre.lower()=='rtsp'):
_SaveFile(filename,url)
try: play.play(filename) #(url)
except: pass
else:
try: play.play(url)
except: pass
def PlayURLstrm(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
filename=xbmc.translatePath(os.path.join(_addonPath,'resources','test.strm'))
_SaveFile(filename,url)
try: _addon.resolve_url(url)
except: t=''
try: play.play(filename) #(url)
except: t=''
def PlayVideo(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#import urlresolver
infoLabels={"Studio":addpr('studio',''),"ShowTitle":addpr('showtitle',''),"Title":addpr('title','')}
li=xbmcgui.ListItem(addpr('title',''),iconImage=addpr('img',''),thumbnailImage=addpr('img',''))
li.setInfo(type="Video", infoLabels=infoLabels ); li.setProperty('IsPlayable', 'true')
#xbmc.Player().stop()
try: _addon.resolve_url(url)
except: t=''
try: play.play(url, li)
except: t=''
def PlayFromHost(url):
PlayerMethod=addst("core-player")
if (PlayerMethod=='DVDPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_DVDPLAYER
elif (PlayerMethod=='MPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_MPLAYER
elif (PlayerMethod=='PAPLAYER'): PlayerMeth=xbmc.PLAYER_CORE_PAPLAYER
else: PlayerMeth=xbmc.PLAYER_CORE_AUTO
play=xbmc.Player(PlayerMeth) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
#play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
import urlresolver
infoLabels={"Studio":addpr('studio',''),"ShowTitle":addpr('showtitle',''),"Title":addpr('title','')}
li=xbmcgui.ListItem(addpr('title',''),iconImage=addpr('img',''),thumbnailImage=addpr('img',''))
li.setInfo(type="Video", infoLabels=infoLabels ); li.setProperty('IsPlayable', 'true')
deb('url',url)
###
#try: _addon.resolve_url(url)
#except: t=''
#stream_url='http://s6.vidcache.net/stream/a4133ca7743c0a0f4ff063f715d934472bb1d513?client_file_id=524368'
#play.play(stream_url, li)
###
if ('youtube.com' in url):
stream_url=url
else:
debob(urlresolver.HostedMediaFile(url))
#stream_url = urlresolver.HostedMediaFile(url).resolve()
try: stream_url = urlresolver.HostedMediaFile(url).resolve()
except: deb('Link URL Was Not Resolved',url); myNote("urlresolver.HostedMediaFile(url).resolve()","Failed to Resolve Playable URL."); return
try: debob(stream_url) #deb('stream_url',stream_url)
except: t=''
#xbmc.Player().stop()
try: _addon.resolve_url(url)
except: t=''
wwT=addpr("wwT"); wwB=tfalse(addpr("MarkAsWatched","false"));
deb("MarkAsWatched",str(wwB));
try:
if (wwB==True) and (len(wwT) > 0): deb("Attempting to add episode to watched list",wwT); visited_add(wwT);
play.play(stream_url,li);
except:
if (wwB==True) and (len(wwT) > 0): deb("Attempting to remove episode to watched list",wwT); visited_remove(wwT);
t='';
### ############################################################################################################
### ############################################################################################################
def filename_filter_out_year(name=''):
years=re.compile(' \((\d+)\)').findall('__'+name+'__')
for year in years:
name=name.replace(' ('+year+')','')
name=name.strip()
return name
def QP(v): return urllib.quote_plus(v)
def DoLabs2LB(labs,subfav=''):
LB={}
n='title'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='year'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='img'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='fanart'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='plot'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='url'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='country'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='genres'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='todoparams'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='commonid'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='commonid2'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='plot'
try: LB[n]=str(labs[n])
except: LB[n]=''
n='site'
try: LB[n]=labs[n]
except:
try: LB[n]=addpr(n,'')
except: LB[n]=''
n='section'
try: LB[n]=labs[n]
except:
try: LB[n]=addpr(n,'')
except: LB[n]=''
##try: LB['subfav']=subfav
##except: LB['subfav']=''
#n=''
#try: LB[n]=labs[n]
#except: LB[n]=''
return LB
def ContextMenu_Favorites(labs={}):
contextMenuItems=[]; nameonly=filename_filter_out_year(labs['title'])
try: site=labs['site']
except: site=addpr('site','')
try: section=labs['section']
except: section=addpr('section','')
try: _subfav=addpr('subfav','')
except: _subfav=''
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
try:
if _subfav=='': _sf='1'
else: _sf=_subfav
WRFC=ps('WhatRFavsCalled')
LB=DoLabs2LB(labs); LB['mode']='cFavoritesAdd'; P1='XBMC.RunPlugin(%s)'
if _sf is not '1': LB['subfav']= ''; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.1.name'),Pars))
if _sf is not '2': LB['subfav']='2'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.2.name'),Pars))
if _sf is not '3': LB['subfav']='3'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.3.name'),Pars))
if _sf is not '4': LB['subfav']='4'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.4.name'),Pars))
if _sf is not '5': LB['subfav']='5'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.5.name'),Pars))
if _sf is not '6': LB['subfav']='6'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.6.name'),Pars))
if _sf is not '7': LB['subfav']='7'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.7.name'),Pars))
LB['mode']='cFavoritesRemove'; LB['subfav']=_subfav; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append(('Remove: '+WRFC+addst('fav.tv.'+_sf+'.name'),Pars))
except: pass
return contextMenuItems
def ContextMenu_Movies(labs={}):
contextMenuItems=[]; nameonly=filename_filter_out_year(labs['title'])
try: site=labs['site']
except: site=addpr('site','')
try: section=labs['section']
except: section=addpr('section','')
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Movie Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
if (tfalse(addst("CMI_SearchKissAnime"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.kissanime')): contextMenuItems.append(('Search KissAnime', 'XBMC.Container.Update(%s?mode=%s&pageno=1&pagecount=1&title=%s)' % ('plugin://plugin.video.kissanime/','Search',nameonly)))
if (tfalse(addst("CMI_SearchSolarMovieso"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.solarmovie.so')): contextMenuItems.append(('Search Solarmovie.so', 'XBMC.Container.Update(%s?mode=%s§ion=%s&title=%s)' % ('plugin://plugin.video.solarmovie.so/','Search','movies',nameonly)))
if (tfalse(addst("CMI_Search1Channel"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.1channel')): contextMenuItems.append(('Search 1Channel', 'XBMC.Container.Update(%s?mode=7000§ion=%s&query=%s)' % ('plugin://plugin.video.1channel/','movies',nameonly)))
#if os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.merdb'): contextMenuItems.append(('Search MerDB', 'XBMC.Container.Update(%s?mode=%s§ion=%s&url=%s&title=%s)' % ('plugin://plugin.video.merdb/','Search','movies',urllib.quote_plus('http://merdb.ru/'),nameonly)))
#if os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.icefilms'): contextMenuItems.append(('Search Icefilms','XBMC.Container.Update(%s?mode=555&url=%s&search=%s&nextPage=%s)' % ('plugin://plugin.video.icefilms/', 'http://www.icefilms.info/', title, '1')))
try:
WRFC=ps('WhatRFavsCalled')
LB=DoLabs2LB(labs); LB['mode']='cFavoritesAdd'; P1='XBMC.RunPlugin(%s)'
LB['subfav']= ''; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.1.name'),Pars))
LB['subfav']='2'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.2.name'),Pars))
LB['subfav']='3'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.3.name'),Pars))
LB['subfav']='4'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.4.name'),Pars))
LB['subfav']='5'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.5.name'),Pars))
LB['subfav']='6'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.6.name'),Pars))
LB['subfav']='7'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.movies.7.name'),Pars))
except: pass
return contextMenuItems
def ContextMenu_Series(labs={}):
contextMenuItems=[]; nameonly=filename_filter_out_year(labs['title'])
try: site=labs['site']
except: site=addpr('site','')
try: section=labs['section']
except: section=addpr('section','')
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Show Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
if (tfalse(addst("CMI_FindAirDates"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.solarmovie.so')): contextMenuItems.append(('Find AirDates', 'XBMC.Container.Update(%s?mode=%s&title=%s)' % ('plugin://plugin.video.solarmovie.so/','SearchForAirDates',labs['title'])))
if (tfalse(addst("CMI_SearchKissAnime"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.kissanime')): contextMenuItems.append(('Search KissAnime', 'XBMC.Container.Update(%s?mode=%s&pageno=1&pagecount=1&title=%s)' % ('plugin://plugin.video.kissanime/','Search',nameonly)))
if (tfalse(addst("CMI_SearchSolarMovieso"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.solarmovie.so')): contextMenuItems.append(('Search Solarmovie.so', 'XBMC.Container.Update(%s?mode=%s§ion=%s&title=%s)' % ('plugin://plugin.video.solarmovie.so/','Search','tv',nameonly)))
if (tfalse(addst("CMI_Search1Channel"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.1channel')): contextMenuItems.append(('Search 1Channel', 'XBMC.Container.Update(%s?mode=7000§ion=%s&query=%s)' % ('plugin://plugin.video.1channel/','tv',nameonly)))
if (tfalse(addst("CMI_SearchMerDBru"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.merdb')): contextMenuItems.append(('Search MerDB', 'XBMC.Container.Update(%s?mode=%s§ion=%s&url=%s&title=%s)' % ('plugin://plugin.video.merdb/','Search','tvshows',urllib.quote_plus('http://merdb.ru/tvshow/'),nameonly)))
if (tfalse(addst("CMI_SearchIceFilms"))==True) and (os.path.exists(xbmc.translatePath("special://home/addons/") + 'plugin.video.icefilms')): contextMenuItems.append(('Search Icefilms','XBMC.Container.Update(%s?mode=555&url=%s&search=%s&nextPage=%s)' % ('plugin://plugin.video.icefilms/', 'http://www.icefilms.info/', labs['title'], '1')))
try:
WRFC=ps('WhatRFavsCalled'); WRFCr='Remove: '
LB=DoLabs2LB(labs); McFA='cFavoritesAdd'; McFR='cFavoritesRemove'; LB['mode']=McFA; P1='XBMC.RunPlugin(%s)'
#LB['mode']=McFA; LB['subfav']= ''; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.1.name'),Pars))
LB['subfav']='1';
if fav__COMMON__check(LB['site'],LB['section'],LB['title'],LB['year'],LB['subfav'])==True: LB['mode']=McFR; LabelName=WRFCr+WRFC+addst('fav.tv.'+LB['subfav']+'.name');
else: LB['mode']=McFA; LabelName=WRFC+addst('fav.tv.'+LB['subfav']+'.name');
LB['subfav']=''; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((LabelName,Pars));
for nn in ['2','3','4','5','6','7']:
LB['subfav']=nn;
if fav__COMMON__check(LB['site'],LB['section'],LB['title'],LB['year'],LB['subfav'])==True: LB['mode']=McFR; LabelName=WRFCr+WRFC+addst('fav.tv.'+LB['subfav']+'.name');
else: LB['mode']=McFA; LabelName=WRFC+addst('fav.tv.'+LB['subfav']+'.name');
Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((LabelName,Pars));
#LB['mode']=McFA; LB['subfav']='2'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.2.name'),Pars))
#LB['mode']=McFA; LB['subfav']='3'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.3.name'),Pars))
#LB['mode']=McFA; LB['subfav']='4'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.4.name'),Pars))
#LB['mode']=McFA; LB['subfav']='5'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.5.name'),Pars))
#LB['mode']=McFA; LB['subfav']='7'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.7.name'),Pars))
if (tfalse(addst("CMI_RefreshMetaData","true"))==True): LB['mode']='refresh_meta'; LabelName='Refresh MetaData'; LB['imdb_id']=LB['commonid']; LB['alt_id']='imdbnum'; LB['video_type']='tvshow'; LB['year']; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((LabelName,Pars));
except: pass
return contextMenuItems
def ContextMenu_Episodes(labs={}):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Episode Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
return contextMenuItems
def ContextMenu_Hosts(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
#if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Host Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
if tfalse(addst("CMI_JDownloaderResolver"))==True: contextMenuItems.append(('JDownloader (UrlResolver)','XBMC.RunPlugin(%s?mode=%s&url=%s&useResolver=%s)' % ('plugin://'+ps('addon_id')+'/','toJDownloader',urllib.quote_plus(labs['url']),'true')))
if tfalse(addst("CMI_JDownloader"))==True: contextMenuItems.append(('JDownloader (Url)','XBMC.RunPlugin(%s?mode=%s&url=%s&useResolver=%s)' % ('plugin://'+ps('addon_id')+'/','toJDownloader',urllib.quote_plus(labs['url']),'false')))
if ('destfile' in labs) and (len(addst('download_folder_default','')) > 0):
contextMenuItems.append(('Download','XBMC.RunPlugin(%s?mode=%s&url=%s&useResolver=%s&destpath=%s&destfile=%s)' % ('plugin://'+ps('addon_id')+'/','Download',urllib.quote_plus(labs['url']),'true',urllib.quote_plus(addst('download_folder_default','')),urllib.quote_plus(labs['destfile']) ) ))
#elif ('title' in labs) and (len(addst('download_folder_default','')) > 0):
return contextMenuItems
def ContextMenu_LiveStreams(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
try: site=labs['site']
except: site=addpr('site','')
try: section=labs['section']
except: section=addpr('section','')
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Stream Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
try:
WRFC=ps('WhatRFavsCalled')
LB=DoLabs2LB(labs); LB['mode']='cFavoritesAdd'; P1='XBMC.RunPlugin(%s)'
LB['subfav']= ''; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.1.name'),Pars))
LB['subfav']='2'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.2.name'),Pars))
LB['subfav']='3'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.3.name'),Pars))
LB['subfav']='4'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.4.name'),Pars))
LB['subfav']='5'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.5.name'),Pars))
LB['subfav']='6'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.6.name'),Pars))
LB['subfav']='7'; Pars=P1 % _addon.build_plugin_url(LB); contextMenuItems.append((WRFC+addst('fav.tv.7.name'),Pars))
except: pass
return contextMenuItems
def ContextMenu_VideoUrls(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
#if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Url Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
if tfalse(addst("CMI_JDownloader"))==True: contextMenuItems.append(('JDownloader (Url)','XBMC.RunPlugin(%s?mode=%s&url=%s&useResolver=%s)' % ('plugin://'+ps('addon_id')+'/','toJDowfnloader',urllib.quote_plus(labs['url']),'false')))
#contextMenuItems.append(('Downloader','XBMC.RunPlugin(%s?mode=%s&url=%s&useResolver=%s&destpath=%s&destfile=%s)' % ('plugin://'+ps('addon_id')+'/','Download',labs['url'],'false','','')))
return contextMenuItems
def ContextMenu_ImageUrls(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Url Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
return contextMenuItems
def ContextMenu_AudioUrls(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Url Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
return contextMenuItems
def ContextMenu_AudioStreams(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Url Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
return contextMenuItems
def ContextMenu_AudioRadioStreams(labs={},contextMenuItems=[]):
contextMenuItems=[] #; nameonly=filename_filter_out_year(labs['title'])
if tfalse(addst("CMI_ShowInfo"))==True: contextMenuItems.append(('Url Info',ps('cMI.showinfo.url')))
if labs=={}: return contextMenuItems
return contextMenuItems
def XBMC_RunPlugin(plugId,plugParams,plugFile=''): xbmc.executebuiltin("XBMC.RunPlugin(plugin://%s/%s?%s)" % (plugId,plugFile,plugParams) )
def XBMC_ContainerUpdate(plugId,plugParams,plugFile=''): xbmc.executebuiltin("XBMC.Container.Update(plugin://%s/%s?%s)" % (plugId,plugFile,plugParams) )
### ############################################################################################################
### ############################################################################################################
def SendTo_JDownloader(url,useResolver=True):
myNote('Download','sending to jDownloader plugin',15000)
if useResolver==True:
try:
import urlresolver
link=urlresolver.HostedMediaFile(url).resolve()
except: link=url
else: link=url
xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % link)
try: _addon.resolve_url(url)
except: pass
### ############################################################################################################
### ############################################################################################################
#import c_Extract as extract #extract.all(lib,addonfolder,dp)
#import c_HiddenDownloader as downloader #downloader.download(url,destfile,destpath,useResolver=True)
def ExtractThis(filename,destpath):
import c_Extract as extract
return extract.allNoProgress(filename,destpath)
def DownloadThis(url,destfile,destpath,useResolver=True):
destpath=xbmc.translatePath(destpath)
import c_HiddenDownloader as downloader
debob(str(useResolver))
if useResolver==True:
try:
import urlresolver
#debob(urlresolver.HostedMediaFile(url))
link=urlresolver.HostedMediaFile(url).resolve()
except: link=url
else: link=url
deb('downloadable url',link)
downloader.download(link,destfile,destpath,useResolver)
#downloader.download(url,destfile,destpath,useResolver)
### ############################################################################################################
### ############################################################################################################
def XBMC_RefreshRSS(): xbmc.executebuiltin("XBMC.RefreshRSS()")
def XBMC_EjectTray(): xbmc.executebuiltin("XBMC.EjectTray()")
def XBMC_Mute(): xbmc.executebuiltin("XBMC.Mute()")
def XBMC_System_Exec(url): xbmc.executebuiltin("XBMC.System.Exec(%s)" % url)
def XBMC_System_ExecWait(url): xbmc.executebuiltin("XBMC.System.ExecWait(%s)" % url)
def XBMC_PlayDVD(): xbmc.executebuiltin("XBMC.PlayDVD()")
def XBMC_ReloadSkin(): xbmc.executebuiltin("XBMC.ReloadSkin()")
def XBMC_UpdateAddonRepos(): xbmc.executebuiltin("XBMC.UpdateAddonRepos()")
def XBMC_UpdateLocalAddons(): xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
def XBMC_Weather_Refresh(): xbmc.executebuiltin("XBMC.Weather.Refresh()")
def XBMC_ToggleDebug(): xbmc.executebuiltin("XBMC.ToggleDebug()")
def XBMC_Minimize(): xbmc.executebuiltin("XBMC.Minimize()")
def XBMC_ActivateScreensaver(): xbmc.executebuiltin("XBMC.ActivateScreensaver()")
### ############################################################################################################
### ############################################################################################################
def fav__COMMON__empty(site,section,subfav=''): WhereAmI('@ Favorites - Empty - %s%s' % (section,subfav)); favs=[]; cache.set('favs_'+site+'__'+section+subfav+'__', str(favs)); myNote(bFL('Favorites'),bFL('Your Favorites Have Been Wiped Clean. Bye Bye.'))
def fav__COMMON__remove(site,section,name,year,subfav=''):
WhereAmI('@ Favorites - Remove - %s%s' % (section,subfav)); deb('fav__remove() '+section,name+' ('+year+')'); saved_favs=cache.get('favs_'+site+'__'+section+subfav+'__'); tf=False
if saved_favs:
favs=eval(saved_favs)
if favs:
for (_name,_year,_img,_fanart,_country,_url,_plot,_Genres,_site,_subfav,_section,_ToDoParams,_commonID,_commonID2) in favs:
if (name==_name) and (year==_year): favs.remove((_name,_year,_img,_fanart,_country,_url,_plot,_Genres,_site,_subfav,_section,_ToDoParams,_commonID,_commonID2)); cache.set('favs_'+site+'__'+section+subfav+'__', str(favs)); tf=True; myNote(bFL(name.upper()+' ('+year+')'),bFL('Removed from Favorites')); deb(name+' ('+year+')','Removed from Favorites. (Hopefully)'); xbmc.executebuiltin("XBMC.Container.Refresh"); return
if (tf==False): myNote(bFL(name.upper()),bFL('not found in your Favorites'))
else: myNote(bFL(name.upper()+' ('+year+')'),bFL('not found in your Favorites'))
def fav__COMMON__add(site,section,name,year='',img=_artIcon,fanart=_artFanart,subfav='',plot='',commonID='',commonID2='',ToDoParams='',Country='',Genres='',Url=''):
debob(['fav__add()',section,name+' ('+year+')',img,fanart]); WhereAmI('@ Favorites - Add - %s%s' % (section,subfav)); saved_favs=cache.get('favs_'+site+'__'+section+subfav+'__'); favs=[]; fav_found=False
if saved_favs:
#debob(saved_favs)
favs=eval(saved_favs)
if favs:
#debob(favs)
for (_name,_year,_img,_fanart,_country,_url,_plot,_Genres,_site,_subfav,_section,_ToDoParams,_commonID,_commonID2) in favs:
if (name==_name) and (year==_year):
fav_found=True;
if len(year) > 0: myNote(bFL(section+': '+name.upper()+' ('+year+')'),bFL('Already in your Favorites'));
else: myNote(bFL(section+': '+name.upper()),bFL('Already in your Favorites'));
return
#
deb('Adding Favorite',site+' - '+section+' - '+subfav)
debob(['name',name,'year',year,'img',img,'fanart',fanart,'Country',Country,'Url',Url,'plot',plot,'Genres',Genres,'site',site,'subfav',subfav,'section',section,'ToDoParams',ToDoParams,'commonID',commonID,'commonID2',commonID2])
favs.append((name,year,img,fanart,Country,Url,plot,Genres,site,subfav,section,ToDoParams,commonID,commonID2))
##if (section==ps('section.tvshows')): favs.append((name,year,img,fanart,_param['country'],_param['url'],_param['plot'],_param['genre'],_param['dbid']))
##elif (section==ps('section.movie')): favs.append((name,year,img,fanart,_param['country'],_param['url'],_param['plot'],_param['genre'],''))
##else: myNote('Favorites: '+section,'Section not Found')
#
cache.set('favs_'+site+'__'+section+subfav+'__', str(favs));
if len(year) > 0: myNote(bFL(name+' ('+year+')'),bFL('Added to Favorites'))
else: myNote(bFL(name),bFL('Added to Favorites'))
#
def fav__COMMON__list_fetcher(site,section='',subfav=''):
WhereAmI('@ Favorites - List - %s%s' % (section,subfav)); saved_favs=cache.get('favs_'+site+'__'+section+subfav+'__'); favs=[]
if saved_favs:
debob('saved_favs found'); debob(saved_favs); favs=sorted(eval(saved_favs), key=lambda fav: (fav[1],fav[0]),reverse=True); ItemCount=len(favs)
if favs:
debob('favs found'); debob(favs);
return favs
## ((name,year,img,fanart,Country,Url,plot,Genres,site,subfav,section,ToDoParams,commonID,commonID2))
#for (name,year,img,fanart,country,url,plot,genre,dbid) in favs:
# except: deb('Error Listing Item',name+' ('+year+')')