PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/default.py

https://github.com/HIGHWAY99/plugin.video.vidics4
Python | 2023 lines | 1976 code | 3 blank | 44 comment | 27 complexity | bd8bf772fb3e1ba1a0dd3816873cd086 MD5 | raw file
  1. ### ############################################################################################################
  2. ### #
  3. ### # Project: # Vidics4.com - by The Highway 2013.
  4. ### # Author: # The Highway
  5. ### # Version: # v0.2.6
  6. ### # Description: # http://www.Vidics4.com
  7. ### #
  8. ### ############################################################################################################
  9. ### ############################################################################################################
  10. ##### Imports #####
  11. import xbmc,xbmcplugin,xbmcgui,xbmcaddon,xbmcvfs
  12. #import requests ### (Removed in v0.2.1b to fix scripterror on load on Mac OS.) ###
  13. try: import requests ### <import addon="script.module.requests" version="1.1.0"/> ###
  14. except: t='' ### See https://github.com/kennethreitz/requests ###
  15. import urllib,urllib2,re,os,sys,htmllib,string,StringIO,logging,random,array,time,datetime
  16. import urlresolver
  17. import copy
  18. ###
  19. #import cookielib
  20. #import base64
  21. #import threading
  22. ###
  23. #import unicodedata ### I don't want to use unless I absolutely have to. ###
  24. #import zipfile ### Removed because it caused videos to not play. ###
  25. import HTMLParser, htmlentitydefs
  26. try: import StorageServer
  27. except: import storageserverdummy as StorageServer
  28. try: from t0mm0.common.addon import Addon
  29. except: from t0mm0_common_addon import Addon
  30. try: from t0mm0.common.net import Net
  31. except: from t0mm0_common_net import Net
  32. try: from sqlite3 import dbapi2 as sqlite; print "Loading sqlite3 as DB engine"
  33. except: from pysqlite2 import dbapi2 as sqlite; print "Loading pysqlite2 as DB engine"
  34. try: from script.module.metahandler import metahandlers
  35. except: from metahandler import metahandlers
  36. ###
  37. from teh_tools import *
  38. from config import *
  39. ##### /\ ##### Imports #####
  40. ### ############################################################################################################
  41. ### ############################################################################################################
  42. ### ############################################################################################################
  43. __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')
  44. _database_file=os.path.join(xbmc.translatePath("special://database"),ps('_database_name')+'.db');
  45. ###
  46. _addon=Addon(ps('_addon_id'), sys.argv); addon=_addon; _plugin=xbmcaddon.Addon(id=ps('_addon_id')); cache=StorageServer.StorageServer(ps('_addon_id'))
  47. ### ############################################################################################################
  48. ### ############################################################################################################
  49. ### ############################################################################################################
  50. ##### Paths #####
  51. ### # ps('')
  52. _addonPath =xbmc.translatePath(_plugin.getAddonInfo('path'))
  53. _artPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_art')))
  54. _datapath =xbmc.translatePath(_addon.get_profile()); _artIcon =_addon.get_icon(); _artFanart =_addon.get_fanart()
  55. ##### /\ ##### Paths #####
  56. ##### Important Functions with some dependencies #####
  57. 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. ###
  58. ##### /\ ##### Important Functions with some dependencies #####
  59. ##### Settings #####
  60. _setting={}; _setting['enableMeta'] = _enableMeta =tfalse(addst("enableMeta"))
  61. _setting['debug-enable']= _debugging =tfalse(addst("debug-enable")); _setting['debug-show'] = _shoDebugging =tfalse(addst("debug-show"))
  62. _setting['meta.movie.domain']=ps('meta.movie.domain'); _setting['meta.movie.search']=ps('meta.movie.search')
  63. _setting['meta.tv.domain'] =ps('meta.tv.domain'); _setting['meta.tv.search'] =ps('meta.tv.search')
  64. _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'))
  65. CurrentPercent=0; CancelDownload=False
  66. ##### /\ ##### Settings #####
  67. ##### Variables #####
  68. _art404='http://www.solarmovie.so/images/404.png' #_art404=art('404')
  69. _art150='http://www.solarmovie.so/images/thumb150.png' #_art150=art('thumb150')
  70. _artDead='http://www.solarmovie.so/images/deadplanet.png' #_artDead=art('deadplanet')
  71. _artSun=art('sun'); COUNTRIES=ps('COUNTRIES'); GENRES=ps('GENRES'); _default_section_=ps('default_section'); net=Net(); DB=_database_file; BASE_URL=_domain_url;
  72. ##### /\ ##### Variables #####
  73. deb('Addon Path',_addonPath); deb('Art Path',_artPath); deb('Addon Icon Path',_artIcon); deb('Addon Fanart Path',_artFanart)
  74. ### ############################################################################################################
  75. def eod(): _addon.end_of_directory()
  76. def deadNote(header='',msg='',delay=5000,image=_artDead): _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
  77. def sunNote( header='',msg='',delay=5000,image=_artSun):
  78. header=cFL(header,ps('cFL_color')); msg=cFL(msg,ps('cFL_color2'))
  79. _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
  80. def messupText(t,_html=False,_ende=False,_a=False,Slashes=False):
  81. if (_html==True): t=ParseDescription(HTMLParser.HTMLParser().unescape(t))
  82. if (_ende==True): t=t.encode('ascii', 'ignore'); t=t.decode('iso-8859-1')
  83. if (_a==True): t=_addon.decode(t); t=_addon.unescape(t)
  84. if (Slashes==True): t=t.replace( '_',' ')
  85. return t
  86. def name2path(name): return (((name.lower()).replace('.','-')).replace(' ','-')).replace('--','-')
  87. def name2pathU(name): return (((name.replace(' and ','-')).replace('.','-')).replace(' ','-')).replace('--','-')
  88. ### ############################################################################################################
  89. ### ############################################################################################################
  90. ##### Queries #####
  91. _param={}
  92. _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)
  93. _param['img']=addpr('img',''); _param['fanart']=addpr('fanart',''); _param['thumbnail'],_param['thumbnail'],_param['thumbnail']=addpr('thumbnail',''),addpr('thumbnailshow',''),addpr('thumbnailepisode','')
  94. _param['section']=addpr('section','movies'); _param['title']=addpr('title',''); _param['year']=addpr('year',''); _param['genre']=addpr('genre','')
  95. _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','')
  96. _param['pars']=addpr('pars',''); _param['labs']=addpr('labs',''); _param['name']=addpr('name',''); _param['thetvdbid']=addpr('thetvdbid','')
  97. _param['plot']=addpr('plot',''); _param['tomode']=addpr('tomode',''); _param['country']=addpr('country','')
  98. _param['thetvdb_series_id']=addpr('thetvdb_series_id',''); _param['dbid']=addpr('dbid',''); _param['user']=addpr('user','')
  99. _param['subfav']=addpr('subfav',''); _param['episodetitle']=addpr('episodetitle',''); _param['special']=addpr('special',''); _param['studio']=addpr('studio','')
  100. #_param['']=_addon.queries.get('','')
  101. #_param['']=_addon.queries.get('','')
  102. ##_param['pagestart']=addpr('pagestart',0)
  103. ##### /\
  104. ### ############################################################################################################
  105. ### ############################################################################################################
  106. def initDatabase():
  107. print "Building solarmovie Database"
  108. if ( not os.path.isdir( os.path.dirname(_database_file) ) ): os.makedirs( os.path.dirname( _database_file ) )
  109. db=sqlite.connect(_database_file); cursor=db.cursor()
  110. cursor.execute('CREATE TABLE IF NOT EXISTS seasons (season UNIQUE, contents);')
  111. cursor.execute('CREATE TABLE IF NOT EXISTS favorites (type, name, url, img);')
  112. db.commit(); db.close()
  113. ### ############################################################################################################
  114. ### ############################################################################################################
  115. ### ############################################################################################################
  116. ##### Player Functions #####
  117. def PlayVideo(url, infoLabels, listitem):
  118. WhereAmI('@ PlayVideo -- Getting ID From: %s' % url);
  119. #My_infoLabels=eval(infoLabels)
  120. #infoLabels={ "Studio": _param['studio'], "ShowTitle": _param['showtitle'], "Title": _param['title'], "Year": _param['Year'], "Plot": _param['Plot'], 'IMDbURL': _param['IMDbURL'], 'IMDbID': _param['imdbid'], 'IMDb': _param['imdb'] }
  121. infoLabels={ "Studio": _param['studio'], "ShowTitle": _param['showtitle'], "Title": _param['title'], "Year": _param['year'], "Plot": _param['plot'] }
  122. li=xbmcgui.ListItem(_param['title'], iconImage=_param['img'], thumbnailImage=_param['img'])
  123. #match=re.search( '/.+?/.+?/(.+?)/', url) ## Example: http://www.solarmovie.so/link/show/1052387/ ##
  124. #videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
  125. #html=net.http_GET(url).content
  126. #match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL)
  127. #link=match.group(1)
  128. link=url
  129. link=link.replace('/embed/', '/file/'); deb('hoster link',link)
  130. li.setInfo(type="Video", infoLabels=infoLabels ); li.setProperty('IsPlayable', 'true')
  131. try: stream_url = urlresolver.HostedMediaFile(link).resolve()
  132. except:
  133. deb('Link URL Was Not Resolved',link); deadNote("urlresolver.HostedMediaFile(link).resolve()","Failed to Resolve Playable URL."); return
  134. eod()
  135. ##xbmc.Player().stop()
  136. play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
  137. try: _addon.resolve_url(url)
  138. except: t=''
  139. try: _addon.resolve_url(stream_url)
  140. except: t=''
  141. play.play(stream_url, li); xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=li)
  142. try: _addon.resolve_url(url)
  143. except: t=''
  144. try: _addon.resolve_url(stream_url)
  145. except: t=''
  146. def PlayLibrary(section, url, showtitle='', showyear=''): ### Menu for Listing Hosters (Host Sites of the actual Videos)
  147. WhereAmI('@ Play Library: %s' % url); sources=[]; listitem=xbmcgui.ListItem()
  148. #eod()
  149. #_addon.resolve_url(url)
  150. if (url==''): return
  151. html=net.http_GET(url).content; html=html.encode("ascii", "ignore")
  152. ##if (_debugging==True): print html
  153. #if ( section == 'tv'): ## TV Show ## Title (Year) - Info
  154. # 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>
  155. # if (_debugging==True): print match
  156. # if (match==None): return
  157. # ShowYear=_param['year'] #ShowYear=showyear
  158. # ShowTitle=match[0].strip(); EpisodeTitle=match[1].strip(); Season=match[2].strip(); Episode=match[3].strip()
  159. # 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')
  160. # if ('<p id="plot_' in html):
  161. # 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')
  162. # else: ShowPlot=''
  163. # match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
  164. # if (_debugging==True): print match
  165. # (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 )
  166. #else: #################### Movie ## Title (Year) - Info
  167. # match=re.compile(ps('LLinks.compile.show.title_year'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
  168. # if (_debugging==True): print match
  169. # if (match==None): return
  170. # 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]
  171. # if (_debugging==True): print match
  172. # (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 )
  173. ### Both -Movies- and -TV Shows- ### Hosters
  174. try: matchH=re.compile(ps('LLinks.compile.hosters2'), re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)
  175. except: matchH=''
  176. #deb('length of matchH',str(len(matchH)))
  177. #print matchH
  178. if (len(matchH) > 0):
  179. oList=[]; hList=[]; matchH=sorted(matchH, key=lambda item: item[3], reverse=True)
  180. for url, host, quality, age in matchH:
  181. url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
  182. try: mID=re.compile('/.+?/.+?/([0-9]+)/', re.DOTALL | re.IGNORECASE).findall(url)[0]
  183. except: mID=''
  184. #deb('Media Passed',str(host)+' | '+str(quality)+' | '+str(age)+' | '+str(url)+' | '+str(mID))
  185. if (mID is not ''):
  186. oList.append(host+' ['+quality+'] ('+age+')')
  187. hList.append([url,host,quality,age,mID])
  188. try: rt=askSelection(oList,'Select Source:')
  189. except: rt=''
  190. print rt
  191. if (rt==None) or (rt=='none') or (rt==False) or (rt==''): return
  192. hItem=hList[rt]
  193. deb('ID',hItem[4])
  194. urlB='%s/link/play/%s/' % (ps('_domain_url'),hItem[4])
  195. html=net.http_GET(urlB).content
  196. try: url=re.compile('<iframe.+?src="(.+?)"', re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)[0]
  197. except: url=''
  198. url=url.replace('/embed/', '/file/'); deb('hoster url',url)
  199. #oList=[]
  200. #for url, host, quality, age in match:
  201. # url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
  202. # print 'Media Failed: '+str(host)+' | '+str(quality)+' | '+str(age)+' | '+url
  203. # if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
  204. # try: MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
  205. # except: MediaID=''
  206. # try: MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
  207. # except: MediaHost=''
  208. # print 'Media Passed: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
  209. # if (MediaHost is not '') and (MediaID is not ''):
  210. # oList.append(urlresolver.HostedMediaFile(host=MediaHost, media_id=MediaID))
  211. ##
  212. #
  213. #try: url=urlresolver.choose_source(oList)
  214. #except: return
  215. #
  216. #MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
  217. #MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
  218. #print 'Media: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
  219. #print str(urlresolver.HostedMediaFile(url=url.strip()).valid_url())
  220. #if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
  221. #
  222. #
  223. #
  224. #
  225. #videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
  226. #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)
  227. #
  228. deb('video',url)
  229. liz=xbmcgui.ListItem(_param['showtitle'], iconImage="DefaultVideo.png", thumbnailImage=_param['img'])
  230. if ( section == 'tv'): ## TV Show ## Title (Year) - Info
  231. liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
  232. else: #################### Movies ### Title (Year) - Info
  233. liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
  234. liz.setProperty("IsPlayable","true")
  235. ##pl=xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  236. ##pl.clear()
  237. ##pl.add(url, liz)
  238. ##xbmc.Player().play(pl)
  239. play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
  240. print url
  241. stream_url = urlresolver.HostedMediaFile(url).resolve()
  242. print stream_url
  243. play.play(stream_url, liz)
  244. #play.play(url, liz)
  245. liz.setPath(url)
  246. xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
  247. _addon.resolve_url(url)
  248. _addon.resolve_url(stream_url)
  249. ##
  250. ##
  251. ##
  252. ##count=1
  253. ##for url, host, quality, age in match:
  254. ## host=host.strip(); quality=quality.strip(); name=str(count)+". "+host+' - [[B]'+quality+'[/B]] - ([I]'+age+'[/I])'
  255. ## if urlresolver.HostedMediaFile(host=host, media_id='xxx'):
  256. ## 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
  257. eod()
  258. else: return
  259. ### ################################################################
  260. def DownloadStop(): ## Testing ## Doesn't work yet.
  261. global CancelDownload
  262. CancelDownload=True
  263. #global CancelDownload
  264. eod()
  265. #download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
  266. #if (download_method=='Progress'):
  267. # dp=xbmcgui.DialogProgress() ## For Frodo and earlier.
  268. # dp.close()
  269. #elif (download_method=='ProgressBG'):
  270. # dp=xbmcgui.DialogProgressBG() ## Only works on daily build of XBMC.
  271. # dp.close()
  272. #elif (download_method=='Test'):
  273. # t=''
  274. #elif (download_method=='Hidden'):
  275. # t=''
  276. #else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
  277. #try: t=''
  278. #except: t=''
  279. def DownloadStatus(numblocks, blocksize, filesize, dlg, download_method, start_time, section, url, img, LabelName, ext, LabelFile):
  280. if (CancelDownload==True):
  281. try:
  282. if (download_method=='Progress'): ## For Frodo and earlier.
  283. dlg.close()
  284. elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
  285. dlg.close()
  286. elif (download_method=='Test'): t=''
  287. elif (download_method=='Hidden'): t=''
  288. except: t=''
  289. try:
  290. percent = min(numblocks * blocksize * 100 / filesize, 100)
  291. currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
  292. kbps_speed = numblocks * blocksize / (time.time() - start_time)
  293. if kbps_speed > 0: eta = (filesize - numblocks * blocksize) / kbps_speed
  294. else: eta = 0
  295. kbps_speed /= 1024
  296. total = float(filesize) / (1024 * 1024)
  297. #if (download_method=='Progress'): ## For Frodo and earlier.
  298. # line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
  299. # line1 +=' '+percent+'%'
  300. # line2 = 'Speed: %.02f Kb/s ' % kbps_speed
  301. # line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
  302. # dlg.update(percent, line1, line2, line3)
  303. #elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
  304. # line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
  305. # line1 +=' '+percent+'%'
  306. # line2 ='Speed: %.02f Kb/s ' % kbps_speed
  307. # line2 +='ETA: %02d:%02d' % divmod(eta, 60)
  308. # dlg.update(percent, line1, line2)
  309. #elif (download_method=='Test'):
  310. # mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
  311. # spd = 'Speed: %.02f Kb/s ' % kbps_speed
  312. # est = 'ETA: %02d:%02d' % divmod(eta, 60)
  313. # Header= ext+' '+mbs+' '+percent+'%'
  314. # Message= est+' '+spd
  315. #elif (download_method=='Hidden'): t=''
  316. #if (time.time()==start_time) or (int(str(time.time())[-5:1]) == 0): # and (int(str(time.time())[-5:2]) < 10):
  317. #if (int(time.strptime(time.time(),fmt='%S')) == 0):
  318. #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']):
  319. #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'):
  320. #if ('.' in str(percent)): pCheck=int(str(percent).split('.')[0])
  321. #else: pCheck=percent
  322. #pCheck=int(str(percent)[1:])
  323. #if (CurrentPercent is not pCheck):
  324. # global CurrentPercent
  325. # CurrentPercent=pCheck
  326. # myNote(header=Header,msg=Message,delay=100,image=img)
  327. ##myNote(header=Header,msg=Message,delay=1,image=img)
  328. except:
  329. percent=100
  330. if (download_method=='Progress'): ## For Frodo and earlier.
  331. t=''
  332. dlg.update(percent)
  333. elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
  334. t=''
  335. dlg.update(percent)
  336. elif (download_method=='Test'): t=''
  337. #myNote(header='100%',msg='Download Completed',delay=15000,image=img)
  338. elif (download_method=='Hidden'): t=''
  339. if (download_method=='Progress'): ## For Frodo and earlier.
  340. line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
  341. line1 +=' '+str(percent)+'%'
  342. line2 = 'Speed: %.02f Kb/s ' % kbps_speed
  343. line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
  344. dlg.update(percent, line1, line2, line3)
  345. elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
  346. line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
  347. line1 +=' '+str(percent)+'%'
  348. line2 ='Speed: %.02f Kb/s ' % kbps_speed
  349. line2 +='ETA: %02d:%02d' % divmod(eta, 60)
  350. dlg.update(percent, line1, line2)
  351. elif (download_method=='Test'):
  352. mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
  353. spd = 'Speed: %.02f Kb/s ' % kbps_speed
  354. est = 'ETA: %02d:%02d' % divmod(eta, 60)
  355. Header= ext+' '+mbs+' '+str(percent)+'%'
  356. Message= est+' '+spd
  357. elif (download_method=='Hidden'): t=''
  358. if (download_method=='Progress'): ## For Frodo and earlier.
  359. try:
  360. if dlg.iscanceled(): ## used for xbmcgui.DialogProgress() but causes an error with xbmcgui.DialogProgressBG()
  361. dlg.close()
  362. #deb('Download Error','Download canceled.'); myNote('Download Error','Download canceled.')
  363. #raise StopDownloading('Stopped Downloading')
  364. except: t=''
  365. elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
  366. try:
  367. if (dlg.isFinished()):
  368. dlg.close()
  369. except: t=''
  370. def DownloadRequest(section, url,img,LabelName):
  371. if (LabelName=='') and (_param['title'] is not ''): LabelName==_param['title']
  372. if (LabelName=='') and (_param['showtitle'] is not ''): LabelName==_param['showtitle']
  373. LabelFile=clean_filename(LabelName)
  374. deb('LabelName',LabelName)
  375. if (LabelName==''): deb('Download Error','Missing Filename String.'); myNote('Download Error','Missing Filename String.'); return
  376. if (section==ps('section.wallpaper')): FolderDest=xbmc.translatePath(addst("download_folder_wallpapers"))
  377. elif (section==ps('section.tv')): FolderDest=xbmc.translatePath(addst("download_folder_tv"))
  378. elif (section==ps('section.movie')): FolderDest=xbmc.translatePath(addst("download_folder_movies"))
  379. else: FolderDest=xbmc.translatePath(addst("download_folder_movies"))
  380. if os.path.exists(FolderDest)==False: os.mkdir(FolderDest)
  381. if os.path.exists(FolderDest):
  382. if (section==ps('section.tv')) or (section==ps('section.movie')):
  383. ### param >> url: /link/show/1466546/
  384. match=re.search( '/.+?/.+?/(.+?)/', url) ## Example: http://www.solarmovie.so/link/show/1052387/ ##
  385. videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
  386. 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)
  387. try: stream_url = urlresolver.HostedMediaFile(link).resolve()
  388. except: stream_url=''
  389. ext=Download_PrepExt(stream_url,'.flv')
  390. else:
  391. stream_url=url
  392. ext=Download_PrepExt(stream_url,'.jpg')
  393. t=1; c=1
  394. if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext))):
  395. t=LabelFile
  396. while t==LabelFile:
  397. if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+'['+str(c)+']'+ext)))==False:
  398. LabelFile=LabelFile+'['+str(c)+']'
  399. c=c+1
  400. start_time = time.time()
  401. deb('start_time',str(start_time))
  402. download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
  403. urllib.urlcleanup()
  404. if (download_method=='Progress'):
  405. dp=xbmcgui.DialogProgress(); dialogType=12 ## For Frodo and earlier.
  406. dp.create('Downloading', LabelFile+ext)
  407. 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)
  408. myNote('Download Complete',LabelFile+ext,15000)
  409. elif (download_method=='ProgressBG'):
  410. dp=xbmcgui.DialogProgressBG(); dialogType=13 ## Only works on daily build of XBMC.
  411. dp.create('Downloading', LabelFile+ext)
  412. 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)
  413. myNote('Download Complete',LabelFile+ext,15000)
  414. elif (download_method=='Test'):
  415. dp=xbmcgui.DialogProgress()
  416. myNote('Download Started',LabelFile+ext,15000)
  417. 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)
  418. myNote('Download Complete',LabelFile+ext,15000)
  419. elif (download_method=='Hidden'):
  420. dp=xbmcgui.DialogProgress()
  421. myNote('Download Started',LabelFile+ext,15000)
  422. 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)
  423. myNote('Download Complete',LabelFile+ext,15000)
  424. elif (download_method=='jDownloader (StreamURL)'):
  425. myNote('Download','sending to jDownloader plugin',15000)
  426. xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % stream_url)
  427. #return
  428. elif (download_method=='jDownloader (Link)'):
  429. myNote('Download','sending to jDownloader plugin',15000)
  430. xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % link)
  431. #return
  432. else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
  433. ##
  434. ##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)
  435. ##
  436. #myNote('Download Complete',LabelFile+ext,15000)
  437. ##
  438. #### xbmc.translatePath(os.path.join(FolderDest,localfilewithpath+ext))
  439. _addon.resolve_url(url)
  440. _addon.resolve_url(stream_url)
  441. #
  442. #
  443. else: deb('Download Error','Unable to create destination path.'); myNote('Download Error','Unable to create destination path.'); return
  444. def PlayTrailer(url,_title,_year,_image): ### Not currently used ###
  445. WhereAmI('@ PlayVideo: %s' % url) #; sources=[]; url=url.decode('base-64')
  446. #if ('<h2>Movie trailer</h2>' not in url): eod(); return
  447. EmbedID=''; html=net.http_GET(url).content #getURL(url)
  448. html=messupText(html,True,True,True,False)
  449. #print str(html)
  450. if ('traileraddict.com/emd/' in html):
  451. deb('Found','traileraddict.com/emd/')
  452. #EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
  453. try: EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
  454. except: EmbedID=''
  455. if (EmbedID==''):
  456. #print html
  457. #ImdbID=re.compile('<strong>IMDb ID:</strong>[\n]\s+<a href=".+?">(\d+)</a>"', re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  458. try: ImdbID=re.compile('%2Ftitle%2Ftt(\d+)%2F"', re.DOTALL).findall(html)[0].strip()
  459. except: ImdbID=''
  460. if (ImdbID==''): eod(); deb('Error Playing Trailer','No Imdb ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
  461. deb('ImdbID',ImdbID)
  462. thtml=getURL('http://api.traileraddict.com/?imdb='+ImdbID)
  463. try: EmbedID=re.compile('"http://www.traileraddict.com/emd/([0-9]+)"', re.DOTALL).findall(thtml)[0].strip()
  464. except: EmbedID=''
  465. if (EmbedID==''): eod(); deb('Error Playing Trailer','No Embed Video ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
  466. deb('EmbedID',EmbedID)
  467. vhtml=getURL('http://www.traileraddict.com/fvar.php?tid='+EmbedID) #vhtml=getURL('http://www.traileraddict.com/fvarhd.php?tid='+EmbedID)
  468. #print vhtml
  469. if ('Error: Trailer is (Possibly Temporarily) Unavailable' in vhtml): deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
  470. try: thumb=re.compile('&image=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
  471. except: thumb=_param['img']
  472. try: title=re.compile('&filmtitle=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
  473. except: title=_param['title']
  474. try: url=re.compile('&fileurl=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
  475. except:
  476. try: url=re.compile('&fileurl=(.+?)[\n]\s+&', re.DOTALL).findall(vhtml)[0].strip()
  477. except: url=''
  478. if (url==''): eod(); deb('Error Playing Trailer','No Url was found from vhtml.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
  479. url=urllib.unquote_plus(url)
  480. deb('video',url)
  481. liz=xbmcgui.ListItem(_param['showtitle'], iconImage=thumb, thumbnailImage=_image)
  482. liz.setInfo( type="Video", infoLabels={ "Title": title, "Studio": _title+' ('+_year+')' } )
  483. liz.setProperty("IsPlayable","true")
  484. play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
  485. play.play(url, liz)
  486. #liz.setPath(url)
  487. #xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
  488. _addon.resolve_url(url)
  489. #eod(); return
  490. ##### /\ ##### Player Functions #####
  491. ### ############################################################################################################
  492. ### ############################################################################################################
  493. ### ############################################################################################################
  494. ##### Weird, Stupid, or Plain up Annoying Functions. #####
  495. def netURL(url): ### Doesn't seem to work.
  496. return net.http_GET(url).content
  497. def remove_accents(input_str): ### Not even sure rather this one works or not.
  498. #nkfd_form = unicodedata.normalize('NFKD', unicode(input_str))
  499. #return u"".join([c for c in nkfd_form if not unicodedata.combining(c)])
  500. return input_str
  501. ##### /\ ##### Weird, Stupid, or Plain up Annoying Functions. #####
  502. ### ############################################################################################################
  503. ### ############################################################################################################
  504. ### ############################################################################################################
  505. ##### Menus #####
  506. def Trailers_Genres(section, url):
  507. WhereAmI('@ the Genre Menu for Trailers')#print 'Browse by genres screen'
  508. browsebyImg=checkImgLocal(art('genre','.jpg'))
  509. pathA='http://www.solarmovie.so/coming-soon/'; pathC=''#'/#coming-soon'
  510. if ('popularity' in url): pathB='popularity/'
  511. elif ('date' in url): pathB='date/'
  512. else: eod(); return
  513. TrailersGNERES=ps('Trailers.GENRES')
  514. ItemCount=len(TrailersGNERES) # , total_items=ItemCount
  515. for genre in TrailersGNERES:
  516. img=''; imgName=genre #; pre='http://icons.iconarchive.com/icons/sirubico/movie-genre/128/'
  517. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
  518. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
  519. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
  520. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
  521. if (img=='') and (browsebyImg is not ''): img=browsebyImg
  522. if (img==''): img=_artSun
  523. if (genre.lower()=='all'): url=pathA+pathB+('')+pathC
  524. else: url=pathA+pathB+(genre.lower())+pathC
  525. _addon.add_directory({'section': section,'mode': 'TrailersList','url': url,'genre': genre,'bygenre': genre }, {'title': genre},img=img,fanart=_artFanart, total_items=ItemCount)
  526. set_view('list',addst('default-view')); eod()
  527. def mGetItemPage(url):
  528. deb('Fetching html from Url',url)
  529. try: html=net.http_GET(url).content
  530. except: html=''
  531. if (html=='') or (html=='none') or (html==None) or (html==False): return ''
  532. else:
  533. 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)))
  534. return html
  535. def mGetDataTest(html,toGet): ## For Testing Only
  536. resultCnt=0; results={}; debob(toGet)
  537. for item in toGet:
  538. parseTag='<p id="plot_\d+">(.+?)</p>'; item=item.lower()
  539. results[item]=(re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip()
  540. return results
  541. def mGetDataPlot(html,parseTag='<p id=\"plot_\d+\">(.+?)</p>'): ## Working Temp-Fix
  542. if ('<p id="plot_' in html):
  543. try: return (re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip()
  544. except: return ''
  545. else: return ''
  546. def mGetDataGroup2String(html,parseTag='',ifTag='',startTag='',endTag='',Topic=''):
  547. if (ifTag in html):
  548. html=(((html.split(startTag)[1])).split(endTag)[0]).strip()
  549. try: results=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  550. except: return ''
  551. i=0; r=''
  552. for result in results:
  553. if (i==0): r=result.strip()
  554. else: r=r+', '+result.strip()
  555. i=i+1
  556. deb(Topic,r); return r
  557. else: return ''
  558. def mGetDataGenre(html,parseTag='<a href=".+?watch-.+?-.+?s.html">[\n]\s+(.+?)</a>',ifTag='.html">',startTag='<div class="mediaDescription">',endTag='<div class="buttonsLine">',Topic='Genre'): ## Think I'll keep this one since it needs the outside part parsed out.
  559. return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
  560. def mGetDataCountry(html,parseTag='<a href=".+?s-from.+?.html">(.+?)</a>',ifTag='.html">',startTag='<div class="mediaDescription">',endTag='<div class="buttonsLine">',Topic='Country'): ## Think I'll keep this one since it needs the outside part parsed out.
  561. return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
  562. def mGetDataDirector(html,parseTag='<a href="/watch-movies-by-.+?.html">[\n]\s+(.+?)</a>',ifTag='<h4>Director</h4>',startTag='<h4>Director</h4>',endTag='</div>',Topic='Director'): ## Think I'll keep this one since it needs the outside part parsed out.
  563. return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
  564. def mGetDataCast(html,parseTag='<a href="/watch-movies-with-.+?.html">[\n]\s+(.+?)</a>',ifTag='<h4>Cast</h4>',startTag='<h4>Cast</h4>',endTag='</div>',Topic='Cast'): ## Think I'll keep this one since it needs the outside part parsed out.
  565. return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
  566. def mGetDataKeywords(html,parseTag='<a href="/watch-movies-tagged-as-.+?.html">[\n]\s+(.+?)</a>',ifTag='<h4>Keywords</h4>',startTag='<h4>Keywords</h4>',endTag='</div>',Topic='Keywords'): ## Think I'll keep this one since it needs the outside part parsed out.
  567. return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
  568. def mdGetTV(html,toGet):
  569. resultCnt=0; results={}; debob(toGet)
  570. for item in toGet:
  571. item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; parsePreResult=''; rCheck=False
  572. if (item=='result.url'): ###
  573. parseMethod='re.compile.prefix'; parsePreResult=_setting['meta.tv.page']; parseTag='<tr><td class="\D+">\d+</td>.+?href="/index.php.+?tab=series.+?id=(\d+)&.+?lid=7">'
  574. if ('>English</td>' in html): rCheck=True
  575. elif (item=='result.id'): ###
  576. parseMethod='re.compile'; parseTag='<tr><td class="\D+">\d+</td>.+?href="/index.php.+?tab=series.+?id=(\d+)&lid=7">' ## &amp; 's were parsed out earlier. ##
  577. if ('>English</td>' in html): rCheck=True
  578. elif (item=='fanart'): ###
  579. parseMethod='re.compile.group'; parsePreResult=_setting['meta.tv.domain']; parseTag='<tr><td></td><td align=right><a href="(.+?)" target="_blank">View Full Size</a></td></tr>'
  580. if ('" target="_blank">View Full Size</a></td></tr>' in html): rCheck=True
  581. elif (item=='thetvdb.episode.overviews'): ###
  582. parseMethod='split'; parseTag='<td>Overview: </td>'; parseTag2='</tr>'; deb('get item',item)
  583. if ('<td>Overview: </td>' in html): rCheck=True
  584. elif (item=='thetvdb.episode.overview1'): ###
  585. parseMethod='split'; parseTag='<textarea rows="10" cols="45" name="Overview_7" style="display: inline">'; parseTag2='</textarea>'; deb('get item',item)
  586. if ('<td>Overview: </td>' in html): rCheck=True
  587. elif (item=='thetvdb.episode.overview'): ###
  588. parseMethod='re.compile'; parseTag='<textarea rows="10" cols="45" name="Overview_7" style="display: inline">(.+?)</textarea>'; deb('get item',item)
  589. if ('<td>Overview: </td>' in html): rCheck=True
  590. #else: rCheck=False
  591. #if (rCheck==False): print html
  592. deb('rCheck',str(rCheck))
  593. if (rCheck==True): ## Trying to do away with errors for results that dont contain the requested information.
  594. if (parseMethod=='re.compile2'): ## returns 2nd result
  595. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[1].strip()
  596. if (results[item]==''): results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  597. elif (parseMethod=='re.compile'): ## returns 1st result
  598. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  599. elif (parseMethod=='re.compile.fanart'): ## returns 1st result
  600. resultCnt=resultCnt+1; html2=(html.split('<h1>Fan Art</h1>')[1]).split('</table>')[0]
  601. if ('View Full Size' in html2): results[item]=parsePreResult+re.compile(parseTag, re.IGNORECASE | re.DOTALL).findall(html2)[0].strip()
  602. else: results[item]=''
  603. elif (parseMethod=='re.compile.prefix'): ## returns 1st result
  604. try: results[item]=parsePreResult+re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  605. except: results[item]=''
  606. resultCnt=resultCnt+1
  607. elif (parseMethod=='re.compile.group'): ## returns a group of results
  608. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  609. elif (parseMethod=='split'):
  610. resultCnt=resultCnt+1; results[item]=(((html.split(parseTag)[1])).split(parseTag2)[0]).strip()
  611. elif (parseMethod=='re.search2'): ## returns 2nd result
  612. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(2)
  613. elif (parseMethod=='re.search'): ## returns 1st result
  614. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(1)
  615. elif (parseMethod=='re.search.group'): ## returns a group of results
  616. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group()
  617. else:
  618. resultCnt=resultCnt+1; results[item]=''
  619. else:
  620. resultCnt=resultCnt+1; results[item]=''
  621. if debugging==True: print results
  622. return results
  623. def mdGetSplitFindGroup(html,ifTag='', parseTag='',startTag='',endTag=''):
  624. if (ifTag=='') or (parseTag=='') or (startTag=='') or (endTag==''): return ''
  625. if (ifTag in html):
  626. html=(((html.split(startTag)[1])).split(endTag)[0]).strip()
  627. try: return re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  628. except: return ''
  629. else: return ''
  630. def mdGetMovie(html,toGet):
  631. resultCnt=0; results={}; debob(toGet)
  632. for item in toGet:
  633. item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; parsePreResult=''; rCheck=False
  634. if (item=='result.poster'): ###
  635. parseTag='<div class="poster">[\n]\s+<a href=".+?" title=".+?"><img class="right_shadow" src="(.+?)" width="\d+" height="\d+" /></a>'
  636. parseMethod='re.compile'
  637. if ('<div class="poster">' in html): rCheck=True
  638. elif (item=='result.url'): ###
  639. parsePreResult=_setting['meta.movie.domain']
  640. parseTag='<div class="poster">[\n]\s+<a href="(.+?)" title=".+?"><img class="right_shadow" src=".+?" width="\d+" height="\d+" /></a>'
  641. parseMethod='re.compile.prefix'
  642. if ('<div class="poster">' in html): rCheck=True
  643. elif (item=='og.image'): ###
  644. parseTag='<meta property="og:image" content="(.+?)" />'
  645. parseMethod='re.compile'
  646. if ('<meta property="og:image" content="' in html): rCheck=True
  647. elif (item=='og.image2'): ###
  648. parseTag='<meta property="og:image" content="(.+?)" />'
  649. parseMethod='re.compile2'
  650. if ('<meta property="og:image" content="' in html): rCheck=True
  651. elif (item=='og.plot'): ###
  652. parseTag='<meta property="og:description" content="(.+?)" />'
  653. parseMethod='re.compile'
  654. if ('<meta property="og:description" content="' in html): rCheck=True
  655. #if (item=='fanart'): ###
  656. # parseTag='<strong>IMDb rating:</strong>[\n]\s+(.+?)\s+\(.+? votes\)'
  657. # parseMethod='re.compile.group'
  658. # if ('<strong>IMDb rating:</strong>' in html): rCheck=True
  659. #else: rCheck=False
  660. deb('rCheck',str(rCheck))
  661. if (rCheck==True): ## Trying to do away with errors for results that dont contain the requested information.
  662. if (parseMethod=='re.compile2'): ## returns 2nd result
  663. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[1].strip()
  664. if (results[item]==''): results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  665. elif (parseMethod=='re.compile'): ## returns 1st result
  666. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  667. elif (parseMethod=='re.compile.prefix'): ## returns 1st result
  668. resultCnt=resultCnt+1; results[item]=parsePreResult+re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  669. elif (parseMethod=='re.compile.group'): ## returns a group of results
  670. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  671. elif (parseMethod=='split'):
  672. resultCnt=resultCnt+1; results[item]=(((html.split(parseTag)[1])).split(parseTag2)[0]).strip()
  673. elif (parseMethod=='re.search2'): ## returns 2nd result
  674. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(2)
  675. elif (parseMethod=='re.search'): ## returns 1st result
  676. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(1)
  677. elif (parseMethod=='re.search.group'): ## returns a group of results
  678. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group()
  679. else:
  680. resultCnt=resultCnt+1; results[item]=''
  681. else:
  682. resultCnt=resultCnt+1; results[item]=''
  683. if debugging==True: print results
  684. return results
  685. def mGetData(html,toGet):
  686. #if (html=='') or (html=='none') or (html==None) or (html==False):
  687. # deb('mGetData','html is empty')
  688. # return None
  689. resultCnt=0; results={}; debob(toGet)
  690. for item in toGet:
  691. item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; rCheck=False
  692. if (item=='plot') or (item=='movieplot') or (item=='showplot'): ###
  693. parseTag='<p id="plot_\d+">(.+?)</p>'
  694. parseMethod='re.compile'
  695. if ('<p id="plot_' in html):
  696. rCheck=True; deb("found","'<p id=\"plot_'")
  697. elif (item=='imdbrating'): ### 7.3
  698. parseMethod='re.compile'; parseTag='<strong>IMDb rating:</strong>[\n]\s+(.+?)\s+\(.+? votes\)'
  699. if ('<strong>IMDb rating:</strong>' in html): rCheck=True
  700. elif (item=='episodeplot'): ###
  701. parseMethod='re.compile2'; parseTag='<p id="plot_\d+">(.+?)</p>'
  702. if ('<p id="plot_' in html): rCheck=True
  703. elif (item=='latestepisodeplot'): ###
  704. parseMethod='re.compile2'; parseTag='<p id="plot_\d+">(.+?)</p>'
  705. if ('<p id="plot_' in html): rCheck=True
  706. elif (item=='imdbid'): ### 0816711
  707. parseMethod='re.compile'; parseTag='<strong>IMDb ID:</strong>[\n]\s+<a href=".+?">(\d+)</a>'
  708. if ('<strong>IMDb ID:</strong>' in html): rCheck=True
  709. elif (item=='imdburl'): ### http://anonym.to/?http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt0816711%2F
  710. parseMethod='re.compile'; parseTag='<strong>IMDb ID:</strong>[\n]\s+<a href="(.+?)">\d+</a>'
  711. if ('<strong>IMDb ID:</strong>' in html): rCheck=True
  712. elif (item=='imdbvotes'): ### 2,814
  713. parseMethod='re.compile'; parseTag='<strong>IMDb rating:</strong>[\n]\s+.+?\s+\((.+?) votes\)'
  714. if ('<strong>IMDb rating:</strong>' in html): rCheck=True
  715. elif (item=='duration'): ### 116 min
  716. parseMethod='re.compile'; parseTag='<strong>Duration:</strong>[\n]\s+(.+?)<'
  717. if ('<strong>Duration:</strong>' in html): rCheck=True
  718. elif (item=='duration2'):
  719. parseMethod='strip'; parseTag='<strong>Duration:</strong>'; parseTag2='<'
  720. if ('<strong>Duration:</strong>' in html): rCheck=True
  721. elif (item=='premiered'): ### June 21, 2013
  722. parseMethod='re.compile'; parseTag='<strong>Release Date:</strong>[\n]\s+(.+?)\s+[\n]\s+</div>'
  723. if ('<strong>Release Date:</strong>' in html): rCheck=True
  724. elif (item=='premiered2'):
  725. parseMethod='strip'; parseTag='<strong>Release Date:</strong>'; parseTag2='<'
  726. if ('<strong>Release Date:</strong>' in html): rCheck=True
  727. elif (item=='reelasedate'): ### June 21, 2013
  728. parseMethod='re.compile'; parseTag='<strong>Release Date:</strong>[\n]\s+(.+?)\s+[\n]\s+</div>'
  729. if ('<strong>Release Date:</strong>' in html): rCheck=True
  730. elif (item=='reelasedate2'):
  731. parseMethod='strip'; parseTag='<strong>Release Date:</strong>'; parseTag2='<'
  732. if ('<strong>Release Date:</strong>' in html): rCheck=True
  733. elif (item=='Votes'): ### 86
  734. parseMethod='re.compile'; parseTag='<strong>Solar rating:</strong>[\n]\s+<span class="js-votes"[\n]\s+>(\d+\s+votes</span>'
  735. if ('<strong>Solar rating:</strong>' in html) and ('<span class="js-votes"' in html) and ('votes</span>' in html): rCheck=True
  736. elif (item=='coverimage'): ### http://static.solarmovie.so/images/movies/0460681_150x220.jpg
  737. parseMethod='re.search'; parseTag='coverImage">.+?src="(.+?)"'
  738. if ('coverImage">' in html): rCheck=True
  739. elif (item=='season'): ###
  740. parseMethod='re.search'; parseTag="toggleSeason\('(\d+)'\)"
  741. if ('toggleSeason' in html): rCheck=True
  742. elif (item=='seasons'): ###
  743. parseMethod='re.search.group'; parseTag="toggleSeason\('(\d+)'\)"
  744. if ('toggleSeason' in html): rCheck=True
  745. elif (item=='episode'): ###
  746. parseMethod='re.compile'; parseTag='<span class="epname">[\n].+?<a href="(.+?)"[\n]\s+title=".+?">(.+?)</a>[\n]\s+<a href="/.+?/season-(\d+)/episode-(\d+)/" class=".+?">[\n]\s+(\d+) links</a>'
  747. if ('<span class="epname">' in html) and (' links</a>' in html): rCheck=True
  748. elif (item=='episodes'): ###
  749. parseMethod='re.compile.group'; parseTag='<span class="epname">[\n].+?<a href="(.+?)"[\n]\s+title=".+?">(.+?)</a>[\n]\s+<a href="/.+?/season-(\d+)/episode-(\d+)/" class=".+?">[\n]\s+(\d+) links</a>'
  750. if ('<span class="epname">' in html): rCheck=True
  751. else: rCheck=False
  752. ### Year
  753. # Fantasy</a> produced in
  754. # <a href="/tv/watch-tv-shows-2005.html">
  755. # 2005</a>
  756. ### Country
  757. # [<a href="/tv/tv-shows-from-usa.html">USA</a>]
  758. ### Latest Episode
  759. # <div class="mediaDescription latestTvEpisode">
  760. # <h5>Latest Episode:
  761. # <a href="/tv/supernatural-2005/season-8/episode-23/">
  762. # Sacrifice (<span>s08e23</span>)</a>
  763. # <em class="releaseDate">May 15, 2013</em>
  764. # </h5>
  765. #<p id="plot_476403">Sam and Dean capture Crowley to finish the trials and close the gates of Hell. Castiel and Metatron continue the trials to close the gates of Heaven. Sam is left with a huge decision.</p>
  766. # </div>
  767. ### Genres
  768. #<meta name="description" content="Watch full The Heat movie produced in 2013. Genres are Comedy, Crime, Action." />
  769. deb('rCheck',str(rCheck))
  770. if (rCheck==True): ## Trying to do away with errors for results that dont contain the requested information.
  771. if (parseMethod=='re.compile2'): ## returns 2nd result
  772. try: results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[1].strip()
  773. except: results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  774. resultCnt=resultCnt+1
  775. elif (parseMethod=='re.compile'): ## returns 1st result
  776. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
  777. elif (parseMethod=='re.compile.group'): ## returns a group of results
  778. resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  779. elif (parseMethod=='split'):
  780. resultCnt=resultCnt+1; results[item]=(((html.split(parseTag)[1])).split(parseTag2)[0]).strip()
  781. elif (parseMethod=='re.search2'): ## returns 2nd result
  782. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(2)
  783. elif (parseMethod=='re.search'): ## returns 1st result
  784. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(1)
  785. elif (parseMethod=='re.search.group'): ## returns a group of results
  786. resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group()
  787. else:
  788. resultCnt=resultCnt+1; results[item]=''
  789. else:
  790. resultCnt=resultCnt+1; results[item]=''
  791. if debugging==True: print results
  792. return results
  793. def listLinks(section, url, showtitle='', showyear=''): ### Menu for Listing Hosters (Host Sites of the actual Videos)
  794. WhereAmI('@ the Link List: %s' % url); sources=[]; listitem=xbmcgui.ListItem()
  795. if (url==''): return
  796. html=net.http_GET(url).content; html=html.encode("ascii", "ignore")
  797. #if (_debugging==True): print html
  798. if ( section == 'tv'): ## TV Show ## Title (Year) - Info
  799. 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>
  800. if (_debugging==True): print match
  801. if (match==None): return
  802. ShowYear=_param['year'] #ShowYear=showyear
  803. ShowTitle=match[0].strip(); EpisodeTitle=match[1].strip(); Season=match[2].strip(); Episode=match[3].strip()
  804. 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')
  805. if ('<p id="plot_' in html):
  806. 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')
  807. else: ShowPlot=''
  808. match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
  809. if (_debugging==True): print match
  810. (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 )
  811. else: #################### Movie ## Title (Year) - Info
  812. s ='<tr>\n*\s*<td><center><a target="_blank" href="(http://.+?)" target="_blank" rel="nofollow">\s*(Version\s*\d+)\s*</a></center></td>\n*\s*<p><!--ENTER LINK HERE --></p>\n*\s*<td><center>\s*(.+?)\s*</center></td>\n*\s*<p><!--ENTER NAME HERE --></tr>'
  813. #match=re.compile(s, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
  814. #if (_debugging==True): print match
  815. #if (match==None): return
  816. ##ShowYear=match[1].strip(); ShowTitle=match[0].strip(); ShowTitle=HTMLParser.HTMLParser().unescape(ShowTitle); ShowTitle=ParseDescription(ShowTitle);
  817. ##ShowTitle=ShowTitle.encode('ascii', 'ignore'); ShowTitle=ShowTitle.decode('iso-8859-1');
  818. ##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]
  819. #if (_debugging==True): print match
  820. #(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 )
  821. ### Both -Movies- and -TV Shows- ### Hosters
  822. s ='<tr>\n*\s*<td><center><a.*? href="(http://.+?)".*?>\s*(Version\s*\d+)\s*</a></center></td>\n*\s*<p><!--ENTER LINK HERE --></p>\n*\s*<td><center>\s*(.+?)\s*</center></td>\n*\s*<p><!--ENTER NAME HERE --></tr>'
  823. #match=re.compile(s, re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)
  824. match=re.compile(s).findall(html)
  825. if (len(match) > 0):
  826. count=1
  827. #match=sorted(match, key=lambda item: (item[3],item[2],item[1]))
  828. ItemCount=len(match) # , total_items=ItemCount
  829. #for url, host, quality, age in match:
  830. print match
  831. for url, blah, host in match:
  832. host=host.strip() #; quality=quality.strip();
  833. host2=re.compile('http://([0-9A-Za-z\-\.]+)/').findall(url)[0]
  834. name=str(count)+". "+host #+' - [[B]'+quality+'[/B]] - ([I]'+age+'[/I])'
  835. if urlresolver.HostedMediaFile(host=host2, media_id='xxx'):
  836. print (url, blah, host)
  837. #img=ps('Hosters.icon.url')+host;
  838. img=_param['img']
  839. #My_infoLabels['quality']=quality; My_infoLabels['age']=age; My_infoLabels['host']=host
  840. #pars={'section': section, 'img': _param['img'], 'mode': 'PlayVideo', 'url': url, 'quality': quality, 'age': age, 'infoLabels': My_infoLabels, 'listitem': listitem}
  841. pars={'section': section, 'img': _param['img'], 'mode': 'PlayVideo', 'url': url}
  842. contextMenuItems=[];
  843. #contextMenuItems.append(('Show Information', 'XBMC.Action(Info)'))
  844. #pars2=pars; pars2['mode']='Download'
  845. #pars2['studio']=My_infoLabels['Studio']
  846. #pars2['ShowTitle']=My_infoLabels['ShowTitle']
  847. #pars2['Title']=My_infoLabels['Title']
  848. ##deb('plugin url for download',_addon.build_plugin_url(pars2))
  849. #contextMenuItems.append(('Download', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url(pars2)))
  850. ##contextMenuItems.append(('jDownloader', ps('cMI.jDownloader.addlink.url') % (urllib.quote_plus(url))))
  851. pars['mode']='PlayVideo'
  852. _addon.add_directory(pars, {'title': name}, img=img, is_folder=False, contextmenu_items=contextMenuItems, total_items=ItemCount); count=count+1
  853. set_view('list',addst('links-view')); eod()
  854. else: set_view('list',addst('links-view')); eod(); return
  855. ### ################################################################
  856. def Library_SaveTo_TV(section,url,img,name,year,country,season_number,episode_number,episode_title):
  857. ##def listEpisodes(section, url, img='', season='') #_param['img']
  858. show_name=name
  859. xbmcplugin.setContent( int( sys.argv[1] ), 'episodes' ); WhereAmI('@ the Episodes List for TV Show -- url: %s' % url); html=net.http_GET(url).content
  860. if (html=='') or (html=='none') or (html==None):
  861. if (_debugging==True): print 'Html is empty.'
  862. return
  863. if (img==''):
  864. match=re.search( 'coverImage">.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); img=match.group(1)
  865. 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
  866. if not episodes:
  867. if (_debugging==True): print 'couldn\'t find episodes'
  868. return
  869. 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
  870. else: thetvdb_episodes=thetvdb_com_episodes2(_param['thetvdb_series_id'])
  871. #print 'thetvdb_episodes',thetvdb_episodes
  872. woot=False
  873. for ep_url, episode_name, season_number, episode_number, num_links in episodes:
  874. labs={}; s_no=season_number; e_no=episode_number
  875. if (int(episode_number) > -1) and (int(episode_number) < 10): episode_number='0'+episode_number
  876. labs['thumbnail']=img; labs['fanart']=_param['fanart']
  877. labs['EpisodeTitle']=episode_name #; labs['ShowTitle']=''
  878. labs['title']=season_number+'x'+episode_number+' - '+episode_name+' [[I]'+num_links+' Links [/I]]'
  879. ep_url=_domain_url+ep_url; episode_name=messupText(episode_name,True,True,True,True)
  880. 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=''
  881. if (thetvdb_episodes):
  882. for db_ep_url, db_sxe_no, db_ep_url2, db_ep_name, db_dateYear, db_dateMonth, db_dateDay, db_hasImage in thetvdb_episodes:
  883. db_ep_url=ps('meta.tv.domain')+db_ep_url
  884. db_ep_url2=ps('meta.tv.domain')+db_ep_url2
  885. if (db_sxe_no.strip()==(s_no+' x '+e_no)):
  886. if ('Episode #' in episode_name): episode_name=db_ep_name.strip()
  887. labs['Premeired']=labs['DateAired']=labs['Date']=db_dateYear+'-'+db_dateMonth+'-'+db_dateDay
  888. labs['year']=db_dateYear; labs['month']=db_dateMonth; labs['day']=db_dateDay
  889. (db_thumb,labs['thetvdb_series_id'],labs['thetvdb_episode_id']) = Episode__get_thumb(db_ep_url2.strip(),img)
  890. if (check_ifUrl_isHTML(db_thumb)==True): labs['thumbnail']=db_thumb
  891. 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'))
  892. ep_html=mGetItemPage(db_ep_url2); deb('thetvdb - episode - url',db_ep_url2)
  893. deb('Length of ep_html',str(len(ep_html)))
  894. if (ep_html is not None) or (ep_html is not False) or (ep_html is not '') or (ep_html is not 'none'):
  895. labs['PlotOutline']=labs['plot']=mdGetTV(ep_html,['thetvdb.episode.overview1'])['thetvdb.episode.overview1']
  896. contextMenuItems=[]; labs['season']=season_number; labs['episode']=episode_number
  897. #contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  898. #contextMenuItems.append(('Add - Library','XBMC.RunPlugin(%s?mode=%s&section=%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) )))
  899. labs['title']=messupText(labs['title'],True,True,True,False)
  900. deb('Episode Name',labs['title'])
  901. deb('episode thumbnail',labs['thumbnail'])
  902. #
  903. Library_SaveTo_Episode(ep_url,labs['thumbnail'],show_name,year,country,season_number,episode_number,episode_name)
  904. ### Library_SaveTo_Episode(url,iconimage,name,year,country,season_number,episode_number,episode_title)
  905. #
  906. #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)
  907. set_view('episodes',ps('setview.episodes')); eod()
  908. def Menu_BrowseByCountry(section=_default_section_):
  909. url=''; WhereAmI('@ the Genre Menu')#print 'Browse by genres screen'
  910. ItemCount=len(COUNTRIES) # , total_items=ItemCount
  911. for country in COUNTRIES:
  912. #img='http://www.photius.com/flags/thumbnails/af-t.gif'
  913. gif=name2pathU(country)
  914. if (gif=='Bosnia-Herzegovina'): gif='Bosnia-Hercegovina'
  915. elif (gif=='Democratic-Republic-of-Congo'): gif='Congo-Democratic-Republic-of'
  916. elif (gif=='East-Germany'): gif='Germany'
  917. elif (gif=='West-Germany'): gif='Germany'
  918. img='http://www.countries-ofthe-world.com/flags/flag-of-'+gif+'.gif'
  919. if (' and ' in country): print img
  920. if (section==ps('section.movie')): url=_domain_url+'/movies-from-' +name2path(country)+'.html'
  921. else: url=_domain_url+'/tv/tv-shows-from-'+name2path(country)+'.html'
  922. _addon.add_directory({'section': section,'mode': 'GetTitles','url': url,'country': country,'bycountry': country,'pageno': '1','pagecount': addst('pages')}, {'title': country},img=img,fanart=_artFanart, total_items=ItemCount)
  923. set_view('list',addst('default-view')); eod()
  924. def Menu_BrowseByGenre(section=_default_section_):
  925. url=''; WhereAmI('@ the Genre Menu')#print 'Browse by genres screen'
  926. browsebyImg=checkImgLocal(art('genre','.jpg'))
  927. ItemCount=len(GENRES) # , total_items=ItemCount
  928. for genre in GENRES:
  929. img=''; imgName=genre #; pre='http://icons.iconarchive.com/icons/sirubico/movie-genre/128/'
  930. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
  931. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
  932. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
  933. if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
  934. if (img=='') and (browsebyImg is not ''): img=browsebyImg
  935. if (img==''): img=_artSun
  936. if section == ps('section.movie'): url=_domain_url+'/category/'+(genre.lower().replace(' ','-'))+'/'
  937. #else: url=_domain_url+ps('BrowseByGenre.tv.url1') +(genre.lower().replace(' ','-'))+ps('BrowseByGenre.tv.url2')
  938. _addon.add_directory({'section': section,'mode': 'GetTitles','url': url,'genre': genre,'bygenre': genre,'pageno': '1','pagecount': addst('pages')}, {'title': genre},img=img,fanart=_artFanart, total_items=ItemCount)
  939. #GENREStv=ps('GENREStv')
  940. #ItemCount=len(GENREStv) # , total_items=ItemCount
  941. #for genre in GENREStv:
  942. # img=''; imgName=genre #; pre='http://icons.iconarchive.com/icons/sirubico/movie-genre/128/'
  943. # if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
  944. # if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
  945. # if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
  946. # if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
  947. # if (img=='') and (browsebyImg is not ''): img=browsebyImg
  948. # if (img==''): img=_artSun
  949. # if section == ps('section.tv'): url=_domain_url+'/category/'+(genre.lower().replace(' ','-'))+'/'
  950. # #else: url=_domain_url+ps('BrowseByGenre.tv.url1') +(genre.lower().replace(' ','-'))+ps('BrowseByGenre.tv.url2')
  951. # _addon.add_directory({'section': section,'mode': 'GetTitles','url': url,'genre': genre,'bygenre': genre,'pageno': '1','pagecount': addst('pages')}, {'title': genre},img=img,fanart=_artFanart, total_items=ItemCount)
  952. set_view('list',addst('default-view')); eod()
  953. def Menu_BrowseByYear(section=_default_section_):
  954. url=''; WhereAmI('@ the Year Menu'); EarliestYear=(ps('BrowseByYear.earliestyear') - 1) #1929 #1930 ### This is set to 1 year earlier so that it will display too ###
  955. try: thisyear=int(datetime.date.today().strftime("%Y"))
  956. except: thisyear=ps('BrowseByYear.thisyear')
  957. browsebyImg=checkImgLocal(art('year','.gif'))
  958. ItemCount=len(range(thisyear, EarliestYear, ps('BrowseByYear.range.by'))) # , total_items=ItemCount
  959. for year in range(thisyear, EarliestYear, ps('BrowseByYear.range.by')):
  960. img=''; imgName=str(year)
  961. #if (img==''): img=checkImgUrl('http://www.iconarchive.com/download/i67121/aaron-sinuhe/series-season-folder/season-'+imgName+'.ico')
  962. #if (img==''): img=checkImgUrl('http://icons.iconarchive.com/icons/aaron-sinuhe/series-season-folder/256/season-'+imgName+'-icon.png')
  963. if (img=='') and (browsebyImg is not ''): img=browsebyImg
  964. #
  965. #
  966. if (img==''): img=_artSun
  967. if section == ps('section.movie'): url=_domain_url+ps('BrowseByYear.movie.url1') +str(year)+ps('BrowseByYear.movie.url2')
  968. else: url=_domain_url+ps('BrowseByYear.tv.url1') +str(year)+ps('BrowseByYear.tv.url2')
  969. _addon.add_directory({'section': section,'mode': 'GetTitles', 'url': url,'year': year,'pageno': '1','pagecount': addst('pages')}, {'title': str(year)},img=img,fanart=_artFanart, total_items=ItemCount)
  970. set_view('list',addst('default-view')); eod()
  971. ##def listItems(section=_default_section_, url='', html='', episode=False, startPage='1', numOfPages='1', genre='', year='', stitle=''): # List: Movies or TV Shows
  972. def listItems(section=_default_section_, url='', startPage='1', numOfPages='1', genre='', year='', stitle='', season='', episode='', html='', chck=''): # List: Movies or TV Shows
  973. if (url==''): return
  974. #if (chck=='Latest'): url=url+chr(35)+'latest'
  975. WhereAmI('@ the Item List -- url: %s' % url)
  976. if ('?' in url): ex='?'+url.split('?')[1]
  977. else: ex=''
  978. start=int(startPage); end=(start+int(numOfPages)); html=''; html_last=''; nextpage=startPage; deb('page start',str(start)); deb('page end',str(end))
  979. try: html_=net.http_GET(url).content
  980. except:
  981. try: html_=getURL(url)
  982. except:
  983. try: html_=getURLr(url,_domain_url)
  984. except: html_=''
  985. #print html_
  986. if (html_=='') or (html_=='none') or (html_==None):
  987. deb('Error','Problem with page'); deadNote('Results: '+section,'No results were found.')
  988. return
  989. try: last=int(re.compile('<a href="http://.+?/page/(\d+)/.*"\s*>\s*[last]*\s*&raquo;\s*</a>').findall(html_))[0] #, re.IGNORECASE | re.DOTALL).findall(html_))[0]
  990. except: last=2
  991. deb('number of pages',str(last))
  992. #print min(last,end)
  993. if ('<h1>Nothing was found by your request</h1>' in html_):
  994. deadNote('Results: '+section,'Nothing was found by your request'); eod(); return
  995. pmatch=re.findall(ps('LI.page.find'), html_)
  996. if pmatch: last=pmatch[-1]
  997. #if ('?' in url): urlSplitter='&page='; deb('urlSplitter',urlSplitter) ## Quick fix for urls that already have '?' in it.
  998. #else: urlSplitter='?page='; deb('urlSplitter',urlSplitter)
  999. urlSplitter='/page/'; deb('urlSplitter',urlSplitter)
  1000. for page in range(start,min(last,end)):
  1001. if (int(page)> 1): #if (int(startPage)> 1):
  1002. #if ('&page=' in url): pageUrl=url.replace('&page=','&pagenull=')+'&page='+str(page) ## Quick fix.
  1003. #if ('?page=' in url): pageUrl=url.replace('?page=','?pagenull=')+'&page='+str(page) ## Quick fix.
  1004. if ('/page/' in url): pageUrl=url.split('/page/')[0]+'/page/'+str(page)+'/'+ex ## Quick fix.
  1005. else: pageUrl=url+urlSplitter+str(page)+'/' #ps('LI.page.param')+startPage
  1006. else: pageUrl=url
  1007. deb('item listings for',pageUrl)
  1008. try:
  1009. try: html_last=net.http_GET(pageUrl).content
  1010. except:
  1011. try: html_=getURL(url)
  1012. except: t=''
  1013. if (_shoDebugging==True) and (html_last==''): deadNote('Testing','html_last is empty')
  1014. if (html_last in html): t=''
  1015. else: html=html+'\r\n'+html_last; nextpage=str(int(page)+1)
  1016. ##if (_debugging==True): print html_last
  1017. except: t=''
  1018. #if (ps('LI.nextpage.check') in html_last):
  1019. if ('raquo' in html_last):
  1020. if (_debugging==True): print 'A next-page has been found.'
  1021. #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]
  1022. 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 ##
  1023. if (_debugging==True): print 'A next-page is being added.'
  1024. #print {'mode': 'GetTitles', 'url': url, 'pageno': nextpage, 'pagecount': numOfPages}
  1025. _addon.add_directory({'mode': 'GetTitles', 'section': section, 'url': url, 'pageno': nextpage, 'pagecount': numOfPages}, {'title': ps('LI.nextpage.name')}, img=art('icon-next'))
  1026. print {'start':str(start),'end':str(end),'last':str(last),'nextpage':str(nextpage)}
  1027. ### ### _addon.add_directory({'mode': 'GetTitles', 'url': url, 'startPage': str(end), 'numOfPages': numOfPages}, {'title': 'Next...'})
  1028. ###html=nolines(html)
  1029. html=ParseDescription(html); html=remove_accents(html) #if (_debugging==True): print html
  1030. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1031. if (section==ps('section.tv')) and (season=='') and (episode==''): ## TV Show
  1032. deb('listItems >> ',section); deb('listItems >> chck',chck)
  1033. eod(); return
  1034. #elif (section==ps('section.tv')) and (episode==''): ## Season
  1035. # set_view('seasons',515); _addon.end_of_directory(); return
  1036. #elif (section==ps('section.tv')): ## Episode
  1037. # set_view('episodes',515); _addon.end_of_directory(); return
  1038. elif (section==ps('section.movie')): ## Movie
  1039. deb('listItems >> ',section); deb('listItems >> chck',chck)
  1040. ###set_view('movies',515)
  1041. #####xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE)
  1042. ###xbmc.executebuiltin("Container.SetSortMethod(%s)" % xbmcplugin.SORT_METHOD_LABEL)
  1043. #if (chck==ps('LI.movies.popular.new.check')): html=(html.split(ps('LI.movies.popular.new.split1' ))[1]).split(ps('LI.movies.popular.new.split2' ))[0]
  1044. #elif (chck==ps('LI.movies.popular.hd.check')): html=(html.split(ps('LI.movies.popular.hd.split1' ))[1]).split(ps('LI.movies.popular.hd.split2' ))[0]
  1045. #elif (chck==ps('LI.movies.popular.other.check')): html=(html.split(ps('LI.movies.popular.other.split1'))[1]).split(ps('LI.movies.popular.other.split2'))[0]
  1046. #elif (chck==ps('LI.movies.latest.check')): html=(html.split(ps('LI.movies.latest.split1' ))[1]).split(ps('LI.movies.latest.split2' ))[0]
  1047. ###elif (chck=='Popular'): ## I guess this isnt used for movies atm.
  1048. ##s ='<div\sclass="afis">[\n]\s*[\n]\s*<a\shref="(http://vidics4.com/watch-[0-9A-Za-z\-]+/)"\stitle="Watch\s.+?"><img src="(http://vidics4.com/wp-content/themes/[0-9A-Za-z\-]+/timthumb.php?src=http://vidics4.com/wp-content/uploads/.+?"\swidth="\d+"\sheight="\d+"\salt="Watch\s.+?)"/><div\sclass="\D+"></div>\s*</a>[\n]\s*[\n]\s*</div>[\n]\s*[\n]\s*<div class="film">[\n]\s*'
  1049. ##s+='<p>\s*<span\sclass="\D+">Movie Name:</span>\s*<a\shref="http://vidics4.com/watch-[0-9A-Za-z\-]+/"\stitle="Watch\s.+?">Watch (.+?) \((\d\d\d\d)\) Online Movie</a></p>[\n]\s*'
  1050. ##s+='<p><span\sclass="\D+">Genre:</span>\s*(.+?)</p>[\n]\s*[\n]\s*[\n]\s*[\n]\s*'
  1051. ##s+='<p><span class="\D+">Release Date:</span> (\D+ \d+, \d\d\d\d)</p>[\n]\s*'
  1052. ##s+='<p><span class="\D+">Director:</span>\s(.+?)</p>[\n]\s*'
  1053. ##s+='<p><span class="\D+">Cast:</span>\s(.+?)</p>[\n]\s*[\n]\s*[\n]\s*[\n]\s*[\n]\s*'
  1054. ##s+='<a target="_blank" href="http://www.imdb.com/title/(tt\d+)/">'
  1055. deb('Length of HTML',str(len(html)))
  1056. #print html
  1057. #s ='<div class="afis">\n*\s*\n*\s*\n*\s*\n*\s*<a href="(http://vidics4.com/watch-.+?/)" title=".+?"><img src="(http://vidics4.com/wp-content/themes/.+?)"'
  1058. #s+=' width="\d+" height="\d+" alt=".+?"/><div src="" class="kucukIcon"></div></a>'
  1059. #s+='\n*\s*\n*\s*\n*\s*\n*\s*</div>\n*\s*\n*\s*\n*\s*\n*\s*<div class="film">'
  1060. #s+='\n*\s*\n*\s*<p><span class="kalin">[Movie]*\s*Name:</span>\s*<a\s+href="http://vidics4.com/watch-.+?"\s+title=".+?">\s*(.+?)\s*\((\d\d\d\d)\) Online Movie</a></p>'
  1061. ##s+='\n*\s*\n*\s*<p><span class="kalin">Genre:</span>(.*?)</p>'
  1062. ##s+='\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*<p><span class="kalin">Release Date:</span> (\D+ \d+, \d\d\d\d)</p>'
  1063. ##s+='\n*\s*\n*\s*<p><span class="kalin">Director:</span>(.*?)*</p>'
  1064. ##s+='\n*\s*\n*\s*<p><span class="kalin">Cast:</span>(.*?)*</p>'
  1065. ##s+='\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*\n*\s*<a target="_blank" href="http://www.imdb.com/title/(tt[0-9]+)/">'
  1066. #
  1067. #s ='<a\s*href="(http://[A-Za-z0-9\.\-_]*/[A-Za-z0-9\.\-_]*-\d\d\d\d/)"\s*title="(.+?)\s*\((\d\d\d\d)\)"\s*[/]*>\s*\n*\s*'
  1068. #s+='<img src="(http://[A-Za-z0-9\.\-_/]*\?src=http://[A-Za-z0-9\.\-_/]*/wp-content/uploads/\d\d\d\d/\d\d/[A-Za-z0-9\.\-_/]*\.[jpg|png].+?)"\s*width="\d*"\s*height="\d*"\s*alt=".+?\s*\(\d\d\d\d\)"\s*[/]*>'
  1069. #
  1070. s ='<a\s*href="(http://[A-Za-z0-9\.\-_]*/[A-Za-z0-9\.\-_]*-\d\d\d\d[A-Za-z0-9\.\-_]*/)"\s*title="(.+?)\s*\((\d\d\d\d)\)"\s*[/]*>\s*\n*\s*'
  1071. s+='<img\s*src="(http://.+?)"'
  1072. #
  1073. #return
  1074. iitems=re.compile(s).findall(html)
  1075. #iitems=re.compile(s, re.DOTALL).findall(html)
  1076. #try: iitems=re.compile(s, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  1077. #except: iitems=None
  1078. ##try: iitems=re.compile(ps('LI.movies.match.items' ), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  1079. ##except:
  1080. ## try: iitems=re.compile(ps('LI.movies.match.items2'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  1081. ## except: iitems=None
  1082. ## #iitems=re.compile(ps('LI.movies.match.items3'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
  1083. if (iitems==None):
  1084. deb('Item Results','None Found'); deadNote('Results: '+section,'No results were found.'); eod(); return
  1085. ItemCount=len(iitems) # , total_items=ItemCount
  1086. ##iitems=sorted(iitems, key=lambda item: (item[0],item[3]))
  1087. #for name, item_url, thumbnail, year in iitems:
  1088. debob(iitems)
  1089. #for url,img,title,year,genres,releasedate,directors,cast,imdbID in iitems:
  1090. #for url,img,title,year in iitems:
  1091. for url,title,year,img in iitems:
  1092. contextMenuItems=[]; labs={}; pars={'mode':'GetLinks','section':section,'year':year,'title':title,'img':img,'url':url}
  1093. #name=ParseDescription(HTMLParser.HTMLParser().unescape(name)); name=name.encode('ascii', 'ignore'); name=name.decode('iso-8859-1') #; name = remove_accents(name)
  1094. labs['year']=year
  1095. labs['title']=title
  1096. labs['title']+=' ('+year+')'
  1097. #labs['imdb']=imdbID
  1098. #
  1099. contextMenuItems.append(('Show Information','XBMC.Action(Info)'))
  1100. _addon.add_directory(pars, labs, img=img, fanart=img, contextmenu_items=contextMenuItems, total_items=ItemCount)
  1101. #contextMenuItems=[]; name=ParseDescription(HTMLParser.HTMLParser().unescape(name)); name=name.encode('ascii', 'ignore'); name=name.decode('iso-8859-1') #; name = remove_accents(name)
  1102. #name=_addon.decode(name); name=_addon.unescape(name)
  1103. #try: deb('listItems >> '+section+' >> '+name, item_url)
  1104. #except: print item_url
  1105. ###### Right Click Menu for: MOVIE #####
  1106. #contextMenuItems.append(('Show Information', 'XBMC.Action(Info)'))
  1107. #contextMenuItems.append(('Add - Library','XBMC.RunPlugin(%s?mode=%s&section=%s&title=%s&showtitle=%s&showyear=%s&url=%s&img=%s)' % ( sys.argv[0],'LibrarySaveMovie',section, urllib.quote_plus(name), urllib.quote_plus(name), urllib.quote_plus(year), urllib.quote_plus(_domain_url+item_url), urllib.quote_plus(thumbnail))))
  1108. #if os.path.exists(xbmc.translatePath(ps('special.home.addons'))+ps('cMI.1ch.search.folder')):
  1109. # contextMenuItems.append((ps('cMI.1ch.search.name'), ps('cMI.1ch.search.url') % (ps('cMI.1ch.search.plugin'), ps('cMI.1ch.search.section'), name)))
  1110. #if os.path.exists(xbmc.translatePath(ps('special.home.addons'))+ps('cMI.primewire.search.folder')):
  1111. # contextMenuItems.append((ps('cMI.primewire.search.name'), ps('cMI.primewire.search.url') % (ps('cMI.primewire.search.plugin'), ps('cMI.primewire.search.section'), name)))
  1112. ###### Right Click Menu for: MOVIE ##### /\ #####
  1113. #ihtml=mGetItemPage(_domain_url+item_url)
  1114. ###debob(ihtml)
  1115. ###plot=mGetData(ihtml,['plot'])['plot']
  1116. ###plot=mGetDataTest(ihtml,['plot'])['plot']
  1117. ##plot=mGetDataPlot(ihtml)
  1118. ##if (plot==None) or (plot=='none') or (plot==False): plot=''
  1119. #labs={}; pars={'mode': 'GetLinks', 'section': section, 'url': _domain_url + item_url, 'img': thumbnail, 'title': name, 'year': year }
  1120. #labs['poster']=labs['image']=labs['thumbnail']=thumbnail; labs['year']=year; labs['Country']=mGetDataCountry(ihtml)
  1121. #labs['Rating']=mGetData(ihtml,['imdbrating'])['imdbrating']; labs['Votes']=mGetData(ihtml,['imdbvotes'])['imdbvotes']; labs['RatingAndVotes']=labs['Rating']+' / '+ps('rating.max')+' ('+labs['Votes']+' Votes)'
  1122. #labs['Genre']=mGetDataGenre(ihtml); labs['Director']=mGetDataDirector(ihtml); labs['Cast']=mGetDataCast(ihtml); labs['Keywords']=mGetDataKeywords(ihtml)
  1123. #labs['PlotOutline']=labs['plot']=mGetData(ihtml,['plot'])['plot']; labs['imdbid']=mGetData(ihtml,['imdbid'])['imdbid']
  1124. #drhtml=mGetItemPage(_setting['meta.movie.search']+labs['imdbid']) ## metadata >> movie >> results
  1125. #dbhtml_url=mdGetMovie(drhtml,['result.url'])['result.url']; dbhtml=mGetItemPage(dbhtml_url) ## metadata >> movie >> results >> page
  1126. ##if (labs['plot']==''): labs['plot']=mdGetMovie(dbhtml,['og.plot'])['og.plot']
  1127. #if (labs['image']==ps('domain.thumbnail.default')): ## Default // No - Image. ##
  1128. # labs['poster']=labs['image']=labs['thumbnail']=mdGetMovie(dbhtml,['og.image'])['og.image']
  1129. #labs['fanart']=mdGetMovie(dbhtml,['og.image2'])['og.image2']
  1130. #if (labs['fanart']=='') or (labs['fanart']=='none') or (labs['fanart']==None): labs['fanart']=mdGetMovie(dbhtml,['og.image'])['og.image']
  1131. #if (labs['fanart']=='') or (labs['fanart']=='none') or (labs['fanart']==None): labs['fanart']=_artFanart
  1132. #if (labs['Genre'] is not ''): labs['plot']=labs['plot']+'[CR]Genre: [' +labs['Genre'] +']'
  1133. #if (labs['Country'] is not ''): labs['plot']=labs['plot']+'[CR]Country: ['+labs['Country']+']'
  1134. #if (labs['Director'] is not ''): labs['plot']=labs['plot']+'[CR]Director: ['+labs['Director']+']'
  1135. #if (labs['Cast'] is not ''): labs['plot']=labs['plot']+'[CR]Cast: ['+labs['Cast']+']'
  1136. #if (labs['Rating'] is not '') and (labs['Votes'] is not ''): labs['plot']=labs['plot']+'[CR]Rating: ['+labs['Rating']+' ('+labs['Votes']+' Votes)]'
  1137. #labs['TVShowTitle']=name; labs['title']=cFL(name+' ('+cFL(year,ps('cFL_color2'))+')',ps('cFL_color'))
  1138. #if (labs['Country'] is not ''): labs['title']=labs['title']+cFL(' ['+cFL(labs['Country'],ps('cFL_color3'))+']',ps('cFL_color'))
  1139. #contextMenuItems.append((ps('cMI.favorites.tv.add.name')+' '+addst('fav.movies.1.name'),ps('cMI.favorites.movie.add.url') % (sys.argv[0],ps('cMI.favorites.tv.add.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(labs['thumbnail']),urllib.quote_plus(labs['fanart']),urllib.quote_plus(labs['Country']),urllib.quote_plus(labs['plot']),urllib.quote_plus(labs['Genre']),urllib.quote_plus(_domain_url + item_url), '' )))
  1140. #contextMenuItems.append((ps('cMI.favorites.tv.add.name')+' '+addst('fav.movies.2.name'),ps('cMI.favorites.movie.add.url') % (sys.argv[0],ps('cMI.favorites.tv.add.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(labs['thumbnail']),urllib.quote_plus(labs['fanart']),urllib.quote_plus(labs['Country']),urllib.quote_plus(labs['plot']),urllib.quote_plus(labs['Genre']),urllib.quote_plus(_domain_url + item_url),'2' )))
  1141. #if (labs['fanart'] is not ''): contextMenuItems.append(('Download Wallpaper', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url( { 'mode': 'Download' , 'section': ps('section.wallpaper') , 'studio': name+' ('+year+')' , 'img': labs['thumbnail'] , 'url': labs['fanart'] } ) ))
  1142. ##contextMenuItems.append(('Favorites - Add', 'XBMC.RunPlugin(%s?mode=%s&section=%s&title=%s&year=%s&img=%s&fanart=%s&pars=%s&labs=%s)' % (sys.argv[0],'FavoritesAdd',section,name,year,labs['thumbnail'],labs['fanart'],pars,labs )))
  1143. #### contextMenuItems.append(('Favorites - Add', 'XBMC.RunPlugin(%s?mode=%s&title=%s&year=%s&img=%s&fanart=%s&pars=%s&labs=%s)' % (sys.argv[0],'FavoritesAdd',urllib.quote_plus(name),year,urllib.quote_plus(labs['thumbnail']),urllib.quote_plus(labs['fanart']),pars,labs )))
  1144. #### ps('Favorites - '+cFL('Add','green'))
  1145. #if ('/tv/' not in pars['url']):
  1146. # try: _addon.add_directory(pars, labs, img=labs['thumbnail'], fanart=labs['fanart'], contextmenu_items=contextMenuItems, total_items=ItemCount)
  1147. # except:
  1148. # uname=name; name='[Unknown]'; _addon.add_directory({'mode': 'GetLinks', 'section': section, 'url': _domain_url + item_url, 'img': thumbnail, 'title': name, 'year': year }, {'title': name+' ('+year+')'}, img=thumbnail, contextmenu_items=contextMenuItems, total_items=ItemCount)
  1149. set_view('movies',addst('movies-view')); eod(); return #set_view('movies',ps('setview.movies')); eod(); return
  1150. else: ### Possibly a combination of the two for watch lists and the such. ###
  1151. #
  1152. set_view('videos',addst('default-view')); eod(); return
  1153. eod()
  1154. def Trailers_List(section, url, genre):
  1155. if (url==''): return
  1156. WhereAmI('@ the Item List -- url: %s' % url)
  1157. html=net.http_GET(url).content ### html=getURL(url)
  1158. #try: Trailers=re.compile('<div class="movieListSingleFilm">[\n]\s+<a href="(/watch-.+?-\d+.html)"><img width="\d+"[\n]\s+src="(http://static.solarmovie.so/images/movies/[0-9]+_\d+x\d+.jpg)"[\n]\s+class="cover" alt="" /></a>[\n]\s+<h2>[\n]\s+<a href="/watch-.+?-\d+.html">(.+?)</a>', re.DOTALL).findall(html)
  1159. #try: Trailers=re.compile('<div class="movieListSingleFilm">', re.DOTALL).findall(html)
  1160. #except: Trailers=''
  1161. #print html
  1162. if ('<div class="movieListDetailed">' not in html): eod(); return
  1163. html=html.split('<div class="movieListDetailed">')[1]
  1164. if ('class="js-tab"' in html): html=html.split('class="js-tab"')[0]
  1165. Trailers=html.split('<div class="movieListSingleFilm">')
  1166. #print Trailers
  1167. ItemCount=len(Trailers) # , total_items=ItemCount
  1168. for Trailer in Trailers:
  1169. if ('<img' in Trailer):
  1170. Trailer=Trailer.strip()
  1171. contextMenuItems=[]; labs={}; pars={}; pars['section']=section; pars['genre']=genre; labs['fanart']=pars['fanart']=_artFanart; labs['plot']=''
  1172. try: labs['thumbnail']=pars['thumbnail']=labs['img']=pars['img']=re.compile('><img width="\d+"[\n]\s+src="(http://static.solarmovie.so/images/movies/[0-9]+_150x220.jpg)"[\n]\s+class="cover" alt="" /></a>', re.DOTALL).findall(Trailer)[0].strip()
  1173. except: labs['thumbnail']=pars['thumbnail']=labs['img']=pars['img']=''
  1174. try: pars['title']=re.compile('<h2>[\n]\s+<a href="/watch-.+?-\d+.html">(.+?)</a>', re.DOTALL).findall(Trailer)[0].strip()
  1175. except: pars['title']=''
  1176. try: labs['year']=pars['year']=re.compile('<h2>[\n]\s+<a href="/watch-.+?-(\d+).html">', re.DOTALL).findall(Trailer)[0].strip()
  1177. except: labs['year']=pars['year']=''
  1178. try: labs['peopleWaitForIt']=re.compile('<span class="peopleWaitForIt">[\n]\s+(\d+) people wait for it', re.DOTALL).findall(Trailer)[0].strip()
  1179. except: labs['peopleWaitForIt']=''
  1180. try: labs['Director']=re.compile('<span class="movieListDirector">[\n]\s+by[\n]\s+(.*?)\s+</span>', re.DOTALL).findall(Trailer)[0].strip()
  1181. except: labs['Director']=''
  1182. try: labs['plot']=labs['Description']=labs['PlotOutline']=re.compile('<p>(.+?)</p>', re.DOTALL).findall(Trailer)[0].strip()
  1183. except: labs['plot']=labs['Description']=labs['PlotOutline']=''
  1184. try: pars['url']=re.compile('<h2>[\n]\s+<a href="(/watch-.+?-\d+.html)"', re.DOTALL).findall(Trailer)[0].strip()
  1185. except: pars['url']=''
  1186. if (pars['url'] is not ''): pars['url']=_domain_url+pars['url']
  1187. try: labs['Premiere']=labs['DateReleased']=labs['DateAired']=labs['Aired']=labs['date']=re.compile('<span class="timeToRelease">[\n]\s+in \d+ \D+;[\n]\s+<span>(\D+ \d+, \d\d\d\d)</span>[\n]\s+</span>', re.DOTALL).findall(Trailer)[0].strip()
  1188. except: labs['date']=''
  1189. try: labs['ToBeReleasedIn']=re.compile('<span class="timeToRelease">[\n]\s+in (\d+ \D+);[\n]\s+<span>\D+ \d+, \d\d\d\d</span>[\n]\s+</span>', re.DOTALL).findall(Trailer)[0].strip()
  1190. except: labs['ToBeReleasedIn']=''
  1191. #try: labs['title']=re.compile('', re.DOTALL).findall(Trailer)[0].strip()
  1192. #except: labs['title']=''
  1193. #labs['url']=_domain_url+tUrl
  1194. #labs['title']=tTitle
  1195. labs['Director']=labs['Director'].strip(); labs['peopleWaitForIt']=labs['peopleWaitForIt'].strip()
  1196. if (labs['date'] is not ''):
  1197. labs['plot']+='[CR]Premiere: '+labs['date']
  1198. if (labs['ToBeReleasedIn'] is not ''): labs['plot']+=' (in '+labs['ToBeReleasedIn']+')'
  1199. if (labs['Director'] is not ''): labs['plot']+='[CR]Director: '+labs['Director']
  1200. if (labs['peopleWaitForIt'] is not ''): labs['plot']+='[CR]People waiting for it: '+labs['peopleWaitForIt']
  1201. labs['title']=pars['title']
  1202. if (pars['year'] is not ''): labs['title']+=' ('+cFL(pars['year'],ps('cFL_color2'))+')'
  1203. if (labs['ToBeReleasedIn'] is not ''): labs['title']+=' {'+cFL('in '+labs['ToBeReleasedIn'],ps('cFL_color6'))+'}'
  1204. #
  1205. labs['title']=cFL(labs['title'],ps('cFL_color'))
  1206. contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  1207. deb('Trailer',labs['title']+' | '+labs['img']+' | '+pars['url'])
  1208. pars['mode']='PlayTrailer'
  1209. if (pars['url'] is not ''): _addon.add_directory(pars, labs, img=labs['img'], fanart=labs['fanart'], contextmenu_items=contextMenuItems, is_folder=False, total_items=ItemCount)
  1210. #
  1211. #
  1212. #if (Trailers==''): eod(); return
  1213. #for tUrl, tImg, tTitle in Trailers:
  1214. # contextMenuItems=[]; labs={}; pars={}
  1215. # pars['section']=section; pars['genre']=genre; pars['url']=_domain_url+tUrl; pars['title']=tTitle; pars['thumbnail']=pars['img']=tImg
  1216. # labs['title']=tTitle; labs['thumbnail']=labs['img']=tImg; labs['fanart']=_artFanart
  1217. # contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  1218. # deb('Movie Name',labs['title']); deb('Movie thumbnail',labs['thumbnail'])
  1219. # pars['mode']='PlayTrailer'
  1220. # _addon.add_directory(pars, labs, img=labs['img'], fanart=labs['fanart'], contextmenu_items=contextMenuItems)
  1221. # #
  1222. set_view('movies',addst('movies-view')); eod()
  1223. def UsersList(section, url):
  1224. WhereAmI('@ Users: List -- url: %s' % url)
  1225. html=net.http_GET(url).content
  1226. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1227. deb('html length',str(len(html)))
  1228. matches=re.compile('<a class="userPic nohover">[\n]\s+<img src="(http.+?\.\D+)" /></a>[\n][\n]\s+<dl\sclass="ratingBoxStatus">[\n]\s+<dt>[\n]\s+<a\shref="(/profile/[0-9A-Za-z]+/)">([0-9A-Za-z]+)</a>,[\n]\s+<span\sclass="commentDate">joined:\s(.+?\sago)</span>[\n]\s+</dt>[\n]\s+</dl>[\n]\s+<div class="carmaRatingGroup">[\n]\s+<div class="ratingCell">(.+?)</div>', re.DOTALL).findall(html)
  1229. if (not matches): return
  1230. try: nextpage=re.compile('<li class="next"><a href="(http.+?solarmovie\.so/\D+/.+?page=\d+)"></a></li>', re.DOTALL).findall(html)[0]
  1231. except: nextpage=''
  1232. if (nextpage is not ''): _addon.add_directory({ 'section':section, 'mode': 'listUsers', 'url': nextpage }, {'title': ps('LI.nextpage.name')}, img=art('icon-next'), fanart=_artFanart)
  1233. ItemCount=len(matches) # , total_items=ItemCount
  1234. for img, path, person, joined, rating in matches:
  1235. pars={'section':section, 'mode': 'UsersChooseSection', 'url': _domain_url+path }
  1236. title=cFL(person+' ('+cFL(joined,ps('cFL_color2'))+')'+' ['+cFL(rating,ps('cFL_color3'))+']',ps('cFL_color'))
  1237. labs={'title': title }
  1238. _addon.add_directory(pars, labs, img=img, fanart=_artFanart, total_items=ItemCount)
  1239. set_view('list',addst('default-view')); eod()
  1240. def UsersChooseSection(section, url):
  1241. WhereAmI('@ Users: Choose Area -- url: %s' % url)
  1242. _addon.add_directory({'section':section, 'mode': 'UsersShowProfileAccountInfo', 'url': url+'' }, {'title': 'Account' }, img=_artSun, fanart=_artFanart)
  1243. #_addon.add_directory({'section':section, 'mode': 'UsersShowProfileBlogs', 'url': url+'blogs/' }, {'title': 'Blogs' }, img=_artSun, fanart=_artFanart)
  1244. ##_addon.add_directory({'section':section, 'mode': 'UsersShowFavorites', 'url': url+'favorites/' }, {'title': 'Favorites' }, img=_artSun, fanart=_artFanart) ### Needs Testing
  1245. _addon.add_directory({'section':section, 'mode': 'UsersShowUploads', 'url': url+'favorites/' }, {'title': 'Favorites' }, img=_artSun, fanart=_artFanart) ### Needs Testing
  1246. _addon.add_directory({'section':ps('section.movie'), 'mode': 'GetTitles', 'url': url+'watchlist/' }, {'title': 'Watch List (Movies)' }, img=_artSun, fanart=_artFanart) ### Tested: Works
  1247. _addon.add_directory({'section':ps('section.tv'), 'mode': 'GetTitles', 'url': url+'watchlist/' }, {'title': 'Watch List (TV Shows)' }, img=_artSun, fanart=_artFanart) ### Needs Testing
  1248. _addon.add_directory({'section':section, 'mode': 'UsersShowUploads', 'url': url+'uploads/' }, {'title': 'Uploads' }, img=_artSun, fanart=_artFanart) ### Needs Testing
  1249. set_view('list',addst('default-view')); eod()
  1250. def UsersShowPersonInfo(mode, section, url):
  1251. WhereAmI('@ Users: Show Profile Account Information -- url: %s' % url)
  1252. pars={'mode':mode,'section':section,'url':url}
  1253. html=net.http_GET(url).content
  1254. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1255. deb('html length',str(len(html)))
  1256. try: img=re.compile('<img\ssrc="(http://static\.solarmovie\.so/uploads/users/[0-9A-Za-z]+\.png)"\s/>').findall(html)[0]
  1257. except:
  1258. try: img=re.compile('<a\sclass="userPic\snohover\s+verifUpic">[\n]\s*<img\ssrc="(.+?)"\s/>').findall(html)[0]
  1259. except: img=ps('img.userdefault')
  1260. try: user_UserName=re.compile('<h2 class="noCapitalize">[\n]\s*[\n]\s*([A-Za-z0-9\-\_]+)').findall(html)[0]
  1261. except: user_UserName='[Unknown]'
  1262. if (user_UserName):
  1263. _addon.add_directory(pars, { 'title': cFL(user_UserName,ps('cFL_color'))+'\'s Profile' }, img=img, fanart=_artFanart)
  1264. try: user_Position=re.compile('<span class="position">(\D+)</span>').findall(html)[0]
  1265. except: t=''
  1266. if (user_Position):
  1267. _addon.add_directory(pars, { 'title': 'Position: '+cFL(user_Position,ps('cFL_color2')) }, img=img, fanart=_artFanart)
  1268. try: user_Registered=re.compile('<td><label>Registered:</label></td>[\n]\s+<td>(\D+\s\d+,\s\d\d\d\d,\s\d+:\d+\s\D\D)</td>').findall(html)[0]
  1269. except: t=''
  1270. if (user_Registered):
  1271. _addon.add_directory(pars, { 'title': 'Registered: '+user_Registered }, img=img, fanart=_artFanart)
  1272. try: user_Comments=re.compile('<td><label>Comments:</label></td>[\n]\s+<td>(\d+)</td>').findall(html)[0]
  1273. except: t=''
  1274. if (user_Comments):
  1275. _addon.add_directory(pars, { 'title': 'Comments: '+user_Comments }, img=img, fanart=_artFanart)
  1276. try: user_ProfileViews=re.compile('<td><label>Profile Views:</label></td>[\n]\s+<td>(\d+)</td>').findall(html)[0]
  1277. except: t=''
  1278. if (user_ProfileViews):
  1279. _addon.add_directory(pars, { 'title': 'Profile Views: '+user_ProfileViews }, img=img, fanart=_artFanart)
  1280. try: user_LinksActive=re.compile('<td><label>Links Active:</label></td>[\n]\s+<td>(\d+)</td>').findall(html)[0]
  1281. except: t=''
  1282. if (user_LinksActive):
  1283. _addon.add_directory(pars, { 'title': 'Links Active: '+user_LinksActive }, img=img, fanart=_artFanart)
  1284. try: user_ForumThreads=re.compile('<td><label>Forum Threads:</label></td>[\n]\s+<td>[\n]\s+<a href="/forum/search/login/.+?/">(\d+)</a>[\n]\s+</td>').findall(html)[0]
  1285. except: user_ForumThreads='0'
  1286. if (user_ForumThreads):
  1287. _addon.add_directory(pars, { 'title': 'Forum Threads: '+user_ForumThreads }, img=img, fanart=_artFanart)
  1288. try: user_ForumPosts=re.compile('<td><label>Forum Posts:</label></td>[\n]\s+<td>(\d+)</td>').findall(html)[0]
  1289. except: t=''
  1290. if (user_ForumPosts):
  1291. _addon.add_directory(pars, { 'title': 'Forum Posts: '+user_ForumPosts }, img=img, fanart=_artFanart)
  1292. #matches=re.compile('').findall(html)[0]
  1293. #if (matches):
  1294. # _addon.add_directory(pars, { 'title': ': '++'' }, img=img, fanart=_artFanart)
  1295. #
  1296. set_view('list',addst('default-view')); eod()
  1297. def UsersShowFavorites(section, url):
  1298. WhereAmI('@ Users: Show Favorites -- url: %s' % url)
  1299. html=net.http_GET(url).content
  1300. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1301. deb('html length',str(len(html)))
  1302. #matches=re.compile('<a class="userPic nohover">[\n]\s+<img src="(http.+?\.\D+)" /></a>[\n][\n]\s+<dl\sclass="ratingBoxStatus">[\n]\s+<dt>[\n]\s+<a\shref="(/profile/[0-9A-Za-z]+/)">([0-9A-Za-z]+)</a>,[\n]\s+<span\sclass="commentDate">joined:\s(.+?\sago)</span>[\n]\s+</dt>[\n]\s+</dl>[\n]\s+<div class="carmaRatingGroup">[\n]\s+<div class="ratingCell">(.+?)</div>', re.DOTALL).findall(html)
  1303. if (not matches): return
  1304. #for img, path, person, joined, rating in matches:
  1305. # pars={'section':section, 'mode': 'UsersChooseSection', 'url': _domain_url+path }
  1306. # title=cFL(person+' ('+cFL(joined,ps('cFL_color2'))+')'+' ['+cFL(rating,ps('cFL_color3'))+']',ps('cFL_color'))
  1307. # labs={'title': title }
  1308. # _addon.add_directory(pars, labs, img=img, fanart=_artFanart)
  1309. set_view('videos',addst('default-view')); eod()
  1310. #def UsersShowWatchList(section, url):
  1311. # WhereAmI('@ Users: Show Watch List -- url: %s' % url)
  1312. # html=net.http_GET(url).content
  1313. # html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1314. # deb('html length',str(len(html)))
  1315. # #matches=re.compile('<a class="userPic nohover">[\n]\s+<img src="(http.+?\.\D+)" /></a>[\n][\n]\s+<dl\sclass="ratingBoxStatus">[\n]\s+<dt>[\n]\s+<a\shref="(/profile/[0-9A-Za-z]+/)">([0-9A-Za-z]+)</a>,[\n]\s+<span\sclass="commentDate">joined:\s(.+?\sago)</span>[\n]\s+</dt>[\n]\s+</dl>[\n]\s+<div class="carmaRatingGroup">[\n]\s+<div class="ratingCell">(.+?)</div>', re.DOTALL).findall(html)
  1316. # if (not matches): return
  1317. # #for img, path, person, joined, rating in matches:
  1318. # # pars={'section':section, 'mode': 'UsersChooseSection', 'url': _domain_url+path }
  1319. # # title=cFL(person+' ('+cFL(joined,ps('cFL_color2'))+')'+' ['+cFL(rating,ps('cFL_color3'))+']',ps('cFL_color'))
  1320. # # labs={'title': title }
  1321. # # _addon.add_directory(pars, labs, img=img, fanart=_artFanart)
  1322. # set_view('videos',addst('default-view')); eod()
  1323. def UsersShowUploads(section, url):
  1324. WhereAmI('@ Users: Show Uploads -- url: %s' % url)
  1325. html=net.http_GET(url).content; html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False); deb('html length',str(len(html)))
  1326. s='<a href="(.+?)">\n\s+(.+?) (\(\d\d\d\d\))</a>' #s='<th colspan="\d+" class="commentSummaryName">[\n]\s+<a href="(/.+?)">[\n]\s+(.+?)\s(\(\d\d\d\d\))</a>[\n]\s+</th>'
  1327. matches=re.compile(s).findall(html)
  1328. if (not matches): return;
  1329. #print matches
  1330. ItemCount=len(matches) # , total_items=ItemCount
  1331. #matches=sorted(matches, key=lambda item: item[1],reverse=False)
  1332. #matches=sorted(matches, key=lambda item: item[2],reverse=True)
  1333. for path, name, year in matches:
  1334. if ('/tv/' in path) and ('/season-' in path) and ('/episode-' in path): ### TV Episode
  1335. pars={'section': ps('section.tv' ), 'mode': 'GetLinks', 'url': _domain_url+path, 'title': name, 'year': year }
  1336. showtitle,season,episode,eptitle=re.compile('__(.+?)\ss(\d+)e(\d+)\s(.+?)__', re.DOTALL).findall('__'+name+'__')[0]
  1337. title=' - '+cFL(eptitle,ps('cFL_color4'))
  1338. title=' '+cFL(season+cFL('x',ps('cFL_color4'))+episode,ps('cFL_color5'))+title
  1339. title=cFL(showtitle+' ('+cFL(year,ps('cFL_color2'))+')'+title,ps('cFL_color'))
  1340. labs={'title': title }; deb('Adding TV Episode - Title',title); deb('Adding TV - Url',pars['url'])
  1341. _addon.add_directory(pars, labs, img=_art150, fanart=_artFanart, total_items=ItemCount)
  1342. elif ('/watch-' in path) and ('.html' in path): ### Movie
  1343. pars={'section': ps('section.movie'), 'mode': 'GetLinks', 'url': _domain_url+path, 'title': name, 'year': year }
  1344. title=cFL(name+' ('+cFL(year,ps('cFL_color2'))+')',ps('cFL_color'))
  1345. labs={'title': title }; deb('Adding Movie - Title',title); deb('Adding Movie - Url',pars['url'])
  1346. _addon.add_directory(pars, labs, img=_art150, fanart=_artFanart, total_items=ItemCount)
  1347. set_view('videos',addst('default-view')); eod()
  1348. def listLatestSearches(section, url):
  1349. url='http://www.solarmovie.so/'; WhereAmI('@ List: Latest Searches -- url: %s' % url)
  1350. html=net.http_GET(url).content; html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False); deb('html length',str(len(html)))
  1351. s='<li>[\n]\s+<a href="(/(movie|tv)/search/.+?/)">[\n]\s+(.+?)</a>[\n]\s+</li>' #'<a href="(.+?)">\n\s+(.+?) (\(\d\d\d\d\))</a>'
  1352. matches=re.compile(s).findall(html)
  1353. if (not matches): return;
  1354. #print matches
  1355. ItemCount=len(matches) # , total_items=ItemCount
  1356. #print matches
  1357. for path, zone, name in matches:
  1358. title=iFL(cFL(zone.upper()+': ',ps('cFL_color2')))+cFL(name,ps('cFL_color')); path=_domain_url+path; deb('Adding Item - Title',title); deb('Adding Item - Url',path); labs={'title': title }
  1359. if ('tv' ==zone): ### TV
  1360. pars={'section': ps('section.tv' ), 'mode': 'GetTitles', 'url': path, 'title': name }
  1361. _addon.add_directory(pars, labs, img=_art150, fanart=_artFanart, total_items=ItemCount)
  1362. elif ('movie'==zone): ### Movie
  1363. pars={'section': ps('section.movie'), 'mode': 'GetTitles', 'url': path, 'title': name }
  1364. _addon.add_directory(pars, labs, img=_art150, fanart=_artFanart, total_items=ItemCount)
  1365. set_view('list',addst('default-view')); eod()
  1366. def Site__PrivacyPolicy():
  1367. WhereAmI('@ SolarMovie.so: Privacy Policy -- url: %s' % 'http://www.solarmovie.so/privacy-policy.html');
  1368. HeaderMessage='[COLOR cornflowerblue]Privacy Policy[/COLOR]'
  1369. message ='[B]'+cFL('Privacy Policy',ps('cFL_color'))+'[/B][CR][CR]'
  1370. message+='Please read the following terms and conditions carefully and pay attention to the fact that by '
  1371. message+='entering this site you completely agree to its terms and conditions. SolarMovie site (& plugin) reserves '
  1372. message+='the right to change these terms and conditions without any prior notice. To get the changes '
  1373. message+='check this policy on a regular base.[CR][CR]'
  1374. message+='This Site (nor this plugin) shall have no responsibilities or liabilities for the content, data, opinions, '
  1375. message+='statements and links this site contains.[CR][CR]'
  1376. message+='YOU HEREBY FURTHER AFFIRM AND WARRANT THAT YOU ARE CURRENTLY OVER THE AGE OF EIGHTEEN ([B]18[/B]) '
  1377. message+='YEARS (TWENTYONE ([B]21[/B]) IN PLACES WHERE EIGHTEEN ([B]18[/B]) YEARS IS NOT THE AGE OF MAJORITY) '
  1378. message+='AND ARE CAPABLE OF LAWFULLY ENTERING INTO AND EXECUTING THE TERMS OF THIS AGREEMENT.[CR][CR]'
  1379. message+='SolarMovie uses the right of "Free Speech".[CR][CR]'
  1380. message+='This site works in accordance with copyright law. Persons who reproduce or distribute any works '
  1381. message+='without a copyright owner\'s consent, may be in violation of this law.[CR][CR]'
  1382. message+='We do not make warranties that this site (nor this plugin) will operate error free. If you see an error, please '
  1383. message+='contact the webmaster (or author of the plugin if it has to do with the plugin, however please make sure to check that the site is up and running first.).[CR][CR]'
  1384. message+='By entering this site (and/or this plugin) you agree to hold the owners, employees, advertisers of [B]SolarMovie[/B] (both the site and this plugin)'
  1385. message+='free from any and all liability.[CR][CR]'
  1386. message+='Your membership may not be shared or transferred.[CR][CR]'
  1387. message+='If you have any questions please feel free to contact us (of the site).[CR][CR]'
  1388. #########
  1389. message+='[CR][CR][COLOR grey][I]This has been copied from solarmovie.so on 2013-08-11, with the appropriate text added for this plugin. Please check out the current '
  1390. message+='Privacy Policy for the site @ http://www.solarmovie.so/privacy-policy.html for any changes.[/I][/COLOR][CR][CR][CR][CR]'
  1391. message+=cFL('Thank you for taking the time to read this.',ps('cFL_color3'))
  1392. message=cFL(message,ps('cFL_color5'))
  1393. print message
  1394. TextBox2().load_string(message,HeaderMessage)
  1395. #eod()
  1396. def Site__TermsOfService():
  1397. WhereAmI('@ SolarMovie.so: Terms of Service -- url: %s' % 'http://www.solarmovie.so/terms.html');
  1398. HeaderMessage='[COLOR cornflowerblue]Terms of Service[/COLOR]'
  1399. message ='[B]'+cFL('Terms of Service',ps('cFL_color'))+'[/B][CR][CR]'
  1400. #########
  1401. message+='[B]'+cFL('Using SolarMovie',ps('cFL_color2'))+'[/B][CR][CR]'
  1402. message+='When you enter SolarMovie (site and/or plugin) you automatically agree to all our rules and regulations![CR][CR][CR]'
  1403. #########
  1404. message+='[B]'+cFL('Hosting and Legal Issues',ps('cFL_color2'))+'[/B][CR][CR]'
  1405. message+='SolarMovie is not hosting or uploading any copyrighted content or media of any kind; '
  1406. message+='we only store links to third-party websites that carry their own legal responsibility '
  1407. message+='for their content. If you want to remove content from these websites - please contact '
  1408. message+='these media hosters directly.[CR][CR]'
  1409. message+='SolarMovie is working according to DMCA, so if you need to remove any content from the '
  1410. message+='website, you can contact our copyright issues department. '
  1411. message+='(http://www.solarmovie.so/contacts.html)[CR][CR][CR]'
  1412. #########
  1413. message+='[B]'+cFL('Responsibilities',ps('cFL_color2'))+'[/B][CR][CR]'
  1414. message+='SolarMovie (site & plugin) is not responsible for anything that might happen on third-party websites. '
  1415. message+='We are not responsible for the accuracy, compliance, copyright, legality, decency, or '
  1416. message+='any other aspect of the content of other linked sites. Please, be careful when you '
  1417. message+='install, download or submit any personal or CC information![CR][CR]'
  1418. message+='SolarMovie (site & plugin) holds no responsibility for any legal or copyright issues that may occur due '
  1419. message+='to the use of SolarMovie (site and/or plugin). Please check local copyright laws or the rules of your '
  1420. message+='provider to avoid legal problems.[CR][CR]'
  1421. message+='P.S.[CR]As a website we strongly recommend our users to support the makers of the movies '
  1422. message+='and buy the shows and movies that they like![CR][CR][CR]'
  1423. #########
  1424. message+='[CR][CR][COLOR grey][I]This has been copied from solarmovie.so on 2013-08-11, with the appropriate text added for this plugin. Please check out the current '
  1425. message+='Terms of Service for the site @ http://www.solarmovie.so/terms.html for any changes.[/I][/COLOR][CR][CR][CR][CR]'
  1426. message+=cFL('Thank you for taking the time to read this.',ps('cFL_color3'))
  1427. message=cFL(message,ps('cFL_color5'))
  1428. print message
  1429. TextBox2().load_string(message,HeaderMessage)
  1430. #eod()
  1431. def News_LatestThreads(url,headermessage):
  1432. WhereAmI('@ News: Latest Threads -- url: %s' % url);
  1433. message=''; html=net.http_GET(url).content
  1434. if (html=='') or (html=='none') or (html==None): deb('Html','is empty.' ); return
  1435. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1436. ThreadSection=html
  1437. deb('html length',str(len(html)))
  1438. try: ThreadSection=ThreadSection.split('<h3>Latest Threads</h3>')[1]
  1439. except: t=''
  1440. try: ThreadSection=ThreadSection.split('<div id="footer">')[0]
  1441. except: t=''
  1442. try: ThreadSection=ThreadSection.split('<iframe')[0]
  1443. except: t=''
  1444. ThreadSection=ThreadSection.replace('<div class="commentPreview ">','').strip()
  1445. ThreadSection=ThreadSection.replace('<a href="/tv/','[COLOR black] ').strip()
  1446. ThreadSection=ThreadSection.replace('<a href="/watch-','[COLOR black] ').strip()
  1447. ThreadSection=ThreadSection.replace('/" class="commentPreviewTitle">','[/COLOR][COLOR '+ps('cFL_color')+']').strip()
  1448. ThreadSection=ThreadSection.replace('.html" class="commentPreviewTitle">','[/COLOR][COLOR '+ps('cFL_color')+']').strip()
  1449. ThreadSection=ThreadSection.replace('class="commentPreviewTitle">','[/COLOR][COLOR '+ps('cFL_color')+']').strip()
  1450. ThreadSection=ThreadSection.replace('<span class="commentPreviewInfo"> by','[/COLOR][COLOR pink] by ').strip()
  1451. ThreadSection=ThreadSection.replace('<a href="/profile/','[/COLOR][COLOR black] ').strip()
  1452. ThreadSection=ThreadSection.replace('/">','[/COLOR][COLOR '+ps('cFL_color2')+'] By ').strip()
  1453. ThreadSection=ThreadSection.replace('/"','[/COLOR][COLOR '+ps('cFL_color2')+']').strip()
  1454. ThreadSection=ThreadSection.replace('</a>,','[/COLOR], [COLOR '+ps('cFL_color3')+']').strip()
  1455. ThreadSection=ThreadSection.replace('</span>','[/COLOR]').strip()
  1456. ThreadSection=ThreadSection.replace('<span class="commentPreviewBody">','[COLOR '+ps('cFL_color6')+']').strip()
  1457. ThreadSection=ThreadSection.replace('</div>','').strip()
  1458. ThreadSection=ThreadSection.replace('<div class="commentPreview oddComment">','').strip()
  1459. ThreadSection=ThreadSection.replace('</a>','[COLOR black]').strip()
  1460. ThreadSection=ThreadSection.replace('<span class="commentPrewviewInfo">>','[/COLOR]').strip()
  1461. ThreadSection=ThreadSection.replace('\n\n','\n').strip()
  1462. ThreadSection=ThreadSection.replace('\n','').strip()
  1463. ThreadSection=ThreadSection.replace('\r','').strip()
  1464. ThreadSection=ThreadSection.replace(' ',' ').strip()
  1465. ThreadSection=ThreadSection.replace(' ',' ').strip()
  1466. ThreadSection=ThreadSection.replace(' ',' ').strip()
  1467. ThreadSection=ThreadSection.replace(' ',' ').strip()
  1468. ThreadSection=ThreadSection.replace(' ',' ').strip()
  1469. matches=re.compile('(\[COLOR\sblack\].+?\[/COLOR\])', re.DOTALL).findall(ThreadSection)
  1470. for match in matches:
  1471. ThreadSection=ThreadSection.replace(match,'').strip()
  1472. ThreadSection=ThreadSection.replace(') ',') ').strip()
  1473. ThreadSection=ThreadSection.replace(') [/COLOR][CR][COLOR '+ps('cFL_color')+']',') [/COLOR][COLOR '+ps('cFL_color')+']').strip()
  1474. ThreadSection=ThreadSection.replace('[/COLOR][COLOR '+ps('cFL_color')+']','[/COLOR][CR][CR][COLOR '+ps('cFL_color')+']').strip()
  1475. ThreadSection=ThreadSection.replace('[/COLOR] [COLOR '+ps('cFL_color')+']','[/COLOR][CR][CR][COLOR '+ps('cFL_color')+']').strip()
  1476. ThreadSection=ThreadSection.replace('[/COLOR] [COLOR '+ps('cFL_color')+']','[/COLOR][CR][CR][COLOR '+ps('cFL_color')+']').strip()
  1477. ThreadSection=ThreadSection.replace('[/COLOR] [COLOR '+ps('cFL_color')+']','[/COLOR][CR][CR][COLOR '+ps('cFL_color')+']').strip()
  1478. ThreadSection=ThreadSection.replace(' [COLOR '+ps('cFL_color6')+']',' [CR][COLOR '+ps('cFL_color6')+']').strip()
  1479. ThreadSection=ThreadSection.replace('[COLOR '+ps('cFL_color')+'] ','[COLOR '+ps('cFL_color')+']').strip()
  1480. #ThreadSection=ThreadSection.replace(' [COLOR '+ps('cFL_color')+']',' [CR][CR][COLOR '+ps('cFL_color')+']').strip()
  1481. #ThreadSection=ThreadSection.replace('','').strip()
  1482. #ThreadSection=ThreadSection.replace('','').strip()
  1483. #ThreadSection=ThreadSection.replace('','').strip()
  1484. _addon.resolve_url(url)
  1485. TextBox2().load_string(ThreadSection,headermessage)
  1486. #_addon.resolve_url(url)
  1487. ######
  1488. def listEpisodes(section, url, img='', season=''): #_param['img']
  1489. xbmcplugin.setContent( int( sys.argv[1] ), 'episodes' ); WhereAmI('@ the Episodes List for TV Show -- url: %s' % url); html=net.http_GET(url).content
  1490. metadata_tv_episodes=tfalse(addst("metadata_tv_episodes")); metadata_tv_ep_plot=tfalse(addst("metadata_tv_ep_plot"))
  1491. if (html=='') or (html=='none') or (html==None): deb('Html','is empty.' ); return
  1492. html=messupText(html,_html=True,_ende=True,_a=False,Slashes=False)
  1493. if (img==''): match=re.search( 'coverImage">.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); img=match.group(1)
  1494. ###if (season=='') or (season.lower()=='all'):
  1495. ###try: 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.DOTALL).findall(html)
  1496. ##if (int(season) > 2):
  1497. ## try: episodes=re.compile('<span class="epname">[\n].+?<a href="(.+?)"[\n]\s+title=".+?">(.+?)</a>[\n]\s+<a href="/.+?/season-(['+season+']*)/episode-(\d+)/" class=".+?">[\n]\s+(\d+) links</a>').findall(html)
  1498. ## except: episodes=''
  1499. ##else:
  1500. #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.DOTALL).findall(html)
  1501. try: 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+) link', re.DOTALL).findall(html)
  1502. except: episodes=''
  1503. ###else:
  1504. ### try: 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.DOTALL).findall(html)
  1505. ### #try: episodes=re.compile('<span class="epname">[\n].+?<a href="(.+?)"[\n]\s+title=".+?">(.+?)</a>[\n]\s+<a href="/.+?/season-(['+season+'])/episode-(\d+)/" class=".+?">[\n]\s+(\d+) links</a>', re.DOTALL).findall(html)
  1506. ### except: episodes=''
  1507. if (not episodes) or (episodes==None) or (episodes==False) or (episodes==''): deb('Episodes','couldn\'t find episodes'); eod(); return
  1508. if (metadata_tv_episodes==False) or (_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
  1509. else:
  1510. if (season=='0') or (season=='') or (season.lower()=='all'): thetvdb_episodes=thetvdb_com_episodes2(_param['thetvdb_series_id'])
  1511. else: thetvdb_episodes=thetvdb_com_episodes3(_param['thetvdb_series_id'],season)
  1512. woot=False
  1513. #print episodes
  1514. ItemCount=len(episodes) # , total_items=ItemCount
  1515. ShowZeroLinks=tfalse(addst("tv-zerolinks-show"))
  1516. for ep_url, episode_name, season_number, episode_number, num_links in episodes:
  1517. if (season==''): t=''
  1518. elif (season==season_number) or (season.lower()=='all') or (season==''):
  1519. labs={}; s_no=season_number; e_no=episode_number
  1520. if (int(episode_number) > -1) and (int(episode_number) < 10): episode_number='0'+episode_number
  1521. labs['thumbnail']=img; labs['fanart']=_param['fanart']
  1522. labs['EpisodeTitle']=episode_name #; labs['ShowTitle']=''
  1523. episode_name=messupText(episode_name,_html=True,_ende=True,_a=False,Slashes=False)
  1524. #labs['title']=season_number+'x'+episode_number+' - '+episode_name+' [[I]'+num_links+' Links [/I]]'
  1525. 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'))
  1526. ep_url=_domain_url+ep_url; episode_name=messupText(episode_name,True,True,True,True)
  1527. if (metadata_tv_episodes==False): t=''
  1528. #elif (season=='0') (s_no=='0') or (season=='') or (season.lower()=='all'): t=''
  1529. elif (thetvdb_episodes) and (thetvdb_episodes is not None) and (thetvdb_episodes is not '') and (thetvdb_episodes is not 'none'):
  1530. #for thetvdb_episode in thetvdb_episodes:
  1531. for db_ep_url, db_sxe_no, db_ep_url2, db_ep_name, db_dateYear, db_dateMonth, db_dateDay, db_hasImage in thetvdb_episodes:
  1532. if (db_sxe_no.strip()==(s_no+' x '+e_no)):
  1533. v=(db_ep_url, db_sxe_no, db_ep_url2, db_ep_name, db_dateYear, db_dateMonth, db_dateDay, db_hasImage)
  1534. db_ep_url=ps('meta.tv.domain')+db_ep_url; db_ep_url2=ps('meta.tv.domain')+db_ep_url2
  1535. if ('Episode #' in episode_name): episode_name=db_ep_name.strip()
  1536. if ('TBA'==episode_name): episode_name='(To Be Announced)'
  1537. labs['Premeired']=labs['DateAired']=labs['Date']=db_dateYear+'-'+db_dateMonth+'-'+db_dateDay; labs['year']=db_dateYear; labs['month']=db_dateMonth; labs['day']=db_dateDay
  1538. deb('db_hasImage',db_hasImage)
  1539. if ('img' in db_hasImage): (labs['thumbnail'],labs['thetvdb_series_id'],labs['thetvdb_episode_id']) = Episode__get_thumb(db_ep_url2,img)
  1540. else: (labs['thumbnail'],labs['thetvdb_series_id'],labs['thetvdb_episode_id']) = (img,'','')
  1541. #(db_thumb,labs['thetvdb_series_id'],labs['thetvdb_episode_id']) = Episode__get_thumb(db_ep_url2.strip(),img)
  1542. #if (check_ifUrl_isHTML(db_thumb)==True): labs['thumbnail']=db_thumb
  1543. 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'))
  1544. ####################
  1545. if (metadata_tv_ep_plot==False): labs['PlotOutline']=labs['plot']=''
  1546. else:
  1547. try: ep_html=mGetItemPage(db_ep_url2)
  1548. except: ep_html=''
  1549. deb('thetvdb - episode - url',db_ep_url2); deb('Length of ep_html',str(len(ep_html)))
  1550. if (ep_html is not None) or (ep_html is not False) or (ep_html is not '') or (ep_html is not 'none'):
  1551. labs['PlotOutline']=labs['plot']=mdGetTV(ep_html,['thetvdb.episode.overview1'])['thetvdb.episode.overview1']
  1552. ####################
  1553. thetvdb_episodes.remove(v)
  1554. #
  1555. #
  1556. #
  1557. contextMenuItems=[]; labs['season']=season_number; labs['episode']=episode_number
  1558. contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  1559. contextMenuItems.append(('Add - Library','XBMC.RunPlugin(%s?mode=%s&section=%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) )))
  1560. deb('Episode Name',labs['title']); deb('episode thumbnail',labs['thumbnail'])
  1561. if (season==season_number) or (season==''):
  1562. if (ShowZeroLinks==True) or (int(num_links) > 0):
  1563. _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, total_items=ItemCount)
  1564. #
  1565. set_view('episodes',addst('episode-view')); eod() #set_view('episodes',ps('setview.episodes')); eod()
  1566. def listSeasons(section, url, img=''): #_param['img']
  1567. xbmcplugin.setContent(int(sys.argv[1]),'seasons'); WhereAmI('@ the Seasons List for TV Show -- url: %s' % url); html=net.http_GET(url).content
  1568. if (html=='') or (html=='none') or (html==None):
  1569. if (_debugging==True): print 'Html is empty.'
  1570. return
  1571. if (img==''):
  1572. match=re.search(ps('listSeasons.match.img'), html, re.IGNORECASE | re.MULTILINE | re.DOTALL); img=match.group(1)
  1573. ##if (_debugging==True): print ParseDescription(html)
  1574. seasons=re.compile(ps('listSeasons.match.seasons')).findall(html)
  1575. if (_debugging==True): print seasons
  1576. if not seasons:
  1577. if (_debugging==True): print 'couldn\'t find seasons'
  1578. return
  1579. ItemCount=len(seasons) # , total_items=ItemCount
  1580. for season_name in seasons:
  1581. Aimg=''; imgName=season_name
  1582. if (Aimg==''): Aimg=checkImgUrl('http://icons.iconarchive.com/icons/aaron-sinuhe/series-season-folder/256/season-'+imgName+'-icon.png')
  1583. if (Aimg==''): Aimg=img
  1584. season_name=messupText(season_name,False,False,True,True)
  1585. _addon.add_directory({'mode': 'GetEpisodes', 'url': url+'season-'+season_name+'/', 'title': _param['title'], 'showtitle': _param['showtitle'], 'year': _param['year'], 'section': section, 'img': img, 'season': season_name, 'thetvdb_series_id': _param['thetvdb_series_id'], 'fanart': _param['fanart']}, {'title': ps('listSeasons.prefix.seasons')+cFL(season_name,ps('cFL_color5'))}, img=Aimg, fanart=_param['fanart'], total_items=ItemCount)
  1586. set_view('seasons',addst('season-view')); eod() #set_view('seasons',ps('setview.seasons')); eod()
  1587. def Menu_LoadCategories(section=_default_section_): #Categories
  1588. WhereAmI('@ the Category Menu')
  1589. ### ###################################################################################################################################################################################################################################
  1590. ### ###################################################################################################################################################################################################################################
  1591. #if ( section == ps('section.trailers')): ## Trailers #################################################################################################################################################################################
  1592. # _addon.add_directory({'section': section, 'mode': 'TrailersGenres', 'url': 'http://www.solarmovie.so/coming-soon/date/' }, {'title': cFL('G',ps('cFL_color'))+'enre By Release Date'},fanart=_artFanart,img=art('genre','.jpg'))
  1593. # _addon.add_directory({'section': section, 'mode': 'TrailersGenres', 'url': 'http://www.solarmovie.so/coming-soon/popularity/' }, {'title': cFL('G',ps('cFL_color'))+'enre By Popularity'}, fanart=_artFanart,img=art('genre','.jpg'))
  1594. ###elif ( section == ps('sectoin.trailers.popular')): ###### Trailers Popular #############################################################################################################################################################
  1595. ###elif ( section == ps('sectoin.trailers.releasedate')): ## Trailers Release Date ########################################################################################################################################################
  1596. #elif ( section == ps('section.users')): ## Users #######################################################################################################################################################################################
  1597. # _addon.add_directory({'section': section, 'mode': 'listUsers', 'url': 'http://www.solarmovie.so/ratings/moderator/' }, {'title': cFL('M',ps('cFL_color'))+'oderators'}, fanart=_artFanart,img=ps('img.usersection'))
  1598. # _addon.add_directory({'section': section, 'mode': 'listUsers', 'url': 'http://www.solarmovie.so/ratings/linker/' }, {'title': cFL('L',ps('cFL_color'))+'inkers'}, fanart=_artFanart,img=ps('img.usersection'))
  1599. # _addon.add_directory({'section': section, 'mode': 'listUsers', 'url': 'http://www.solarmovie.so/ratings/linker/' }, {'title': cFL('U',ps('cFL_color'))+'ploaders'}, fanart=_artFanart,img=ps('img.usersection'))
  1600. # _addon.add_directory({'section': section, 'mode': 'listUsers', 'url': 'http://www.solarmovie.so/ratings/linker/' }, {'title': cFL('U',ps('cFL_color'))+'sers'}, fanart=_artFanart,img=ps('img.usersection'))
  1601. #elif ( section == ps('section.tv')): ######## TV Shows #################################################################################################################################################################################
  1602. # _addon.add_directory({'section': section, 'mode': 'Search', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('S',ps('cFL_color'))+'earch'}, fanart=_artFanart,img=art('icon-search'))
  1603. # _addon.add_directory({'section': section, 'mode': 'AdvancedSearch', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('A',ps('cFL_color'))+'dvanced Search'}, fanart=_artFanart,img=art('icon-search'))
  1604. # _addon.add_directory({'section': section, 'mode': 'GetTitlesLatestWatched', 'url': _domain_url+'/latest-watched-movies.html', 'pageno': '1','pagecount': '1'}, {'title': cFL('L',ps('cFL_color'))+'atest Watched'}, img=_art150,fanart=_artFanart)
  1605. # _addon.add_directory({'section': section, 'mode': 'GetTitlesLatest', 'url': _domain_url+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('L',ps('cFL_color'))+'atest Added'}, img=_art150,fanart=_artFanart)
  1606. # _addon.add_directory({'section': section, 'mode': 'GetTitlesPopular', 'url': _domain_url+ps('domain.url.tv')+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('P',ps('cFL_color'))+'opular (ALL TIME)'}, img=_art150,fanart=_artFanart)
  1607. # _addon.add_directory({'section': section, 'mode': 'GetTitlesNewPopular', 'url': _domain_url+ps('domain.url.tv')+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('P',ps('cFL_color'))+'opular (NEW)'}, img=_art150,fanart=_artFanart)
  1608. # _addon.add_directory({'section': section, 'mode': 'BrowseCountry'}, {'title': cFL('C',ps('cFL_color'))+'ountry'}, fanart=_artFanart,img=art('countries','.jpg'))
  1609. # _addon.add_directory({'section': section, 'mode': 'BrowseGenre'}, {'title': cFL('G',ps('cFL_color'))+'enre'}, fanart=_artFanart,img=art('genre','.jpg'))
  1610. # _addon.add_directory({'section': section, 'mode': 'BrowseYear'}, {'title': cFL('Y',ps('cFL_color'))+'ear'}, fanart=_artFanart,img=art('year','.gif'))
  1611. # _addon.add_directory( {'section': section, 'mode': 'FavoritesList'}, {'title': cFL('F',ps('cFL_color'))+'avorites '+addst('fav.tv.1.name')},fanart=_artFanart,img=_art404)
  1612. # _addon.add_directory( {'section': section, 'mode': 'FavoritesList', 'subfav': '2'}, {'title': cFL('F',ps('cFL_color'))+'avorites '+addst('fav.tv.2.name')},fanart=_artFanart,img=_art404)
  1613. # _addon.add_directory( {'section': section, 'mode': 'FavoritesList', 'subfav': '3'}, {'title': cFL('F',ps('cFL_color'))+'avorites '+addst('fav.tv.3.name')},fanart=_artFanart,img=_art404)
  1614. # if (_setting['label-empty-favorites']==True):
  1615. # _addon.add_directory({'section': section, 'mode': 'FavoritesEmpty', 'subfav': ''}, {'title': cFL('E',ps('cFL_color'))+'mpty Favorites '+addst('fav.tv.1.name')},img=art('trash','.gif'),fanart=_artFanart,is_folder=False)
  1616. # _addon.add_directory({'section': section, 'mode': 'FavoritesEmpty', 'subfav': '2'}, {'title': cFL('E',ps('cFL_color'))+'mpty Favorites '+addst('fav.tv.2.name')},img=art('trash','.gif'),fanart=_artFanart,is_folder=False)
  1617. # _addon.add_directory({'section': section, 'mode': 'FavoritesEmpty', 'subfav': '3'}, {'title': cFL('E',ps('cFL_color'))+'mpty Favorites '+addst('fav.tv.3.name')},img=art('trash','.gif'),fanart=_artFanart,is_folder=False)
  1618. # _addon.add_directory( {'section': section, 'mode': ps('cMI.airdates.find.mode'), 'title': ''}, {'title': cFL('F',ps('cFL_color'))+'ind Air-Dates'},fanart=_artFanart,img=_art404)
  1619. #el
  1620. if ( section == ps('section.movie')): ##### Movies ###################################################################################################################################################################################
  1621. #
  1622. # Cinema Movies
  1623. # Featured
  1624. # HD Movies
  1625. # Latest Added
  1626. # http://viooz.co/rss.xml
  1627. # http://viooz.co/year/
  1628. # http://viooz.co/host/
  1629. # http://viooz.co/language/
  1630. # http://viooz.co/country/
  1631. # http://viooz.co/hd/
  1632. # Featured http://viooz.co/top/
  1633. # http://viooz.co/cenima/
  1634. # http://viooz.co/genre/
  1635. # http://viooz.co/movies/
  1636. # http://viooz.co/title/0-9
  1637. # http://viooz.co/title/A
  1638. # Search (Title|Actor|Director)
  1639. #
  1640. _addon.add_directory({'section': section, 'mode': 'Search', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('S',ps('cFL_color'))+'earch'}, fanart=_artFanart,img=art('icon-search'))
  1641. _addon.add_directory({'section': section, 'mode': 'AdvancedSearch', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('A',ps('cFL_color'))+'dvanced Search'}, fanart=_artFanart,img=art('icon-search'))
  1642. _addon.add_directory({'section': section, 'mode': 'GetTitles', 'url': _domain_url+'/latest-watched-movies.html', 'pageno': '1','pagecount': '1'}, {'title': cFL('L',ps('cFL_color'))+'atest Watched'}, img=_art150,fanart=_artFanart)
  1643. _addon.add_directory({'section': section, 'mode': 'GetTitlesLatest', 'url': _domain_url+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('L',ps('cFL_color'))+'atest Added'}, img=_art150,fanart=_artFanart)
  1644. _addon.add_directory({'section': section, 'mode': 'GetTitlesNewPopular', 'url': _domain_url+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('P',ps('cFL_color'))+'opular (NEW)'}, img=_art150,fanart=_artFanart)
  1645. _addon.add_directory({'section': section, 'mode': 'GetTitlesHDPopular', 'url': _domain_url+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('P',ps('cFL_color'))+'opular (HD)'}, img=_art150,fanart=_artFanart)
  1646. _addon.add_directory({'section': section, 'mode': 'GetTitlesOtherPopular', 'url': _domain_url+'/', 'pageno': '1','pagecount': '1'}, {'title': cFL('P',ps('cFL_color'))+'opular (OTHER)'}, img=_art150,fanart=_artFanart)
  1647. _addon.add_directory({'section': section, 'mode': 'BrowseCountry'}, {'title': cFL('C',ps('cFL_color'))+'ountry'}, fanart=_artFanart,img=art('countries','.jpg'))
  1648. _addon.add_directory({'section': section, 'mode': 'BrowseGenre'}, {'title': cFL('G',ps('cFL_color'))+'enre'}, fanart=_artFanart,img=art('genre','.jpg'))
  1649. _addon.add_directory({'section': section, 'mode': 'BrowseYear'}, {'title': cFL('Y',ps('cFL_color'))+'ear'}, fanart=_artFanart,img=art('year','.gif'))
  1650. ###_addon.add_directory( {'section': section, 'mode': 'ComingSoon'}, {'title': cFL('C',ps('cFL_color'))+'oming Soon'},fanart=_artFanart,img='http://www.mirrorservice.org/sites/addons.superrepo.org/Frodo/.metadata/plugin.video.trailer.addict.png')
  1651. _addon.add_directory( {'section': section, 'mode': 'FavoritesList'}, {'title': cFL('F',ps('cFL_color'))+'avorites '+addst('fav.movies.1.name')},fanart=_artFanart,img=_art404)
  1652. _addon.add_directory( {'section': section, 'mode': 'FavoritesList', 'subfav': '2'}, {'title': cFL('F',ps('cFL_color'))+'avorites '+addst('fav.movies.2.name')},fanart=_artFanart,img=_art404)
  1653. if (_setting['label-empty-favorites']==True):
  1654. _addon.add_directory({'section': section, 'mode': 'FavoritesEmpty', 'subfav': ''}, {'title': cFL('E',ps('cFL_color'))+'mpty Favorites '+addst('fav.movies.1.name')},fanart=_artFanart,img=art('trash','.gif'),is_folder=False)
  1655. _addon.add_directory({'section': section, 'mode': 'FavoritesEmpty', 'subfav': '2'}, {'title': cFL('E',ps('cFL_color'))+'mpty Favorites '+addst('fav.movies.2.name')},fanart=_artFanart,img=art('trash','.gif'),is_folder=False)
  1656. ### ###################################################################################################################################################################################################################################
  1657. ### ###################################################################################################################################################################################################################################
  1658. ###
  1659. ###_addon.add_directory({'section': section, 'mode': 'BrowseAtoZ'}, {'title': 'A-Z'})
  1660. #_addon.add_directory({'section': section, 'mode': 'GetSearchQuery'}, {'title': 'Search'})
  1661. ###_addon.add_directory({'section': section, 'mode': 'GetTitles'}, {'title': 'Favorites'})
  1662. set_view('list',addst('default-view')); eod()
  1663. ### http://www.solarmovie.so/latest-movies.html
  1664. ###
  1665. ###
  1666. def Menu_MainMenu(): #The Main Menu
  1667. WhereAmI('@ the Main Menu')
  1668. _addon.add_directory({'mode': 'BrowseGenre', 'section': ps('section.movie')}, {'title': cFL('C',ps('cFL_color'))+'ategories'} ,img=art('movies') ,fanart=_artFanart)
  1669. ##_addon.add_directory({'mode': 'LoadCategories', 'section': ps('section.movie')}, {'title': cFL('M',ps('cFL_color'))+'ovies'} ,img=art('movies') ,fanart=_artFanart)
  1670. ##_addon.add_directory({'mode': 'LoadCategories', 'section': ps('section.tv')}, {'title': cFL('T',ps('cFL_color'))+'V Shows'},img=art('television') ,fanart=_artFanart)
  1671. ##_addon.add_directory({'mode': 'LoadCategories', 'section': ps('section.trailers')}, {'title': cFL('C',ps('cFL_color'))+'oming Soon'},img=ps('img.comingsoon'),fanart=_artFanart)
  1672. ##_addon.add_directory({'mode': 'LoadCategories', 'section': ps('section.users')}, {'title': cFL('U',ps('cFL_color'))+'sers'} ,img=ps('img.usersection'),fanart=_artFanart)
  1673. ##_addon.add_directory({'mode': 'GetLatestSearches', 'section': 'Both'}, {'title': cFL('L',ps('cFL_color'))+'atest Searches'} ,img=art('icon-search') ,fanart=_artFanart)
  1674. #_addon.add_directory({'section': ps('section.movie'), 'mode': 'Search', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('S',ps('cFL_color'))+'earch'}, fanart=_artFanart,img=art('icon-search'))
  1675. #_addon.add_directory({'section': ps('section.movie'), 'mode': 'AdvancedSearch', 'pageno': '1', 'pagecount': addst('pages')}, {'title': cFL('A',ps('cFL_color'))+'dvanced Search'}, fanart=_artFanart,img=art('icon-search'))
  1676. _addon.add_directory({'mode': 'ResolverSettings'}, {'title': cFL('U',ps('cFL_color'))+'rl-Resolver Settings'},is_folder=False ,img=art('turtle','.jpg') ,fanart=_artFanart)
  1677. _addon.add_directory({'mode': 'Settings'}, {'title': cFL('P',ps('cFL_color'))+'lugin Settings'} ,is_folder=False ,img='http://vidics4.com/wp-content/themes/stargate/logo/logo.png' ,fanart=_artFanart)
  1678. ##_addon.add_directory({'mode': 'DownloadStop'}, {'title': cFL('S',ps('cFL_color'))+'top Current Download'},is_folder=False ,img=_artDead ,fanart=_artFanart)
  1679. ##_addon.add_directory({'mode': 'TextBoxFile', 'title': "[COLOR cornflowerblue]Local Change Log:[/COLOR] %s" % (__plugin__), 'url': ps('changelog.local')}, {'title': cFL('L',ps('cFL_color'))+'ocal Change Log'}, img=art('thechangelog','.jpg'), is_folder=False ,fanart=_artFanart)
  1680. ##_addon.add_directory({'mode': 'TextBoxUrl', 'title': "[COLOR cornflowerblue]Latest Change Log:[/COLOR] %s" % (__plugin__), 'url': ps('changelog.url')}, {'title': cFL('L',ps('cFL_color'))+'atest Online Change Log'}, img=art('thechangelog','.jpg'), is_folder=False ,fanart=_artFanart)
  1681. ##_addon.add_directory({'mode': 'TextBoxUrl', 'title': "[COLOR cornflowerblue]Latest News:[/COLOR] %s" % (__plugin__), 'url': ps('news.url')}, {'title': cFL('L',ps('cFL_color'))+'atest Online News'}, img=_art404 , is_folder=False ,fanart=_artFanart)
  1682. ##_addon.add_directory({'mode': 'LatestThreads','title': "[COLOR cornflowerblue]Latest Threads[/COLOR]", 'url': ps('LatestThreads.url')}, {'title': cFL('L',ps('cFL_color'))+'atest Threads'}, img=_art404 , is_folder=False ,fanart=_artFanart)
  1683. ##_addon.add_directory({'mode': 'PrivacyPolicy','title': "", 'url': ''}, {'title': cFL('P',ps('cFL_color'))+'rivacy Policy'}, img=_art404 , is_folder=False ,fanart=_artFanart)
  1684. ##_addon.add_directory({'mode': 'TermsOfService','title': "", 'url': ''}, {'title': cFL('T',ps('cFL_color'))+'erms of Service'}, img=_art404 , is_folder=False ,fanart=_artFanart)
  1685. ### ############
  1686. set_view('list',addst('default-view')); eod()
  1687. ### ############
  1688. ### _addon.show_countdown(9000,'Testing','Working...') ### Time seems to be in seconds.
  1689. ##### /\ ##### Menus #####
  1690. ### ############################################################################################################
  1691. ### ############################################################################################################
  1692. ### ############################################################################################################
  1693. ##### Favorites #####
  1694. def fav__empty(section,subfav=''):
  1695. WhereAmI('@ Favorites - Empty - %s%s' % (section,subfav)); favs=[]; cache.set('favs_'+section+subfav+'__', str(favs)); sunNote(bFL('Favorites'),bFL('Your Favorites Have Been Wiped Clean. Bye Bye.'))
  1696. def fav__remove(section,name,year,subfav=''):
  1697. WhereAmI('@ Favorites - Remove - %s%s' % (section,subfav)); deb('fav__remove() '+section,name+' ('+year+')'); saved_favs=cache.get('favs_'+section+subfav+'__'); tf=False
  1698. if saved_favs:
  1699. favs=eval(saved_favs)
  1700. if favs:
  1701. for (_name,_year,_img,_fanart,_country,_url,_plot,_genre,_dbid) in favs:
  1702. if (name==_name) and (year==_year):
  1703. favs.remove((_name,_year,_img,_fanart,_country,_url,_plot,_genre,_dbid)); cache.set('favs_'+section+subfav+'__', str(favs)); tf=True; sunNote(bFL(name.upper()+' ('+year+')'),bFL('Removed from Favorites')); deb(name+' ('+year+')','Removed from Favorites. (Hopefully)'); xbmc.executebuiltin("XBMC.Container.Refresh"); return
  1704. if (tf==False): sunNote(bFL(name.upper()),bFL('not found in your Favorites'))
  1705. else: sunNote(bFL(name.upper()+' ('+year+')'),bFL('not found in your Favorites'))
  1706. def fav__add(section,name,year='',img=_art150,fanart=_artFanart,subfav=''):
  1707. WhereAmI('@ Favorites - Add - %s%s' % (section,subfav))
  1708. if (debugging==True): print 'fav__add()',section,name+' ('+year+')',img,fanart
  1709. saved_favs=cache.get('favs_'+section+subfav+'__'); favs=[]; fav_found=False
  1710. if saved_favs:
  1711. if (debugging==True): print saved_favs
  1712. favs=eval(saved_favs)
  1713. if favs:
  1714. if (debugging==True): print favs
  1715. for (_name,_year,_img,_fanart,_country,_url,_plot,_genre,_dbid) in favs:
  1716. if (name==_name) and (year==_year):
  1717. fav_found=True; sunNote(bFL(section+': '+name.upper()+' ('+year+')'),bFL('Already in your Favorites')); return
  1718. if (section==ps('section.tv')): favs.append((name,year,img,fanart,_param['country'],_param['url'],_param['plot'],_param['genre'],_param['dbid']))
  1719. elif (section==ps('section.movie')): favs.append((name,year,img,fanart,_param['country'],_param['url'],_param['plot'],_param['genre'],''))
  1720. cache.set('favs_'+section+subfav+'__', str(favs)); sunNote(bFL(name+' ('+year+')'),bFL('Added to Favorites'))
  1721. def fav__list(section,subfav=''):
  1722. WhereAmI('@ Favorites - List - %s%s' % (section,subfav)); saved_favs=cache.get('favs_'+section+subfav+'__'); favs=[]
  1723. if saved_favs:
  1724. if (debugging==True): print saved_favs
  1725. favs=sorted(eval(saved_favs), key=lambda fav: (fav[1],fav[0]),reverse=True)
  1726. ItemCount=len(favs) # , total_items=ItemCount
  1727. if favs:
  1728. #if (section==ps('section.tv')): xbmcplugin.setContent( int( sys.argv[1] ), 'tvshows' )
  1729. #elif (section==ps('section.movie')): xbmcplugin.setContent( int( sys.argv[1] ), 'movies' )
  1730. for (name,year,img,fanart,country,url,plot,genre,dbid) in favs:
  1731. if (debugging==True): print '----------------------------'
  1732. if (debugging==True): print name,year,img,fanart,country,url,plot,genre,dbid #,pars,labs
  1733. contextMenuItems=[]; labs2={}; labs2['fanart']=''
  1734. if (section==ps('section.tv')):
  1735. labs2['title']=cFL(name+' ('+cFL(year,ps('cFL_color2'))+')',ps('cFL_color')); labs2['ShowTitle']=name; labs2['year']=year; pars2={'mode': 'GetSeasons', 'section': section, 'url': url, 'img': img, 'image': img, 'fanart': fanart, 'title': name, 'year': year, 'thetvdbid': dbid, 'thetvdb_series_id': dbid, 'Country': country, 'plot': plot }
  1736. if (country is not ''): labs2['title']=labs2['title']+cFL(' ['+cFL(country,ps('cFL_color3'))+']',ps('cFL_color'))
  1737. labs2['image']=img; labs2['fanart']=fanart; labs2['PlotOutline']=labs2['plot']=plot; labs2['genre']=genre; labs2['country']=country
  1738. #labs2['Overlay']=xbmcgui.ICON_OVERLAY_WATCHED #'7' ### Testing ### (Watched) ###
  1739. #labs2['overlay']=xbmcgui.ICON_OVERLAY_WATCHED #'7' ### Testing ### (Watched) ###
  1740. #labs2[u'overlay']=xbmcgui.ICON_OVERLAY_WATCHED #'7' ### Testing ### (Watched) ###
  1741. #labs2['Overlay']=7 ### Testing ### (Watched) ###
  1742. #labs2['overlay']=7 ### Testing ### (Watched) ###
  1743. #labs2['overlay']=6 ### Testing ### (Unwatched) ###
  1744. #labs2[u'watched']=7
  1745. #labs2[u'watch']=7
  1746. #
  1747. #
  1748. ##### Right Click Menu for: TV #####
  1749. contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  1750. contextMenuItems.append((ps('cMI.airdates.find.name'), ps('cMI.airdates.find.url') % (sys.argv[0],ps('cMI.airdates.find.mode'),urllib.quote_plus(name))))
  1751. #contextMenuItems.append((ps('cMI.favorites.tv.remove.name'),ps('cMI.favorites.tv.remove.url') % (sys.argv[0],ps('cMI.favorites.tv.remove.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(img),urllib.quote_plus(fanart),urllib.quote_plus(country),urllib.quote_plus(plot),urllib.quote_plus(genre),urllib.quote_plus(url),dbid, '' )))
  1752. contextMenuItems.append((ps('cMI.favorites.tv.remove.name'),ps('cMI.favorites.tv.remove.url') % (sys.argv[0],ps('cMI.favorites.tv.remove.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(img),urllib.quote_plus(fanart),urllib.quote_plus(country),urllib.quote_plus(plot),urllib.quote_plus(genre),urllib.quote_plus(url),dbid,subfav )))
  1753. if os.path.exists(xbmc.translatePath(ps('special.home.addons'))+ps('cMI.1ch.search.folder')):
  1754. contextMenuItems.append((ps('cMI.1ch.search.name'), ps('cMI.1ch.search.url') % (ps('cMI.1ch.search.plugin') , ps('cMI.1ch.search.section.tv'), name)))
  1755. if os.path.exists(xbmc.translatePath(ps('special.home.addons'))+ps('cMI.primewire.search.folder')):
  1756. contextMenuItems.append((ps('cMI.primewire.search.name'), ps('cMI.primewire.search.url') % (ps('cMI.primewire.search.plugin'), ps('cMI.primewire.search.section.tv'), name)))
  1757. if (fanart is not ''):
  1758. contextMenuItems.append(('Download Wallpaper', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url( { 'mode': 'Download' , 'section': ps('section.wallpaper') , 'studio': name+' ('+year+')' , 'img': img , 'url': fanart } ) ))
  1759. ##### Right Click Menu for: TV ##### /\ #####
  1760. #try: _addon.add_directory2(pars2, labs2, img=img, fanart=fanart, contextmenu_items=contextMenuItems, overlay=7) ## Testing Watched/Unwatched ##
  1761. try: _addon.add_directory(pars2, labs2, img=img, fanart=fanart, contextmenu_items=contextMenuItems, total_items=ItemCount)
  1762. except: deb('Error Listing Item',name+' ('+year+')')
  1763. elif (section==ps('section.movie')):
  1764. labs2['title']=cFL(name+' ('+cFL(year,ps('cFL_color2'))+')',ps('cFL_color')); labs2['image']=img; labs2['fanart']=fanart; labs2['ShowTitle']=name; labs2['year']=year; pars2={'mode': 'GetLinks', 'section': section, 'url': url, 'img': img, 'image': img, 'fanart': fanart, 'title': name, 'year': year }; labs2['plot']=plot
  1765. ##labs2['title']=cFL(name+' ('+cFL(year,ps('cFL_color2'))+') ['+cFL(country,ps('cFL_color3'))+']',ps('cFL_color'))
  1766. ##labs2[u'overlay']=xbmcgui.ICON_OVERLAY_WATCHED
  1767. ##labs2['overlay']=xbmcgui.ICON_OVERLAY_WATCHED
  1768. #labs2['overlay']=7
  1769. #
  1770. ##### Right Click Menu for: TV #####
  1771. contextMenuItems.append((ps('cMI.showinfo.name'),ps('cMI.showinfo.url')))
  1772. #contextMenuItems.append((ps('cMI.favorites.tv.remove.name'), ps('cMI.favorites.movie.remove.url') % (sys.argv[0],ps('cMI.favorites.tv.remove.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(img),urllib.quote_plus(fanart),urllib.quote_plus(country),urllib.quote_plus(plot),urllib.quote_plus(genre),urllib.quote_plus(url), '' )))
  1773. contextMenuItems.append((ps('cMI.favorites.tv.remove.name'),ps('cMI.favorites.movie.remove.url') % (sys.argv[0],ps('cMI.favorites.tv.remove.mode'),section,urllib.quote_plus(name),year,urllib.quote_plus(img),urllib.quote_plus(fanart),urllib.quote_plus(country),urllib.quote_plus(plot),urllib.quote_plus(genre),urllib.quote_plus(url),subfav )))
  1774. if (fanart is not ''): contextMenuItems.append(('Download Wallpaper', 'XBMC.RunPlugin(%s)' % _addon.build_plugin_url( { 'mode': 'Download' , 'section': ps('section.wallpaper') , 'studio': name+' ('+year+')' , 'img': img , 'url': fanart } ) ))
  1775. ##### Right Click Menu for: TV ##### /\ #####
  1776. try: _addon.add_directory(pars2, labs2, img=img, fanart=fanart, contextmenu_items=contextMenuItems)
  1777. except: deb('Error Listing Item',name+' ('+year+')')
  1778. if (section==ps('section.tv')): set_view('tvshows',ps('setview.tv') ,True)
  1779. elif (section==ps('section.movie')): set_view('movies' ,ps('setview.movies') ,True)
  1780. else: sunNote('Favorites: '+section,'No favorites found *'); set_view('list',addst('default-view')); eod(); return
  1781. else: sunNote('Favorites: '+section,'No favorites found **'); set_view('list',addst('default-view')); eod(); return
  1782. #set_view('list',addst('default-view'));
  1783. eod()
  1784. ##### /\ ##### Favorites #####
  1785. ### ############################################################################################################
  1786. ### ############################################################################################################
  1787. ### ############################################################################################################
  1788. ##### Search #####
  1789. def doSearchNormal (section,title=''):
  1790. if (section=='tv'): SearchPrefix='http://vidics4.com/?s=%s&x=0&y=0'
  1791. else: SearchPrefix='http://vidics4.com/?s=%s&x=0&y=0'
  1792. if (title==''):
  1793. title=showkeyboard(txtMessage=title,txtHeader="Title: ("+section+")")
  1794. if (title=='') or (title=='none') or (title==None) or (title==False): return
  1795. _param['url']=SearchPrefix % (title.replace(' ','+'))
  1796. deb('Searching for',_param['url']); listItems(section, _param['url'], _param['pageno'], addst('pages'), _param['genre'], _param['year'], _param['title'])
  1797. def doSearchAdvanced (section,title=''):
  1798. txtHeader='Advanced Search'; options={}; r= -1
  1799. #########################
  1800. options[ps('AdvSearch.tags.1')] =''
  1801. options[ps('AdvSearch.tags.2')] =''
  1802. options[ps('AdvSearch.tags.3')] =''
  1803. options[ps('AdvSearch.tags.4')] ='0'
  1804. options[ps('AdvSearch.tags.5')] =str(ps('BrowseByYear.earliestyear'))
  1805. options[ps('AdvSearch.tags.6')] =str(int(datetime.date.today().strftime("%Y"))+1)
  1806. options[ps('AdvSearch.tags.7')] ='' ### &q[genre][]=2&q[genre][]=13
  1807. #########################
  1808. options['startPage'] ='1'
  1809. options['numOfPages'] =addst('pages') #'1'
  1810. #########################
  1811. if (section==ps('section.tv') ): options[ps('AdvSearch.tags.0')]='1'; options['url']=ps('AdvSearch.url.tv')
  1812. elif (section==ps('section.movie')): options[ps('AdvSearch.tags.0')]='0'; options['url']=ps('AdvSearch.url.movie')
  1813. else: options[ps('AdvSearch.tags.0')]='0'; options['url']=ps('AdvSearch.url.movie')
  1814. options['url']+='['+ps('AdvSearch.tags.0')+']='+options[ps('AdvSearch.tags.0')]; _param['url']=options['url']
  1815. #options['']=''
  1816. #options['']=''
  1817. ### [year_from]=2013&q[year_to]=2014&q[country]=132&q[genre][]=2&q[genre][]=13
  1818. ### http://www.solarmovie.so/advanced-search/?q[title]=maveric&q[is_series]=0&q[actor]=&q[description]=&q[year_from]=2013&q[year_to]=2014&q[country]=0
  1819. ### http://www.solarmovie.so/advanced-search/?q[title]=maveric&q[is_series]=0&q[actor]=testb&q[description]=testa&q[year_from]=2013&q[year_to]=2014&q[country]=132&q[genre][]=2&q[genre][]=13
  1820. while (r is not 0):
  1821. option_list=[]
  1822. option_list.append( ps('AdvSearch.menu.0'))
  1823. if (''==options[ps('AdvSearch.tags.1')]): option_list.append(ps('AdvSearch.menu.1'))
  1824. else: option_list.append(ps('AdvSearch.menu.1')+': '+options[ps('AdvSearch.tags.1')])
  1825. if (''==options[ps('AdvSearch.tags.2')]): option_list.append(ps('AdvSearch.menu.2'))
  1826. else: option_list.append(ps('AdvSearch.menu.2')+': '+options[ps('AdvSearch.tags.2')])
  1827. if (''==options[ps('AdvSearch.tags.3')]): option_list.append(ps('AdvSearch.menu.3'))
  1828. else: option_list.append(ps('AdvSearch.menu.3')+': '+options[ps('AdvSearch.tags.3')])
  1829. if (''==options[ps('AdvSearch.tags.4')]): option_list.append(ps('AdvSearch.menu.4'))
  1830. else: option_list.append(ps('AdvSearch.menu.4')+': '+options[ps('AdvSearch.tags.4')])
  1831. if (''==options[ps('AdvSearch.tags.5')]): option_list.append(ps('AdvSearch.menu.5'))
  1832. else: option_list.append(ps('AdvSearch.menu.5')+': '+options[ps('AdvSearch.tags.5')])
  1833. if (''==options[ps('AdvSearch.tags.6')]): option_list.append(ps('AdvSearch.menu.6'))
  1834. else: option_list.append(ps('AdvSearch.menu.6')+': '+options[ps('AdvSearch.tags.6')])
  1835. if (''==options[ps('AdvSearch.tags.7')]): option_list.append(ps('AdvSearch.menu.7'))
  1836. else: option_list.append(ps('AdvSearch.menu.7')+': '+options[ps('AdvSearch.tags.7')])
  1837. option_list.append( ps('AdvSearch.menu.8'))
  1838. r=askSelection(option_list,txtHeader)
  1839. if (r==0): ### Do Advanced Search
  1840. _param['url']+='&q['+ps('AdvSearch.tags.1')+']='+options[ps('AdvSearch.tags.1')];
  1841. _param['url']+='&q['+ps('AdvSearch.tags.2')+']='+options[ps('AdvSearch.tags.2')];
  1842. _param['url']+='&q['+ps('AdvSearch.tags.3')+']='+options[ps('AdvSearch.tags.3')];
  1843. _param['url']+='&q['+ps('AdvSearch.tags.5')+']='+options[ps('AdvSearch.tags.5')];
  1844. _param['url']+='&q['+ps('AdvSearch.tags.6')+']='+options[ps('AdvSearch.tags.6')];
  1845. _param['url']+='&q['+ps('AdvSearch.tags.4')+']='+options[ps('AdvSearch.tags.4')];
  1846. ### if (options['year_to'] is not ''): _param['url']+='&q[year_to]='+options['year_to'];
  1847. deb('Advanced Searching',_param['url'])
  1848. listItems(section, _param['url'], startPage=options['startPage'], numOfPages=options['numOfPages'], chck='AdvancedSearch')
  1849. ### listItems(section, _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'],chck='AdvancedSearch')
  1850. ### listItems(section=, url=, startPage='1', numOfPages='1', genre='', year='', stitle='', season='', episode='', html='', chck=''): # List: Movies or TV Shows
  1851. elif (r==1): ### Change Title
  1852. r2=showkeyboard(txtMessage=options[ps('AdvSearch.tags.1')],txtHeader="Title: "+options[ps('AdvSearch.tags.1')],passwordField=False)
  1853. if (r2 is not False): options[ps('AdvSearch.tags.1')]=r2
  1854. elif (r==2): ### Change Description
  1855. r2=showkeyboard(txtMessage=options['description'],txtHeader="Description: "+options['description'],passwordField=False)
  1856. if (r2 is not False): options['description']=r2
  1857. elif (r==3): ### Change Actor
  1858. r2=showkeyboard(txtMessage=options[ps('AdvSearch.tags.2')],txtHeader="Actor: "+options[ps('AdvSearch.tags.2')],passwordField=False)
  1859. if (r2 is not False): options[ps('AdvSearch.tags.2')]=r2
  1860. #elif (r==4): ### Change Country
  1861. elif (r==5): ### Change Year From
  1862. r2=dialogbox_number(Header='Year From:'+options[ps('AdvSearch.tags.5')],n='01/01/'+options[ps('AdvSearch.tags.5')],type=0)
  1863. if (r2 is not False) and (len(r2)==4): options[ps('AdvSearch.tags.5')]=r2
  1864. if (r2 is not False) and ('/' in r2): options[ps('AdvSearch.tags.5')]=r2.split('/')[2] ## <<<
  1865. if (r2 is not False) and ('-' in r2): options[ps('AdvSearch.tags.5')]=r2.split('-')[2]
  1866. elif (r==6): ### Change Year To
  1867. r2=dialogbox_number(Header='Year To:' +options[ps('AdvSearch.tags.6')],n='01/01/'+options[ps('AdvSearch.tags.6')],type=0)
  1868. if (r2 is not False) and (len(r2)==4): options[ps('AdvSearch.tags.6')]=r2
  1869. if (r2 is not False) and ('/' in r2): options[ps('AdvSearch.tags.6')]=r2.split('/')[2] ## <<<
  1870. if (r2 is not False) and ('-' in r2): options[ps('AdvSearch.tags.6')]=r2.split('-')[2]
  1871. #elif (r==7): ### Change Genre
  1872. elif (r==8): ### Cancel Advanced Search
  1873. eod(); return
  1874. #elif (r== -1): ### escape // right click or such.
  1875. # eod(); return
  1876. ##
  1877. ##
  1878. #
  1879. #
  1880. #
  1881. eod()
  1882. return
  1883. ##### /\ ##### Search #####
  1884. ### ############################################################################################################
  1885. ### ############################################################################################################
  1886. ### ############################################################################################################
  1887. ##### Modes #####
  1888. def check_mode(mode=''):
  1889. deb('Mode',mode)
  1890. if (mode=='') or (mode=='main') or (mode=='MainMenu'):
  1891. initDatabase(); Menu_MainMenu()
  1892. elif (mode=='PlayVideo'): PlayVideo(_param['url'], _param['infoLabels'], _param['listitem'])
  1893. elif (mode=='PlayTrailer'): PlayTrailer(_param['url'], _param['title'], _param['year'], _param['img'])
  1894. elif (mode=='Settings'): _addon.addon.openSettings() #_plugin.openSettings()
  1895. elif (mode=='ResolverSettings'): urlresolver.display_settings()
  1896. elif (mode=='LoadCategories'): Menu_LoadCategories(_param['section'])
  1897. #elif (mode=='BrowseAtoZ'): BrowseAtoZ(_param['section'])
  1898. elif (mode=='BrowseYear'): Menu_BrowseByYear(_param['section'])
  1899. elif (mode=='BrowseGenre'): Menu_BrowseByGenre(_param['section'])
  1900. elif (mode=='BrowseCountry'): Menu_BrowseByCountry(_param['section'])
  1901. #elif (mode=='BrowseLatest'): BrowseLatest(_param['section'])
  1902. #elif (mode=='BrowsePopular'): BrowsePopular(_param['section'])
  1903. #elif (mode=='GetResults'): GetResults(_param['section'], genre, letter, page)
  1904. elif (mode=='GetTitles'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'])
  1905. elif (mode=='GetTitlesLatest'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.tv.latest.check'))
  1906. elif (mode=='GetTitlesLatestWatched'): listItems(_param['section'],_param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.tv.latest.watched.check'))
  1907. elif (mode=='GetTitlesPopular'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.tv.popular.all.check'))
  1908. elif (mode=='GetTitlesHDPopular'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.movies.popular.hd.check'))
  1909. elif (mode=='GetTitlesOtherPopular'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.movies.popular.other.check'))
  1910. elif (mode=='GetTitlesNewPopular'): listItems(_param['section'], _param['url'], _param['pageno'], _param['pagecount'], _param['genre'], _param['year'], _param['title'], chck=ps('LI.movies.popular.new.check'))
  1911. elif (mode=='GetLinks'): listLinks(_param['section'], _param['url'], showtitle=_param['showtitle'], showyear=_param['showyear'])
  1912. elif (mode=='GetSeasons'): listSeasons(_param['section'], _param['url'], _param['img'])
  1913. elif (mode=='GetEpisodes'): listEpisodes(_param['section'], _param['url'], _param['img'], _param['season'])
  1914. elif (mode=='TextBoxFile'): TextBox2().load_file(_param['url'],_param['title']); eod()
  1915. elif (mode=='TextBoxUrl'): TextBox2().load_url( _param['url'],_param['title']); eod()
  1916. elif (mode=='SearchForAirDates'): search_for_airdates(_param['title']); eod()
  1917. elif (mode=='Search'): doSearchNormal(_param['section'],_param['title'])
  1918. elif (mode=='AdvancedSearch'): doSearchAdvanced(_param['section'],_param['title'])
  1919. elif (mode=='FavoritesList'): fav__list(_param['section'],_param['subfav'])
  1920. elif (mode=='FavoritesEmpty'): fav__empty(_param['section'],_param['subfav'])
  1921. elif (mode=='FavoritesRemove'): fav__remove(_param['section'],_param['title'],_param['year'],_param['subfav'])
  1922. elif (mode=='FavoritesAdd'): fav__add(_param['section'],_param['title'],_param['year'],_param['img'],_param['fanart'],_param['subfav'])
  1923. elif (mode=='sunNote'): sunNote( header=_param['title'],msg=_param['plot'])
  1924. elif (mode=='deadNote'): deadNote(header=_param['title'],msg=_param['plot'])
  1925. elif (mode=='LibrarySaveMovie'): Library_SaveTo_Movies(_param['url'],_param['img'],_param['showtitle'],_param['showyear'])
  1926. elif (mode=='LibrarySaveTV'): Library_SaveTo_TV(_param['section'], _param['url'],_param['img'],_param['showtitle'],_param['showyear'],_param['country'],_param['season'],_param['episode'],_param['episodetitle'])
  1927. elif (mode=='LibrarySaveEpisode'): Library_SaveTo_Episode(_param['url'],_param['img'],_param['title'],_param['showyear'],_param['country'],_param['season'],_param['episode'],_param['episodetitle'])
  1928. elif (mode=='PlayLibrary'): PlayLibrary(_param['section'], _param['url'], showtitle=_param['showtitle'], showyear=_param['showyear'])
  1929. elif (mode=='Download'): print _param; DownloadRequest(_param['section'], _param['url'],_param['img'],_param['studio']); eod()
  1930. elif (mode=='DownloadStop'): DownloadStop(); eod()
  1931. elif (mode=='TrailersGenres'): Trailers_Genres(_param['section'], _param['url'])
  1932. elif (mode=='TrailersList'): Trailers_List(_param['section'], _param['url'], _param['genre'])
  1933. elif (mode=='LatestThreads'): News_LatestThreads(_param['url'],_param['title'])
  1934. elif (mode=='listUsers'): UsersList(_param['section'],_param['url'])
  1935. elif (mode=='UsersChooseSection'): UsersChooseSection(_param['section'],_param['url'])
  1936. elif (mode=='UsersShowFavorites'): UsersShowFavorites(_param['section'],_param['url'])
  1937. #elif (mode=='UsersShowWatchList'): UsersShowWatchList(_param['section'],_param['url'])
  1938. elif (mode=='UsersShowUploads'): UsersShowUploads(_param['section'],_param['url'])
  1939. elif (mode=='PrivacyPolicy'): Site__PrivacyPolicy()
  1940. elif (mode=='TermsOfService'): Site__TermsOfService()
  1941. elif (mode=='GetLatestSearches'): listLatestSearches(_param['section'],_param['url'])
  1942. elif (mode=='UsersShowProfileAccountInfo'): UsersShowPersonInfo(mode, _param['section'],_param['url'])
  1943. else: deadNote(header='Mode: "'+mode+'"',msg='[ mode ] not found.'); initDatabase(); Menu_MainMenu()
  1944. # {'showyear': '', 'infoLabels': "
  1945. # {'Plot': '', 'Episode': '11', 'Title': u'Transformers Prime', 'IMDbID': '2961014', 'host': 'filenuke.com',
  1946. # 'IMDbURL': 'http://anonym.to/?http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2961014%2F',
  1947. # 'ShowTitle': u'Transformers Prime', 'quality': 'HDTV', 'Season': '3', 'age': '25 days',
  1948. # 'Studio': u'Transformers Prime (2010): 3x11 - Persuasion', 'Year': '2010', 'IMDb': '2961014',
  1949. # 'EpisodeTitle': u'Persuasion'}", 'thetvdbid': '', 'year': '', 'special': '', 'plot': '',
  1950. # 'img': 'http://static.solarmovie.so/images/movies/1659175_150x220.jpg', 'title': '', 'fanart': '', 'dbid': '', 'section': 'tv', 'pagesource': '', 'listitem': '<xbmcgui.ListItem object at 0x14C799B0>', 'episodetitle': '', 'thumbnail': '', 'thetvdb_series_id': '', 'season': '', 'labs': '', 'pageurl': '', 'pars': '', 'user': '', 'letter': '', 'genre': '', 'by': '', 'showtitle': '', 'episode': '', 'name': '', 'pageno': 0, 'pagecount': 1, 'url': '/link/show/1466546/', 'country': '', 'subfav': '', 'mode': 'Download', 'tomode': ''}
  1951. ##### /\ ##### Modes #####
  1952. ### ############################################################################################################
  1953. deb('param >> studio',_param['studio'])
  1954. deb('param >> season',_param['season'])
  1955. deb('param >> section',_param['section'])
  1956. deb('param >> img',_param['img'])
  1957. deb('param >> showyear',_param['showyear'])
  1958. deb('param >> showtitle',_param['showtitle'])
  1959. deb('param >> title',_param['title'])
  1960. deb('param >> url',_param['url']) ### Simply Logging the current query-passed / param -- URL
  1961. check_mode(_param['mode']) ### Runs the function that checks the mode and decides what the plugin should do. This should be at or near the end of the file.
  1962. ### ############################################################################################################
  1963. ### ############################################################################################################
  1964. ### ############################################################################################################