PageRenderTime 93ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/default.py

https://github.com/HIGHWAY99/plugin.video.vidics4
Python | 2023 lines | 1976 code | 3 blank | 44 comment | 27 complexity | bd8bf772fb3e1ba1a0dd3816873cd086 MD5 | raw file

Large files files are truncated, but you can click here to view the full 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 De

Large files files are truncated, but you can click here to view the full file