-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdefault.py
1716 lines (1670 loc) · 130 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
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
### ############################################################################################################
### #
### # Project: # KissAnime.com - by The Highway 2013.
### # Author: # The Highway
### # Version: # v0.3.7
### # Description: # http://www.KissAnime.com
### #
### ############################################################################################################
### ############################################################################################################
##### Imports #####
import xbmc,xbmcplugin,xbmcgui,xbmcaddon,xbmcvfs
#import requests ### (Removed in v0.2.1b to fix scripterror on load on Mac OS.) ###
try: import requests ### <import addon="script.module.requests" version="1.1.0"/> ###
except: t='' ### See https://github.com/kennethreitz/requests ###
import urllib,urllib2,re,os,sys,htmllib,string,StringIO,logging,random,array,time,datetime
try: import urlresolver
except: pass
import copy
###
#import cookielib
#import base64
#import threading
###
#import unicodedata ### I don't want to use unless I absolutely have to. ###
#import zipfile ### Removed because it caused videos to not play. ###
import HTMLParser, htmlentitydefs
try: import StorageServer
except: import storageserverdummy as StorageServer
try: from t0mm0.common.addon import Addon
except: from t0mm0_common_addon import Addon
try: from t0mm0.common.net import Net
except: from t0mm0_common_net import Net
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
###
from teh_tools import *
from config import *
##### /\ ##### Imports #####
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
__plugin__=ps('__plugin__'); __authors__=ps('__authors__'); __credits__=ps('__credits__'); _addon_id=ps('_addon_id'); _domain_url=ps('_domain_url'); _database_name=ps('_database_name'); _plugin_id=ps('_addon_id')
_database_file=os.path.join(xbmc.translatePath("special://database"),ps('_database_name')+'.db');
###
_addon=Addon(ps('_addon_id'), sys.argv); addon=_addon; _plugin=xbmcaddon.Addon(id=ps('_addon_id')); cache=StorageServer.StorageServer(ps('_addon_id'))
###
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
##### Paths #####
### # ps('')
_addonPath =xbmc.translatePath(_plugin.getAddonInfo('path'))
_artPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_art')))
_datapath =xbmc.translatePath(_addon.get_profile()); _artIcon =_addon.get_icon(); _artFanart =_addon.get_fanart()
##### /\ ##### Paths #####
##### Important Functions with some dependencies #####
def art(f,fe=ps('default_art_ext')): return xbmc.translatePath(os.path.join(_artPath,f+fe)) ### for Making path+filename+ext data for Art Images. ###
##### /\ ##### Important Functions with some dependencies #####
##### Settings #####
_setting={}; _setting['enableMeta'] = _enableMeta =tfalse(addst("enableMeta"))
_setting['debug-enable']= _debugging =tfalse(addst("debug-enable")); _setting['debug-show'] = _shoDebugging =tfalse(addst("debug-show"))
_setting['meta.movie.domain']=ps('meta.movie.domain'); _setting['meta.movie.search']=ps('meta.movie.search')
_setting['meta.tv.domain'] =ps('meta.tv.domain'); _setting['meta.tv.search'] =ps('meta.tv.search')
_setting['meta.tv.page']=ps('meta.tv.page'); _setting['meta.tv.fanart.url']=ps('meta.tv.fanart.url'); _setting['meta.tv.fanart.url2']=ps('meta.tv.fanart.url2'); _setting['label-empty-favorites']=tfalse(addst('label-empty-favorites'))
CurrentPercent=0; CancelDownload=False
##### /\ ##### Settings #####
##### Variables #####
_art404=ps('img_hot') #'http://www.solarmovie.so/images/404.png' #_art404=art('404')
_art150=ps('img_hot') #'http://www.solarmovie.so/images/thumb150.png' #_art150=art('thumb150')
_artDead=ps('img_hot') #'http://www.solarmovie.so/images/deadplanet.png' #_artDead=art('deadplanet')
_artSun=ps('img_hot') #art('sun');
COUNTRIES=ps('COUNTRIES'); GENRES=ps('GENRES'); _default_section_=ps('default_section'); net=Net(); DB=_database_file; BASE_URL=_domain_url;
#_artFanart=xbmc.translatePath(os.path.join(_addonPath,'fanart5.jpg'))
##### /\ ##### Variables #####
deb('Addon Path',_addonPath); deb('Art Path',_artPath); deb('Addon Icon Path',_artIcon); deb('Addon Fanart Path',_artFanart)
### ############################################################################################################
def eod(): _addon.end_of_directory()
def deadNote(header='',msg='',delay=5000,image=_artDead): _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
def sunNote( header='',msg='',delay=5000,image=_artSun):
header=cFL(header,ps('cFL_color')); msg=cFL(msg,ps('cFL_color2'))
_addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
def messupText(t,_html=False,_ende=False,_a=False,Slashes=False):
if (_html==True): t=ParseDescription(HTMLParser.HTMLParser().unescape(t))
if (_ende==True): t=t.encode('ascii', 'ignore'); t=t.decode('iso-8859-1')
if (_a==True): t=_addon.decode(t); t=_addon.unescape(t)
if (Slashes==True): t=t.replace( '_',' ')
return t
def name2path(name): return (((name.lower()).replace('.','-')).replace(' ','-')).replace('--','-')
def name2pathU(name): return (((name.replace(' and ','-')).replace('.','-')).replace(' ','-')).replace('--','-')
### ############################################################################################################
### ############################################################################################################
##### Queries #####
_param={}
_param['mode']=addpr('mode',''); _param['url']=addpr('url',''); _param['pagesource'],_param['pageurl'],_param['pageno'],_param['pagecount']=addpr('pagesource',''),addpr('pageurl',''),addpr('pageno',0),addpr('pagecount',1)
_param['img']=addpr('img',''); _param['fanart']=addpr('fanart',''); _param['thumbnail'],_param['thumbnail'],_param['thumbnail']=addpr('thumbnail',''),addpr('thumbnailshow',''),addpr('thumbnailepisode','')
_param['section']=addpr('section','movies'); _param['title']=addpr('title',''); _param['year']=addpr('year',''); _param['genre']=addpr('genre','')
_param['by']=addpr('by',''); _param['letter']=addpr('letter',''); _param['showtitle']=addpr('showtitle',''); _param['showyear']=addpr('showyear',''); _param['listitem']=addpr('listitem',''); _param['infoLabels']=addpr('infoLabels',''); _param['season']=addpr('season',''); _param['episode']=addpr('episode','')
_param['pars']=addpr('pars',''); _param['labs']=addpr('labs',''); _param['name']=addpr('name',''); _param['thetvdbid']=addpr('thetvdbid','')
_param['plot']=addpr('plot',''); _param['tomode']=addpr('tomode',''); _param['country']=addpr('country','')
_param['thetvdb_series_id']=addpr('thetvdb_series_id',''); _param['dbid']=addpr('dbid',''); _param['user']=addpr('user','')
_param['subfav']=addpr('subfav',''); _param['episodetitle']=addpr('episodetitle',''); _param['special']=addpr('special',''); _param['studio']=addpr('studio','')
#_param['']=_addon.queries.get('','')
#_param['']=_addon.queries.get('','')
##_param['pagestart']=addpr('pagestart',0)
##### /\
### ############################################################################################################
### ############################################################################################################
def initDatabase():
print "Building solarmovie Database"
if ( not os.path.isdir( os.path.dirname(_database_file) ) ): os.makedirs( os.path.dirname( _database_file ) )
db=sqlite.connect(_database_file); cursor=db.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS seasons (season UNIQUE, contents);')
cursor.execute('CREATE TABLE IF NOT EXISTS favorites (type, name, url, img);')
db.commit(); db.close()
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
##### Player Functions #####
def PlayURL(url):
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 PlayVideo(url,title='',studio='',img='',showtitle='',plot='',autoplay=False): #PlayVideo(url, infoLabels, listitem)
WhereAmI('@ PlayVideo -- Getting ID From: %s' % url)
if (img==''): img=_artIcon
infoLabels={"Studio":studio,"ShowTitle":showtitle,"Title":title,"Plot":plot}
li=xbmcgui.ListItem(title,iconImage=img,thumbnailImage=img)
li.setInfo(type="Video", infoLabels=infoLabels ); li.setProperty('IsPlayable', 'true')
#xbmc.Player().stop()
try: _addon.resolve_url(url)
except: t=''
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
_addon.addon.setSetting(id="LastVideoPlayItemUrl", value=url)
_addon.addon.setSetting(id="LastVideoPlayItemName", value=title)
_addon.addon.setSetting(id="LastVideoPlayItemImg", value=img)
_addon.addon.setSetting(id="LastVideoPlayItemStudio", value=studio)
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True)
if (autoplay==False): eod()
#try: html=nURL(url,method='head',headers={'Referer':_domain_url})
#except: html=''
#deb('length of html',str(len(html)))
#from teh_tools import _SaveFile
#_SaveFile(xbmc.translatePath(os.path.join(_addonPath,'resources','testing.txt')),html)
#try: html=nURL('http://s10.histats.com/js15_gif.js',method='head',headers={'Referer':_domain_url})
#except: html=''
#xbmc.getIPAddress()
#MyIP=xbmc.getIPAddress()
#MyIP=""
#MyIP="0.0.0.0"
#deb('my ip',xbmc.getIPAddress())
url2=url
#url2=url2.replace('&ip=0.0.0.0&','&ip='+MyIP+'&')
#url2=url2.replace('&cmo=sensitive_content=yes&','&')
#url2=url2.replace('&sparams=id,itag,source,ip,ipbits,expire&','&sparams=expire,id,ip,ipbits,itag,source&')
##url2=url2.replace('&itag=5&','&itag=34&')
#url2=url2.replace('&key=lh1&','&key=cms1&')
##url2+='&cpn='
#url2+='&cms_redirect=yes'
##url2+='&ms=nxu'
##url2+='&mt='
##url2+='&mv=m'
##url2='http://redirector.googlevideo.com/videoplayback?id=f7b436d64b869da8&itag=34&source=picasa&ip=199.0.197.160&ipbits=0&expire=1385481949&sparams=expire,id,ip,ipbits,itag,source&signature=3155D80C58FF4E1C35F46C66957FF4625495D36E.52DED4EDC5079C8FFAA8AA04754F9347808D0B8B&key=cms1'
##url2='http://redirector.googlevideo.com/videoplayback?id=2f676cc6a678c32e&itag=5&source=picasa&ip=199.0.197.160&ipbits=0&expire=1385483906&sparams=expire,id,ip,ipbits,itag,source&signature=12A862B470AFF570F006AB2AC81DA24A3FCEECFB.4BB4AE0D52D543E7054211500A12B1A34F11272E&key=lh1'
##url2='http://redirector.googlevideo.com/videoplayback?id=2f676cc6a678c32e&itag=5&source=picasa&ip=199.0.197.160&ipbits=0&expire=1385483906&sparams=expire,id,ip,ipbits,itag,source&signature=12A862B470AFF570F006AB2AC81DA24A3FCEECFB.4BB4AE0D52D543E7054211500A12B1A34F11272E&key=cms1'
deb('url2',url2)
try: play.play(url2, li);
#try: play.play(url, li);
except: t=''
try: xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=li)
except: t=''
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True)
#try: _addon.resolve_url(url)
#except: t=''
#xbmc.sleep(7000)
def PlayLibrary(section, url, showtitle='', showyear=''): ### Menu for Listing Hosters (Host Sites of the actual Videos)
WhereAmI('@ Play Library: %s' % url); sources=[]; listitem=xbmcgui.ListItem()
#eod()
#_addon.resolve_url(url)
if (url==''): return
html=net.http_GET(url).content; html=html.encode("ascii", "ignore")
##if (_debugging==True): print html
#if ( section == 'tv'): ## TV Show ## Title (Year) - Info
# match=re.compile(ps('LLinks.compile.show_episode.info'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0] ### <title>Watch The Walking Dead Online for Free - Prey - S03E14 - 3x14 - SolarMovie</title>
# if (_debugging==True): print match
# if (match==None): return
# ShowYear=_param['year'] #ShowYear=showyear
# ShowTitle=match[0].strip(); EpisodeTitle=match[1].strip(); Season=match[2].strip(); Episode=match[3].strip()
# ShowTitle=HTMLParser.HTMLParser().unescape(ShowTitle); ShowTitle=ParseDescription(ShowTitle); ShowTitle=ShowTitle.encode('ascii', 'ignore'); ShowTitle=ShowTitle.decode('iso-8859-1'); EpisodeTitle=HTMLParser.HTMLParser().unescape(EpisodeTitle); EpisodeTitle=ParseDescription(EpisodeTitle); EpisodeTitle=EpisodeTitle.encode('ascii', 'ignore'); EpisodeTitle=EpisodeTitle.decode('iso-8859-1')
# if ('<p id="plot_' in html):
# ShowPlot=(re.compile(ps('LLinks.compile.show.plot'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip(); ShowPlot=HTMLParser.HTMLParser().unescape(ShowPlot); ShowPlot=ParseDescription(ShowPlot); ShowPlot=ShowPlot.encode('ascii', 'ignore'); ShowPlot=ShowPlot.decode('iso-8859-1')
# else: ShowPlot=''
# match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
# if (_debugging==True): print match
# (IMDbURL,IMDbID)=match; IMDbURL=IMDbURL.strip(); IMDbID=IMDbID.strip(); My_infoLabels={ "Studio": ShowTitle+' ('+ShowYear+'): '+Season+'x'+Episode+' - '+EpisodeTitle, "Title": ShowTitle, "ShowTitle": ShowTitle, "Year": ShowYear, "Plot": ShowPlot, 'Season': Season, 'Episode': Episode, 'EpisodeTitle': EpisodeTitle, 'IMDbURL': IMDbURL, 'IMDbID': IMDbID, 'IMDb': IMDbID }; listitem.setInfo(type="Video", infoLabels=My_infoLabels )
#else: #################### Movie ## Title (Year) - Info
# match=re.compile(ps('LLinks.compile.show.title_year'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
# if (_debugging==True): print match
# if (match==None): return
# ShowYear=match[1].strip(); ShowTitle=match[0].strip(); ShowTitle=HTMLParser.HTMLParser().unescape(ShowTitle); ShowTitle=ParseDescription(ShowTitle); ShowTitle=ShowTitle.encode('ascii', 'ignore'); ShowTitle=ShowTitle.decode('iso-8859-1'); ShowPlot=(re.compile(ps('LLinks.compile.show.plot'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip(); ShowPlot=HTMLParser.HTMLParser().unescape(ShowPlot); ShowPlot=ParseDescription(ShowPlot); ShowPlot=ShowPlot.encode('ascii', 'ignore'); ShowPlot=ShowPlot.decode('iso-8859-1'); match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
# if (_debugging==True): print match
# (IMDbURL,IMDbID)=match; IMDbURL=IMDbURL.strip(); IMDbID=IMDbID.strip(); My_infoLabels={ "Studio": ShowTitle+' ('+ShowYear+')', "Title": ShowTitle, "ShowTitle": ShowTitle, "Year": ShowYear, "Plot": ShowPlot, 'IMDbURL': IMDbURL, 'IMDbID': IMDbID, 'IMDb': IMDbID }; listitem.setInfo(type="Video", infoLabels=My_infoLabels )
### Both -Movies- and -TV Shows- ### Hosters
try: matchH=re.compile(ps('LLinks.compile.hosters2'), re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)
except: matchH=''
#deb('length of matchH',str(len(matchH)))
#print matchH
if (len(matchH) > 0):
oList=[]; hList=[]; matchH=sorted(matchH, key=lambda item: item[3], reverse=True)
for url, host, quality, age in matchH:
url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
try: mID=re.compile('/.+?/.+?/([0-9]+)/', re.DOTALL | re.IGNORECASE).findall(url)[0]
except: mID=''
#deb('Media Passed',str(host)+' | '+str(quality)+' | '+str(age)+' | '+str(url)+' | '+str(mID))
if (mID is not ''):
oList.append(host+' ['+quality+'] ('+age+')')
hList.append([url,host,quality,age,mID])
try: rt=askSelection(oList,'Select Source:')
except: rt=''
print rt
if (rt==None) or (rt=='none') or (rt==False) or (rt==''): return
hItem=hList[rt]
deb('ID',hItem[4])
urlB='%s/link/play/%s/' % (ps('_domain_url'),hItem[4])
html=net.http_GET(urlB).content
try: url=re.compile('<iframe.+?src="(.+?)"', re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)[0]
except: url=''
url=url.replace('/embed/', '/file/'); deb('hoster url',url)
#oList=[]
#for url, host, quality, age in match:
# url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
# print 'Media Failed: '+str(host)+' | '+str(quality)+' | '+str(age)+' | '+url
# if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
# try: MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
# except: MediaID=''
# try: MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
# except: MediaHost=''
# print 'Media Passed: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
# if (MediaHost is not '') and (MediaID is not ''):
# oList.append(urlresolver.HostedMediaFile(host=MediaHost, media_id=MediaID))
##
#
#try: url=urlresolver.choose_source(oList)
#except: return
#
#MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
#MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
#print 'Media: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
#print str(urlresolver.HostedMediaFile(url=url.strip()).valid_url())
#if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
#
#
#
#
#videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
#html=net.http_GET(url).content; match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); link=match.group(1); link=link.replace('/embed/', '/file/'); deb('hoster link',link)
#
deb('video',url)
liz=xbmcgui.ListItem(_param['showtitle'], iconImage="DefaultVideo.png", thumbnailImage=_param['img'])
if ( section == 'tv'): ## TV Show ## Title (Year) - Info
liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
else: #################### Movies ### Title (Year) - Info
liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
liz.setProperty("IsPlayable","true")
##pl=xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
##pl.clear()
##pl.add(url, liz)
##xbmc.Player().play(pl)
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
print url
stream_url = urlresolver.HostedMediaFile(url).resolve()
print stream_url
play.play(stream_url, liz)
#play.play(url, liz)
liz.setPath(url)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
_addon.resolve_url(url)
_addon.resolve_url(stream_url)
##
##
##
##count=1
##for url, host, quality, age in match:
## host=host.strip(); quality=quality.strip(); name=str(count)+". "+host+' - [[B]'+quality+'[/B]] - ([I]'+age+'[/I])'
## if urlresolver.HostedMediaFile(host=host, media_id='xxx'):
## img=ps('Hosters.icon.url')+host; My_infoLabels['quality']=quality; My_infoLabels['age']=age; My_infoLabels['host']=host; _addon.add_directory({'section': section, 'img': _param['img'], 'mode': 'PlayVideo', 'url': url, 'quality': quality, 'age': age, 'infoLabels': My_infoLabels, 'listitem': listitem}, {'title': name}, img=img, is_folder=False); count=count+1
eod()
else: return
### ################################################################
def DownloadStop(): ## Testing ## Doesn't work yet.
global CancelDownload
CancelDownload=True
#global CancelDownload
eod()
#download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
#if (download_method=='Progress'):
# dp=xbmcgui.DialogProgress() ## For Frodo and earlier.
# dp.close()
#elif (download_method=='ProgressBG'):
# dp=xbmcgui.DialogProgressBG() ## Only works on daily build of XBMC.
# dp.close()
#elif (download_method=='Test'):
# t=''
#elif (download_method=='Hidden'):
# t=''
#else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
#try: t=''
#except: t=''
def DownloadStatus(numblocks, blocksize, filesize, dlg, download_method, start_time, section, url, img, LabelName, ext, LabelFile):
if (CancelDownload==True):
try:
if (download_method=='Progress'): ## For Frodo and earlier.
dlg.close()
elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
dlg.close()
elif (download_method=='Test'): t=''
elif (download_method=='Hidden'): t=''
except: t=''
try:
percent = min(numblocks * blocksize * 100 / filesize, 100)
currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
kbps_speed = numblocks * blocksize / (time.time() - start_time)
if kbps_speed > 0: eta = (filesize - numblocks * blocksize) / kbps_speed
else: eta = 0
kbps_speed /= 1024
total = float(filesize) / (1024 * 1024)
#if (download_method=='Progress'): ## For Frodo and earlier.
# line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
# line1 +=' '+percent+'%'
# line2 = 'Speed: %.02f Kb/s ' % kbps_speed
# line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
# dlg.update(percent, line1, line2, line3)
#elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
# line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
# line1 +=' '+percent+'%'
# line2 ='Speed: %.02f Kb/s ' % kbps_speed
# line2 +='ETA: %02d:%02d' % divmod(eta, 60)
# dlg.update(percent, line1, line2)
#elif (download_method=='Test'):
# mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
# spd = 'Speed: %.02f Kb/s ' % kbps_speed
# est = 'ETA: %02d:%02d' % divmod(eta, 60)
# Header= ext+' '+mbs+' '+percent+'%'
# Message= est+' '+spd
#elif (download_method=='Hidden'): t=''
#if (time.time()==start_time) or (int(str(time.time())[-5:1]) == 0): # and (int(str(time.time())[-5:2]) < 10):
#if (int(time.strptime(time.time(),fmt='%S')) == 0):
#if (str(percent) in ['0','1','5','10','15','20','25','30','35','40','45','50','55','60','65','70','75','80','85','90','91','92','93','94','95','96','97','98','99','100']):
#if (str(percent) == '0' or '1' or '5' or '10' or '15' or '20' or '25' or '30' or '35' or '40' or '45' or '50' or '55' or '60' or '65' or '70' or '75' or '80' or '85' or '90' or '91' or '92' or '93' or '94' or '95' or '96' or '97' or '98' or '99' or '100'):
#if ('.' in str(percent)): pCheck=int(str(percent).split('.')[0])
#else: pCheck=percent
#pCheck=int(str(percent)[1:])
#if (CurrentPercent is not pCheck):
# global CurrentPercent
# CurrentPercent=pCheck
# myNote(header=Header,msg=Message,delay=100,image=img)
##myNote(header=Header,msg=Message,delay=1,image=img)
except:
percent=100
if (download_method=='Progress'): ## For Frodo and earlier.
t=''
dlg.update(percent)
elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
t=''
dlg.update(percent)
elif (download_method=='Test'): t=''
#myNote(header='100%',msg='Download Completed',delay=15000,image=img)
elif (download_method=='Hidden'): t=''
if (download_method=='Progress'): ## For Frodo and earlier.
line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
line1 +=' '+str(percent)+'%'
line2 = 'Speed: %.02f Kb/s ' % kbps_speed
line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
dlg.update(percent, line1, line2, line3)
elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
line1 +=' '+str(percent)+'%'
line2 ='Speed: %.02f Kb/s ' % kbps_speed
line2 +='ETA: %02d:%02d' % divmod(eta, 60)
dlg.update(percent, line1, line2)
elif (download_method=='Test'):
mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
spd = 'Speed: %.02f Kb/s ' % kbps_speed
est = 'ETA: %02d:%02d' % divmod(eta, 60)
Header= ext+' '+mbs+' '+str(percent)+'%'
Message= est+' '+spd
elif (download_method=='Hidden'): t=''
if (download_method=='Progress'): ## For Frodo and earlier.
try:
if dlg.iscanceled(): ## used for xbmcgui.DialogProgress() but causes an error with xbmcgui.DialogProgressBG()
dlg.close()
#deb('Download Error','Download canceled.'); myNote('Download Error','Download canceled.')
#raise StopDownloading('Stopped Downloading')
except: t=''
elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
try:
if (dlg.isFinished()):
dlg.close()
except: t=''
def DownloadRequest(section,url,img,LabelName):
if (LabelName=='') and (_param['title'] is not ''): LabelName==_param['title']
if (LabelName=='') and (_param['showtitle'] is not ''): LabelName==_param['showtitle']
LabelFile=clean_filename(LabelName)
deb('LabelName',LabelName)
if (LabelName==''): deb('Download Error','Missing Filename String.'); myNote('Download Error','Missing Filename String.'); return
if (section==ps('section.wallpaper')): FolderDest=xbmc.translatePath(addst("download_folder_wallpapers"))
elif (section==ps('section.tv')): FolderDest=xbmc.translatePath(addst("download_folder_tv"))
elif (section==ps('section.movie')): FolderDest=xbmc.translatePath(addst("download_folder_movies"))
else: FolderDest=xbmc.translatePath(addst("download_folder_movies"))
if os.path.exists(FolderDest)==False: os.mkdir(FolderDest)
if os.path.exists(FolderDest):
if (section==ps('section.tv')) or (section==ps('section.movie')):
### param >> url: /link/show/1466546/
#match=re.search( '/.+?/.+?/(.+?)/', url) ## Example: http://www.solarmovie.so/link/show/1052387/ ##
#videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
#html=net.http_GET(url).content; match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); link=match.group(1); link=link.replace('/embed/', '/file/'); deb('hoster link',link)
#try: stream_url = urlresolver.HostedMediaFile(link).resolve()
#except: stream_url=''
stream_url=url
if ('.mp4' in LabelName) or ('.mp4' in stream_url): ext='.mp4'
elif ('.avi' in LabelName) or ('.avi' in stream_url): ext='.avi'
elif ('.mkv' in LabelName) or ('.mkv' in stream_url): ext='.mkv'
else: ext='.flv'
ext=Download_PrepExt(stream_url,ext)
else:
stream_url=url
if ('.png' in LabelName) or ('.png' in stream_url): ext='.png'
else: ext='.jpg'
ext=Download_PrepExt(stream_url,ext)
t=1; c=1
if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext))):
t=LabelFile
while t==LabelFile:
if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+'['+str(c)+']'+ext)))==False:
LabelFile=LabelFile+'['+str(c)+']'
c=c+1
start_time = time.time()
deb('start_time',str(start_time))
download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
urllib.urlcleanup()
if (download_method=='Progress'):
dp=xbmcgui.DialogProgress(); dialogType=12 ## For Frodo and earlier.
dp.create('Downloading', LabelFile+ext)
urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
myNote('Download Complete',LabelFile+ext,15000)
elif (download_method=='ProgressBG'):
dp=xbmcgui.DialogProgressBG(); dialogType=13 ## Only works on daily build of XBMC.
dp.create('Downloading', LabelFile+ext)
urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
myNote('Download Complete',LabelFile+ext,15000)
elif (download_method=='Test'):
dp=xbmcgui.DialogProgress()
myNote('Download Started',LabelFile+ext,15000)
urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
myNote('Download Complete',LabelFile+ext,15000)
elif (download_method=='Hidden'):
dp=xbmcgui.DialogProgress()
myNote('Download Started',LabelFile+ext,15000)
urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
myNote('Download Complete',LabelFile+ext,15000)
elif (download_method=='jDownloader (StreamURL)'):
myNote('Download','sending to jDownloader plugin',15000)
xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % stream_url)
#return
elif (download_method=='jDownloader (Link)'):
myNote('Download','sending to jDownloader plugin',15000)
xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % link)
#return
else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
##
##urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
##
#myNote('Download Complete',LabelFile+ext,15000)
##
#### xbmc.translatePath(os.path.join(FolderDest,localfilewithpath+ext))
_addon.resolve_url(url)
_addon.resolve_url(stream_url)
#
#
else: deb('Download Error','Unable to create destination path.'); myNote('Download Error','Unable to create destination path.'); return
def PlayTrailer(url,_title,_year,_image): ### Not currently used ###
WhereAmI('@ PlayVideo: %s' % url) #; sources=[]; url=url.decode('base-64')
#if ('<h2>Movie trailer</h2>' not in url): eod(); return
EmbedID=''; html=net.http_GET(url).content #getURL(url)
html=messupText(html,True,True,True,False)
#print str(html)
if ('traileraddict.com/emd/' in html):
deb('Found','traileraddict.com/emd/')
#EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
try: EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
except: EmbedID=''
if (EmbedID==''):
#print html
#ImdbID=re.compile('<strong>IMDb ID:</strong>[\n]\s+<a href=".+?">(\d+)</a>"', re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
try: ImdbID=re.compile('%2Ftitle%2Ftt(\d+)%2F"', re.DOTALL).findall(html)[0].strip()
except: ImdbID=''
if (ImdbID==''): eod(); deb('Error Playing Trailer','No Imdb ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
deb('ImdbID',ImdbID)
thtml=getURL('http://api.traileraddict.com/?imdb='+ImdbID)
try: EmbedID=re.compile('"http://www.traileraddict.com/emd/([0-9]+)"', re.DOTALL).findall(thtml)[0].strip()
except: EmbedID=''
if (EmbedID==''): eod(); deb('Error Playing Trailer','No Embed Video ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
deb('EmbedID',EmbedID)
vhtml=getURL('http://www.traileraddict.com/fvar.php?tid='+EmbedID) #vhtml=getURL('http://www.traileraddict.com/fvarhd.php?tid='+EmbedID)
#print vhtml
if ('Error: Trailer is (Possibly Temporarily) Unavailable' in vhtml): deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
try: thumb=re.compile('&image=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
except: thumb=_param['img']
try: title=re.compile('&filmtitle=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
except: title=_param['title']
try: url=re.compile('&fileurl=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
except:
try: url=re.compile('&fileurl=(.+?)[\n]\s+&', re.DOTALL).findall(vhtml)[0].strip()
except: url=''
if (url==''): eod(); deb('Error Playing Trailer','No Url was found from vhtml.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
url=urllib.unquote_plus(url)
deb('video',url)
liz=xbmcgui.ListItem(_param['showtitle'], iconImage=thumb, thumbnailImage=_image)
liz.setInfo( type="Video", infoLabels={ "Title": title, "Studio": _title+' ('+_year+')' } )
liz.setProperty("IsPlayable","true")
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
play.play(url, liz)
#liz.setPath(url)
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
_addon.resolve_url(url)
#eod(); return
##### /\ ##### Player Functions #####
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
##### Weird, Stupid, or Plain up Annoying Functions. #####
def netURL(url): ### Doesn't seem to work.
return net.http_GET(url).content
def remove_accents(input_str): ### Not even sure rather this one works or not.
#nkfd_form = unicodedata.normalize('NFKD', unicode(input_str))
#return u"".join([c for c in nkfd_form if not unicodedata.combining(c)])
return input_str
##### /\ ##### Weird, Stupid, or Plain up Annoying Functions. #####
### ############################################################################################################
### ############################################################################################################
### ############################################################################################################
##### Menus #####
def mGetItemPage(url):
deb('Fetching html from Url',url)
try: html=net.http_GET(url).content
except: html=''
if (html=='') or (html=='none') or (html==None) or (html==False): return ''
else:
html=HTMLParser.HTMLParser().unescape(html); html=_addon.decode(html); html=_addon.unescape(html); html=ParseDescription(html); html=html.encode('ascii', 'ignore'); html=html.decode('iso-8859-1'); deb('Length of HTML fetched',str(len(html)))
return html
def mdGetSplitFindGroup(html,ifTag='', parseTag='',startTag='',endTag=''):
if (ifTag=='') or (parseTag=='') or (startTag=='') or (endTag==''): return ''
if (ifTag in html):
html=(((html.split(startTag)[1])).split(endTag)[0]).strip()
try: return re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
except: return ''
else: return ''
def listLinks(section, url, showtitle='', showyear=''): ### Menu for Listing Hosters (Host Sites of the actual Videos)
WhereAmI('@ the Link List: %s' % url); sources=[]; listitem=xbmcgui.ListItem()
if (url==''): return
cookie_file=xbmc.translatePath(os.path.join(_addonPath,'temp.cache.txt'))
#try: html=nURL(url)
try: html=nURL(url,headers={'Referer':_domain_url},cookie_file=cookie_file,load_cookie=True)
#try: html=net.http_GET(url).content
except: html=''
deb('length of html',str(len(html)))
if (html==''): return
try: html=html.encode("ascii", "ignore")
except: t=''
html=messupText(html,True,True,True,False)
s='<img id="a'+'d'+'Check\d" src="(http://.+?.com/.*?.png\?id=\d+)"/>'
_mts=re.compile(s, re.DOTALL).findall(html)
for mts2 in _mts:
try:
t=nURL(mts2,headers={'Referer':url})
except: pass
img=_param['img']
if (img==''): img=re.compile('<meta\s*itemprop="thumbnailUrl"\s*content="(http://.+?\.jpg)"').findall(html)[0].replace(' ','%20')
pimg=''+img; fimg=''+img; ptitle=_param['title']
s='<a\s*\n*\s*href="(http://redirector.googlevideo.com/videoplayback.+?)"\s*\n*\s*>((\d+)x(\d+)\.([0-9A-Za-z]+))</a>'
#s="%7C(http.+?redirector.googlevideo.com.+?%3fid%3d([A-Za-z0-9]+)%26itag%3d(((\d+)))%.+?)%7C"
matches=re.compile(s, re.DOTALL).findall(html)
debob(matches)
try: contentURL=re.compile('<meta\s*itemprop="contentURL"\s*content="(http://.+?)"\s*/*>').findall(html)[0]
except: contentURL=''
try: fTitle=re.compile('<meta\s*itemprop="contentURL"\s*content="http://.+?(&title=.*?)"\s*/*>').findall(html)[0]
except: fTitle=''
if (tfalse(addst("enable-autoplay"))==True) and (addst("autoplay-select")=='Default'): #and (tfalse(addst("enable-autoplay2"))==False):
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO)
deb('LastAutoPlayItemUrl',addst("LastAutoPlayItemUrl"))
deb('LastAutoPlayItemName',addst("LastAutoPlayItemName"))
if (play.isPlayingVideo()==False):
_addon.addon.setSetting(id="LastAutoPlayItemUrl", value=contentURL)
_addon.addon.setSetting(id="LastAutoPlayItemName", value=ptitle)
PlayVideo(contentURL, title='[Auto Play] Default URL', studio=ptitle, img=pimg, showtitle=showtitle)
xbmc.executebuiltin("XBMC.Container.Update(%s)" % _addon.build_plugin_url({'mode':'GetEpisodes','url':addst("LastShowListedURL"),'img':addst("LastShowListedIMG")}))
else: myNote('A Video is currently playing.','Try stopping the current video first.')
return
### _addon.addon.setSetting(id="LastShowListedURL", value=url)
### _addon.addon.setSetting(id="LastShowListedIMG", value=img)
### xbmc.executebuiltin("XBMC.RunPlugin(%s)" % _addon.build_plugin_url({'mode':'GetTitles','url':url,'pageno':'1','pagecount':addst('pages')}))
### xbmc.executebuiltin("XBMC.Container.Update(%s)" % _addon.build_plugin_url({'mode':'GetTitles','url':url,'pageno':'1','pagecount':addst('pages')}))
#try: embedURL=re.compile("var\s+embedCode\s*=\s*'(http://.+?)'").findall(html)[0]
#except: embedURL=''
#try: testURL=re.compile("'(http://.+?)'").findall(html); print 'testURL1'; print testURL
#except: testURL=''
#try: testURL=re.compile('"(http://.+?)"').findall(html); print 'testURL2'; print testURL
#except: testURL=''
#try: testURL=re.compile('\n.+?(http://.+?)\n', re.DOTALL).findall(html); print 'testURL3'; print testURL
#except: testURL=''
#try: fmtURLs=re.compile('(\d+)%7C(http%3a%2f%2fredirector.googlevideo.com%2fvideoplayback%3fid%3d[0-9A-Za-z]+%26itag%3d(\d+)%26source%3d[0-9A-Za-z\-_]+%26cmo%3d[0-9A-Za-z\-_]+%3dyes%26ip%3d0.0.0.0%26ipbits%3d0%26expire%3d\d+%26sparams%3did%252Citag%252Csource%252Cip%252Cipbits%252Cexpire%26signature%3d[0-9A-Za-z]+\.[0-9A-Za-z]+%26key%3d[0-9A-Za-z]+)').findall(html)
#except: fmtURLs=''
# print 'testURL4'; print fmtURLs
#
#if (len(fmtURLs) > 0):
# count=1; ItemCount=len(fmtURLs); #match=sorted(match, key=lambda item: (item[3],item[2],item[1]))
## deb('No. of matches',str(ItemCount))
# #print matches
# MaxNoLinks=int(addst('linksmaxshown'))
# try: mmNames=re.compile('(\d+)%2F(\d+x\d+)').findall(html)
# except: mmNames=None
# for mID1,mUrl,mID2 in fmtURLs:
# mUrl=urllib.unquote_plus(mUrl)
# #mUrl=unescape_(mUrl)
# #deb('mUrl',mUrl)
# #try: mName=re.compile(mID1+'%2F(\d+x\d+)').findall(html)[0]+'-'+mID2
# #except: mName=''+mID1
# try: mName=mID2+'-['+mmNames[int(count-1)][1]+']-'+mmNames[int(count-1)][0]
# except: mName=''+mID1
# #if (mFileExt.lower()=='mkv'): img=art('mkv') #'http://convertmkvtomp4.info/images/mkv.png'
# #elif (mFileExt.lower()=='mp4'): img=art('mp4') #'http://zamzar.files.wordpress.com/2013/03/mp4.png?w=480'
# #elif (mFileExt.lower()=='flv'): img=art('flv') #'http://images.wikia.com/fileformats/images/a/ab/Icon_FLV.png'
# contextMenuItems=[]; labs={}
# #if (fTitle not in mUrl): mUrl+=fTitle
# #if (fTitle not in mUrl): mUrl2=fTitle
# #else: mUrl2=''+mUrl
# pars={'img':pimg,'mode':'PlayVideo','url':mUrl,'title':mName,'studio':ptitle}
# #pars2={'img':pimg,'mode':'PlayVideo','url':mUrl2,'title':mName,'studio':ptitle}
# deb('gv redirector url',mUrl)
# ##pars2={'img':img,'mode':'Download','url':url,'title':mName,'studio':ptitle}
# ##contextMenuItems.append(('Download', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url(pars2)))
# ##contextMenuItems.append(('jDownloader', ps('cMI.jDownloader.addlink.url') % (urllib.quote_plus(url))))
# labs['title']=''+mName #+' (Testing)'
# _addon.add_directory(pars,labs,img=img,fanart=fimg,is_folder=False,contextmenu_items=contextMenuItems,total_items=ItemCount)
# #_addon.add_directory(pars2,labs,img=img,fanart=fimg,is_folder=False,contextmenu_items=contextMenuItems,total_items=ItemCount)
# count=count+1
#if (len(embedURL) > 0):
# deb('embedURL',embedURL)
# contextMenuItems=[]; labs={}; labs['title']='[ Embed URL ]' +' [I]<-- Play This One Only[/I]'
# pars={'img':pimg,'mode':'PlayVideo','url':embedURL,'title':'Default URL','studio':ptitle}
# _addon.add_directory(pars,labs,img=img,fanart=fimg,is_folder=False,contextmenu_items=contextMenuItems)
#
if (len(contentURL) > 0):
deb('contentURL',contentURL)
contextMenuItems=[]; labs={}; labs['title']='[ Default URL ]' #+' [I]<-- Play This One[/I]' #
pars={'img':pimg,'mode':'PlayVideo','url':contentURL,'title':'Default URL','studio':ptitle}
_addon.add_directory(pars,labs,img=img,fanart=fimg,is_folder=False,contextmenu_items=contextMenuItems)
if (len(matches) > 0):
count=1; ItemCount=len(matches); #match=sorted(match, key=lambda item: (item[3],item[2],item[1]))
deb('No. of matches',str(ItemCount))
#print matches
MaxNoLinks=int(addst('linksmaxshown'))
if (tfalse(addst("enable-autoplay"))==True) and (addst("autoplay-select")=='Next'):
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO)
if (play.isPlayingVideo()==False):
_addon.addon.setSetting(id="LastAutoPlayItemUrl", value=contentURL)
_addon.addon.setSetting(id="LastAutoPlayItemName", value=ptitle)
(mUrl,mName,mWidth,mHeight,mFileExt)=matches[0]
PlayVideo(mUrl, title='[Auto Play] '+mName, studio=ptitle, img=pimg, showtitle=showtitle)
xbmc.executebuiltin("XBMC.Container.Update(%s)" % _addon.build_plugin_url({'mode':'GetEpisodes','url':addst("LastShowListedURL"),'img':addst("LastShowListedIMG")}))
else: myNote('A Video is currently playing.','Try stopping the current video first.')
return
if (tfalse(addst("enable-autoplay"))==True) and (addst("autoplay-select")=='Last'):
play=xbmc.Player(xbmc.PLAYER_CORE_AUTO)
if (play.isPlayingVideo()==False):
_addon.addon.setSetting(id="LastAutoPlayItemUrl", value=contentURL)
_addon.addon.setSetting(id="LastAutoPlayItemName", value=ptitle)
(mUrl,mName,mWidth,mHeight,mFileExt)=matches[-1]
PlayVideo(mUrl, title='[Auto Play] '+mName, studio=ptitle, img=pimg, showtitle=showtitle)
xbmc.executebuiltin("XBMC.Container.Update(%s)" % _addon.build_plugin_url({'mode':'GetEpisodes','url':addst("LastShowListedURL"),'img':addst("LastShowListedIMG")}))
else: myNote('A Video is currently playing.','Try stopping the current video first.')
return
for mUrl,mName,mWidth,mHeight,mFileExt in matches:
#mUrl=urllib.unquote_plus(mUrl).replace('%2C',','); deb('unquoted url',mUrl)
if (mFileExt.lower()=='mkv'): img=art('mkv') #'http://convertmkvtomp4.info/images/mkv.png'
elif (mFileExt.lower()=='mp4'): img=art('mp4') #'http://zamzar.files.wordpress.com/2013/03/mp4.png?w=480'
elif (mFileExt.lower()=='flv'): img=art('flv') #'http://images.wikia.com/fileformats/images/a/ab/Icon_FLV.png'
contextMenuItems=[]; labs={}
#if (fTitle not in mUrl): mUrl+=fTitle
pars={'img':pimg,'mode':'PlayVideo','url':mUrl,'title':mName,'studio':ptitle}
parsDL={'img':pimg,'mode':'Download','section':ps('section.movie'),'url':mUrl,'title':ptitle+'-'+mName,'studio':ptitle+'-'+mName,'showtitle':ptitle+'-'+mName}
deb('gv redirector url',mUrl)
#pars2={'img':img,'mode':'Download','url':url,'title':mName,'studio':ptitle}
contextMenuItems.append(('Download', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url(parsDL)))
contextMenuItems.append(('jDownloader', ps('cMI.jDownloader.addlink.url') % (urllib.quote_plus(mUrl))))
labs['title']=''+mName #+' (Testing)'
_addon.add_directory(pars,labs,img=img,fanart=fimg,is_folder=False,contextmenu_items=contextMenuItems,total_items=ItemCount)
count=count+1
set_view(ps('content_links'),addst('links-view')); eod()
### ################################################################
def Library_SaveTo_TV(section,url,img,name,year,country,season_number,episode_number,episode_title):
##def listEpisodes(section, url, img='', season='') #_param['img']
show_name=name
xbmcplugin.setContent( int( sys.argv[1] ), 'episodes' ); WhereAmI('@ the Episodes List for TV Show -- url: %s' % url); html=net.http_GET(url).content
if (html=='') or (html=='none') or (html==None):
if (_debugging==True): print 'Html is empty.'
return
if (img==''):
match=re.search( 'coverImage">.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); img=match.group(1)
episodes=re.compile('<span class="epname">[\n].+?<a href="(.+?)"[\n]\s+title=".+?">(.+?)</a>[\n]\s+<a href="/.+?/season-(\d+)/episode-(\d+)/" class=".+?">[\n]\s+(\d+) links</a>', re.IGNORECASE | re.MULTILINE | re.DOTALL).findall(html) #; if (_debugging==True): print episodes
if not episodes:
if (_debugging==True): print 'couldn\'t find episodes'
return
if (_param['thetvdb_series_id']=='') or (_param['thetvdb_series_id']=='none') or (_param['thetvdb_series_id']==None) or (_param['thetvdb_series_id']==False): thetvdb_episodes=None
else: thetvdb_episodes=thetvdb_com_episodes2(_param['thetvdb_series_id'])
#print 'thetvdb_episodes',thetvdb_episodes
woot=False
for ep_url, episode_name, season_number, episode_number, num_links in episodes:
labs={}; s_no=season_number; e_no=episode_number
if (int(episode_number) > -1) and (int(episode_number) < 10): episode_number='0'+episode_number
labs['thumbnail']=img; labs['fanart']=_param['fanart']
labs['EpisodeTitle']=episode_name #; labs['ShowTitle']=''
labs['title']=season_number+'x'+episode_number+' - '+episode_name+' [[I]'+num_links+' Links [/I]]'
ep_url=_domain_url+ep_url; episode_name=messupText(episode_name,True,True,True,True)
if (thetvdb_episodes==None) or (_param['thetvdb_series_id']==None) or (_param['thetvdb_series_id']==False) or (_param['thetvdb_series_id'] is not '') or (_param['thetvdb_series_id']=='none'): t=''
if (thetvdb_episodes):
for db_ep_url, db_sxe_no, db_ep_url2, db_ep_name, db_dateYear, db_dateMonth, db_dateDay, db_hasImage in thetvdb_episodes:
db_ep_url=ps('meta.tv.domain')+db_ep_url
db_ep_url2=ps('meta.tv.domain')+db_ep_url2
if (db_sxe_no.strip()==(s_no+' x '+e_no)):
if ('Episode #' in episode_name): episode_name=db_ep_name.strip()
labs['Premeired']=labs['DateAired']=labs['Date']=db_dateYear+'-'+db_dateMonth+'-'+db_dateDay
labs['year']=db_dateYear; labs['month']=db_dateMonth; labs['day']=db_dateDay
(db_thumb,labs['thetvdb_series_id'],labs['thetvdb_episode_id']) = Episode__get_thumb(db_ep_url2.strip(),img)
if (check_ifUrl_isHTML(db_thumb)==True): labs['thumbnail']=db_thumb
labs['title']=cFL(season_number+cFL('x',ps('cFL_color4'))+episode_number,ps('cFL_color5'))+' - '+cFL(episode_name,ps('cFL_color4'))+cFL(' [[I]'+cFL(num_links+' Links ',ps('cFL_color3'))+'[/I]]',ps('cFL_color'))
ep_html=mGetItemPage(db_ep_url2); deb('thetvdb - episode - url',db_ep_url2)
deb('Length of ep_html',str(len(ep_html)))
if (ep_html is not None) or (ep_html is not False) or (ep_html is not '') or (ep_html is not 'none'):
labs['PlotOutline']=labs['plot']=mdGetTV(ep_html,['thetvdb.episode.overview1'])['thetvdb.episode.overview1']
contextMenuItems=[]; labs['season']=season_number; labs['episode']=episode_number
#contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
#contextMenuItems.append(('Add - Library','XBMC.RunPlugin(%s?mode=%s§ion=%s&title=%s&showtitle=%s&showyear=%s&url=%s&img=%s&season=%s&episode=%s&episodetitle=%s)' % ( sys.argv[0],'LibrarySaveEpisode',section, urllib.quote_plus(_param['title']), urllib.quote_plus(_param['showtitle']), urllib.quote_plus(_param['year']), urllib.quote_plus(ep_url), urllib.quote_plus(labs['thumbnail']), urllib.quote_plus(season_number), urllib.quote_plus(episode_number), urllib.quote_plus(episode_name) )))
labs['title']=messupText(labs['title'],True,True,True,False)
deb('Episode Name',labs['title'])
deb('episode thumbnail',labs['thumbnail'])
#
Library_SaveTo_Episode(ep_url,labs['thumbnail'],show_name,year,country,season_number,episode_number,episode_name)
### Library_SaveTo_Episode(url,iconimage,name,year,country,season_number,episode_number,episode_title)
#
#if (season==season_number) or (season==''): _addon.add_directory({'mode': 'GetLinks', 'year': _param['year'], 'section': section, 'img': img, 'url': ep_url, 'season': season_number, 'episode': episode_number, 'episodetitle': episode_name}, labs, img=labs['thumbnail'], fanart=labs['fanart'], contextmenu_items=contextMenuItems)
set_view('episodes',ps('setview.episodes')); eod()
def Menu_BrowseByGenre(section=_default_section_):
url=''; WhereAmI('@ the Genre Menu')#print 'Browse by genres screen'
browsebyImg=checkImgLocal(art('genre','.jpg'))
ItemCount=len(GENRES)*4 # , total_items=ItemCount
for genre in GENRES:
gt=addst("genre-thumbs"); img=''; imgName=genre #; pre='http://icons.iconarchive.com/icons/sirubico/movie-genre/128/'
#if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
#if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
#if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
#if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
#if (img=='') and (browsebyImg is not ''): img=browsebyImg
#if (img==''): img=_artIcon
if (gt=='icon.png'): img=_artIcon
if (gt=='sitelogo'): img=ps('img_kisslogo')
if (gt=='next'): img=ps('img_next')
if (gt=='prev'): img=ps('img_prev')
if (gt=='hot'): img=ps('img_hot')
if (gt=='updated'): img=ps('img_updated')
if (gt=='skin.primal'): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
if (gt=='skin.tangency'): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
if (gt=='1ch.PrimeWire'): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
if (gt=='1ch.Glossy_Black'): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
if (gt=='kiss.png'): img=art('kiss')
if (gt=='genre.jpg'): img=art('genre','.jpg')
if (gt=='turtle.jpg'): img=art('turtle','.jpg')
if (gt=='mkv.png'): img=art('mkv')
if (gt=='mp4.png'): img=art('mp4')
if (gt=='flv.png'): img=art('flv')
#if (gt==''): img=
if (img==''): img=_artIcon
_addon.add_directory({'mode': 'SelectSort','url': _domain_url+'/Genre/'+genre.replace(' ','-')},{'title':genre},img=img,fanart=_artFanart,total_items=ItemCount)
set_view('list',addst('default-view')); eod()
def Select_Genre(url=''):
if (url==''): url=_domain_url+'/'+ps('common_word')+'List'
WhereAmI('@ the Select Genre Menu'); option_list=GENRES; r=askSelection(option_list,'Select Genre')
#if (r==0): Select_Sort(url+option_list[r].lower(),AZ='')
if (r== -1): eod(); return
else: Select_Sort(url+'/Genre/'+option_list[r].replace(' ','-'),AZ='')
def Select_Sort(url='',AZ='all'):
if (url==''): url=_domain_url+'/'+ps('common_word')+'List'
WhereAmI('@ the Select Sort Menu'); AZ=AZ.lower();
option_list=['Alphabetical','Most Popular','Latest Update','New '+ps('common_word')]
path_list =['','/MostPopular','/LatestUpdate','/Newest']
if (AZ=='') or (AZ=='all'): AZTag=''
elif ('?' in url): AZTag='&c='+AZ
else: AZTag='?c='+AZ
pn='1'; pc=addst('pages'); ItemCount=4 #len(GENRES)
_addon.add_directory({'mode':'GetTitles','url':url+''+AZTag,'pageno':pn,'pagecount':pc},{'title':'Alphabetical'},img=_artIcon,fanart=_artFanart,total_items=ItemCount)
_addon.add_directory({'mode':'GetTitles','url':url+'/MostPopular'+AZTag,'pageno':pn,'pagecount':pc},{'title':'Most Popular'},img=ps('img_hot'),fanart=_artFanart,total_items=ItemCount)
_addon.add_directory({'mode':'GetTitles','url':url+'/LatestUpdate'+AZTag,'pageno':pn,'pagecount':pc},{'title':'Latest Update'},img=ps('img_updated'),fanart=_artFanart,total_items=ItemCount)
_addon.add_directory({'mode':'GetTitles','url':url+'/Newest'+AZTag,'pageno':pn,'pagecount':pc},{'title':'New '+ps('common_word')},img=_artIcon,fanart=_artFanart,total_items=ItemCount)
set_view('list',addst('default-view')); eod()
def Select_AZ(url=''):
if (url==''): url=_domain_url+'/'+ps('common_word')+'List'
option_list=['All','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
WhereAmI('@ the Select AZ Menu')
pn='1'; pc=addst('pages'); ItemCount=len(option_list)
for oo in option_list:
if (oo=='All'): ooo=''
else: ooo=oo.lower()
gt=addst("az-thumbs"); img='';
if (gt=='icon.png'): img=_artIcon
if (gt=='sitelogo'): img=ps('img_kisslogo')
if (gt=='next'): img=ps('img_next')
if (gt=='prev'): img=ps('img_prev')
if (gt=='hot'): img=ps('img_hot')
if (gt=='updated'): img=ps('img_updated')
if (gt=='kiss.png'): img=art('kiss')
if (gt=='genre.jpg'): img=art('genre','.jpg')
if (gt=='turtle.jpg'): img=art('turtle','.jpg')
if (gt=='mkv.png'): img=art('mkv')
if (gt=='mp4.png'): img=art('mp4')
if (gt=='flv.png'): img=art('flv')
if (gt=='chromatix.lower'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/alt-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/hash-icon.png'
else: img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/letter-'+oo.lower()+'-icon.png'
if (gt=='chromatix.upper'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/alt-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/hash-icon.png'
else: img='http://icons.iconarchive.com/icons/chromatix/keyboard-keys/128/letter-uppercase-'+oo.upper()+'-icon.png'
if (gt=='dooffy.lower'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/dooffy/characters/256/At-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/dooffy/characters/256/0-Hash-icon.png'
else: img='http://icons.iconarchive.com/icons/dooffy/characters/256/'+oo.upper()+'1-icon.png'
if (gt=='dooffy.upper'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/dooffy/characters/256/At-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/dooffy/characters/256/0-Hash-icon.png'
else: img='http://icons.iconarchive.com/icons/dooffy/characters/256/'+oo.upper()+'2-icon.png'
if (gt=='balloon-green'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-green/256/speech-balloon-green-a-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-green/256/speech-balloon-green-o-icon.png'
else: img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-green/256/speech-balloon-green-'+oo.lower()+'-icon.png'
if (gt=='balloon-orange'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-orange/256/speech-balloon-orange-a-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-orange/256/speech-balloon-orange-o-icon.png'
else: img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-orange/256/speech-balloon-orange-'+oo.lower()+'-icon.png'
if (gt=='balloon-grey'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-grey/256/speech-balloon-white-a-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-grey/256/speech-balloon-white-o-icon.png'
else: img='http://icons.iconarchive.com/icons/iconexpo/speech-balloon-grey/256/speech-balloon-white-'+oo.lower()+'-icon.png'
if (gt=='red-orb'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/256/At-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/256/Hash-icon.png'
else: img='http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/256/Letter-A-icon.png'
if (gt=='ariil.letter'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/ariil/alphabet/256/Letter-A-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/ariil/alphabet/256/Letter-O-icon.png'
else: img='http://icons.iconarchive.com/icons/ariil/alphabet/256/Letter-'+oo.upper()+'-icon.png'
if (gt=='hydrattz.pink'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-pink-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-pink-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-pink-icon.png'
if (gt=='hydrattz.blue'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-blue-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-blue-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-blue-icon.png'
if (gt=='hydrattz.gold'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-blue-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-blue-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-blue-icon.png'
if (gt=='hydrattz.red'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-red-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-red-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-red-icon.png'
if (gt=='hydrattz.black'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-black-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-black-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-black-icon.png'
if (gt=='hydrattz.grey'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-blue-grey.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-blue-grey.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-grey-icon.png'
if (gt=='hydrattz.lg'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-lg-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-lg-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-lg-icon.png'
if (gt=='hydrattz.dg'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-dg-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-dg-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-dg-icon.png'
if (gt=='hydrattz.violet'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-violet-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-violet-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-violet-icon.png'
if (gt=='hydrattz.orange'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-A-orange-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-O-orange-icon.png'
else: img='http://icons.iconarchive.com/icons/hydrattz/multipurpose-alphabet/256/Letter-'+oo.upper()+'-orange-icon.png'
if (gt=='mattahan'):
if (oo=='all'): img='http://icons.iconarchive.com/icons/mattahan/umicons/256/Letter-A-icon.png'
if (oo=='0'): img='http://icons.iconarchive.com/icons/mattahan/umicons/256/Number-9-icon.png'
else: img='http://icons.iconarchive.com/icons/mattahan/umicons/256/Letter-'+oo.upper()+'-icon.png'
#if (gt==''):
# if (oo=='all'): img=''
# if (oo=='0'): img=''
# else: img=''
#if (gt==''): img=''
#if (gt==''): img=
if (img==''): img=_artIcon
_addon.add_directory({'mode':'SelectSort','url':url,'title':ooo,'pageno':pn,'pagecount':pc},{'title':oo},img=img,fanart=_artFanart,total_items=ItemCount)
set_view('list',addst('default-view')); eod()
def _DoGetItems(url):
#xbmc.executebuiltin("XBMC.RunPlugin(%s)" % _addon.build_plugin_url({'mode':'GetTitles','url':url,'pageno':'1','pagecount':addst('pages')}))
xbmc.executebuiltin("XBMC.Container.Update(%s)" % _addon.build_plugin_url({'mode':'GetTitles','url':url,'pageno':'1','pagecount':addst('pages')}))
#listItems('',url,'1',addst('pages'))
##def listItems(section=_default_section_, url='', html='', episode=False, startPage='1', numOfPages='1', genre='', year='', stitle=''): # List: Movies or TV Shows
def listItems(section=_default_section_, url='', startPage='1', numOfPages='1', genre='', year='', stitle='', season='', episode='', html='', chck=''): # List: Movies or TV Shows
if (url==''): return
#if (chck=='Latest'): url=url+chr(35)+'latest'
WhereAmI('@ the Item List -- url: %s' % url)
start=int(startPage); end=(start+int(numOfPages)); html=''; html_last=''; nextpage=startPage; deb('page start',str(start)); deb('page end',str(end))
try: html_=net.http_GET(url).content
except:
try: html_=getURL(url)
except:
try: html_=getURLr(url,_domain_url)
except: html_=''
#print html_
if (html_=='') or (html_=='none') or (html_==None):
deb('Error','Problem with page'); deadNote('Results: '+section,'No results were found.')
return
try: last=int(re.compile('<li><a href="http://.+?page=\d+">(\d+)</a></li>[\n]\s+<li class="next">', re.IGNORECASE | re.DOTALL).findall(html_))[0]
except: last=2
deb('number of pages',str(last))
#print min(last,end)
if ('<h1>Nothing was found by your request</h1>' in html_):
deadNote('Results: '+section,'Nothing was found by your request'); eod(); return
pmatch=re.findall(ps('LI.page.find'), html_)
if pmatch: last=pmatch[-1]
if ('?' in url): urlSplitter='&page='; deb('urlSplitter',urlSplitter) ## Quick fix for urls that already have '?' in it.
else: urlSplitter='?page='; deb('urlSplitter',urlSplitter)
for page in range(start,min(last,end)):
if (int(page)> 1): #if (int(startPage)> 1):
if ('&page=' in url): pageUrl=url.replace('&page=','&pagenull=')+'&page='+str(page) ## Quick fix.
if ('?page=' in url): pageUrl=url.replace('?page=','?pagenull=')+'&page='+str(page) ## Quick fix.
else: pageUrl=url+urlSplitter+str(page) #ps('LI.page.param')+startPage
else: pageUrl=url
deb('item listings for',pageUrl)
try:
try: html_last=net.http_GET(pageUrl).content
except:
try: html_=getURL(url)
except: t=''
if (_shoDebugging==True) and (html_last==''): deadNote('Testing','html_last is empty')
if (html_last in html): t=''
else: html=html+'\r\n'+html_last
##if (_debugging==True): print html_last
except: t=''
if (ps('LI.nextpage.check') in html_last):
if (_debugging==True): print 'A next-page has been found.'
nextpage=re.findall(ps('LI.nextpage.match'), html_last)[0] #nextpage=re.compile('<li class="next"><a href="http://www.solarmovie.so/.+?.html?page=(\d+)"></a></li>').findall(html_last)[0]
if (int(nextpage) <= last) and (end < last) and (start < last) and (start is not int(nextpage)): #(int(nextpage) > end) and (int(nextpage) <= last): # and (end < last): ## Do Show Next Page Link ##
if (_debugging==True): print 'A next-page is being added.'
#print {'mode': 'GetTitles', 'url': url, 'pageno': nextpage, 'pagecount': numOfPages}
_addon.add_directory({'mode': 'GetTitles', 'section': section, 'url': url, 'pageno': nextpage, 'pagecount': numOfPages}, {'title': ps('LI.nextpage.name')}, img=ps('img_next'))
#print {'start':str(start),'end':str(end),'last':str(last),'nextpage':str(nextpage)}
### ### _addon.add_directory({'mode': 'GetTitles', 'url': url, 'startPage': str(end), 'numOfPages': numOfPages}, {'title': 'Next...'})
###html=nolines(html)
html=ParseDescription(html); html=remove_accents(html) #if (_debugging==True): print html
html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
deb('Length of HTML',str(len(html)))