/default.py
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
- ### ############################################################################################################
- ### #
- ### # Project: # Vidics4.com - by The Highway 2013.
- ### # Author: # The Highway
- ### # Version: # v0.2.6
- ### # Description: # http://www.Vidics4.com
- ### #
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Imports #####
- import xbmc,xbmcplugin,xbmcgui,xbmcaddon,xbmcvfs
- #import requests ### (Removed in v0.2.1b to fix scripterror on load on Mac OS.) ###
- try: import requests ### <import addon="script.module.requests" version="1.1.0"/> ###
- except: t='' ### See https://github.com/kennethreitz/requests ###
- import urllib,urllib2,re,os,sys,htmllib,string,StringIO,logging,random,array,time,datetime
- import urlresolver
- import copy
- ###
- #import cookielib
- #import base64
- #import threading
- ###
- #import unicodedata ### I don't want to use unless I absolutely have to. ###
- #import zipfile ### Removed because it caused videos to not play. ###
- import HTMLParser, htmlentitydefs
- try: import StorageServer
- except: import storageserverdummy as StorageServer
- try: from t0mm0.common.addon import Addon
- except: from t0mm0_common_addon import Addon
- try: from t0mm0.common.net import Net
- except: from t0mm0_common_net import Net
- try: from sqlite3 import dbapi2 as sqlite; print "Loading sqlite3 as DB engine"
- except: from pysqlite2 import dbapi2 as sqlite; print "Loading pysqlite2 as DB engine"
- try: from script.module.metahandler import metahandlers
- except: from metahandler import metahandlers
- ###
- from teh_tools import *
- from config import *
- ##### /\ ##### Imports #####
- ### ############################################################################################################
- ### ############################################################################################################
- ### ############################################################################################################
- __plugin__=ps('__plugin__'); __authors__=ps('__authors__'); __credits__=ps('__credits__'); _addon_id=ps('_addon_id'); _domain_url=ps('_domain_url'); _database_name=ps('_database_name'); _plugin_id=ps('_addon_id')
- _database_file=os.path.join(xbmc.translatePath("special://database"),ps('_database_name')+'.db');
- ###
- _addon=Addon(ps('_addon_id'), sys.argv); addon=_addon; _plugin=xbmcaddon.Addon(id=ps('_addon_id')); cache=StorageServer.StorageServer(ps('_addon_id'))
- ### ############################################################################################################
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Paths #####
- ### # ps('')
- _addonPath =xbmc.translatePath(_plugin.getAddonInfo('path'))
- _artPath =xbmc.translatePath(os.path.join(_addonPath,ps('_addon_path_art')))
- _datapath =xbmc.translatePath(_addon.get_profile()); _artIcon =_addon.get_icon(); _artFanart =_addon.get_fanart()
- ##### /\ ##### Paths #####
- ##### Important Functions with some dependencies #####
- def art(f,fe=ps('default_art_ext')): return xbmc.translatePath(os.path.join(_artPath,f+fe)) ### for Making path+filename+ext data for Art Images. ###
- ##### /\ ##### Important Functions with some dependencies #####
- ##### Settings #####
- _setting={}; _setting['enableMeta'] = _enableMeta =tfalse(addst("enableMeta"))
- _setting['debug-enable']= _debugging =tfalse(addst("debug-enable")); _setting['debug-show'] = _shoDebugging =tfalse(addst("debug-show"))
- _setting['meta.movie.domain']=ps('meta.movie.domain'); _setting['meta.movie.search']=ps('meta.movie.search')
- _setting['meta.tv.domain'] =ps('meta.tv.domain'); _setting['meta.tv.search'] =ps('meta.tv.search')
- _setting['meta.tv.page']=ps('meta.tv.page'); _setting['meta.tv.fanart.url']=ps('meta.tv.fanart.url'); _setting['meta.tv.fanart.url2']=ps('meta.tv.fanart.url2'); _setting['label-empty-favorites']=tfalse(addst('label-empty-favorites'))
- CurrentPercent=0; CancelDownload=False
- ##### /\ ##### Settings #####
- ##### Variables #####
- _art404='http://www.solarmovie.so/images/404.png' #_art404=art('404')
- _art150='http://www.solarmovie.so/images/thumb150.png' #_art150=art('thumb150')
- _artDead='http://www.solarmovie.so/images/deadplanet.png' #_artDead=art('deadplanet')
- _artSun=art('sun'); COUNTRIES=ps('COUNTRIES'); GENRES=ps('GENRES'); _default_section_=ps('default_section'); net=Net(); DB=_database_file; BASE_URL=_domain_url;
- ##### /\ ##### Variables #####
- deb('Addon Path',_addonPath); deb('Art Path',_artPath); deb('Addon Icon Path',_artIcon); deb('Addon Fanart Path',_artFanart)
- ### ############################################################################################################
- def eod(): _addon.end_of_directory()
- def deadNote(header='',msg='',delay=5000,image=_artDead): _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
- def sunNote( header='',msg='',delay=5000,image=_artSun):
- header=cFL(header,ps('cFL_color')); msg=cFL(msg,ps('cFL_color2'))
- _addon.show_small_popup(title=header,msg=msg,delay=delay,image=image)
- def messupText(t,_html=False,_ende=False,_a=False,Slashes=False):
- if (_html==True): t=ParseDescription(HTMLParser.HTMLParser().unescape(t))
- if (_ende==True): t=t.encode('ascii', 'ignore'); t=t.decode('iso-8859-1')
- if (_a==True): t=_addon.decode(t); t=_addon.unescape(t)
- if (Slashes==True): t=t.replace( '_',' ')
- return t
- def name2path(name): return (((name.lower()).replace('.','-')).replace(' ','-')).replace('--','-')
- def name2pathU(name): return (((name.replace(' and ','-')).replace('.','-')).replace(' ','-')).replace('--','-')
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Queries #####
- _param={}
- _param['mode']=addpr('mode',''); _param['url']=addpr('url',''); _param['pagesource'],_param['pageurl'],_param['pageno'],_param['pagecount']=addpr('pagesource',''),addpr('pageurl',''),addpr('pageno',0),addpr('pagecount',1)
- _param['img']=addpr('img',''); _param['fanart']=addpr('fanart',''); _param['thumbnail'],_param['thumbnail'],_param['thumbnail']=addpr('thumbnail',''),addpr('thumbnailshow',''),addpr('thumbnailepisode','')
- _param['section']=addpr('section','movies'); _param['title']=addpr('title',''); _param['year']=addpr('year',''); _param['genre']=addpr('genre','')
- _param['by']=addpr('by',''); _param['letter']=addpr('letter',''); _param['showtitle']=addpr('showtitle',''); _param['showyear']=addpr('showyear',''); _param['listitem']=addpr('listitem',''); _param['infoLabels']=addpr('infoLabels',''); _param['season']=addpr('season',''); _param['episode']=addpr('episode','')
- _param['pars']=addpr('pars',''); _param['labs']=addpr('labs',''); _param['name']=addpr('name',''); _param['thetvdbid']=addpr('thetvdbid','')
- _param['plot']=addpr('plot',''); _param['tomode']=addpr('tomode',''); _param['country']=addpr('country','')
- _param['thetvdb_series_id']=addpr('thetvdb_series_id',''); _param['dbid']=addpr('dbid',''); _param['user']=addpr('user','')
- _param['subfav']=addpr('subfav',''); _param['episodetitle']=addpr('episodetitle',''); _param['special']=addpr('special',''); _param['studio']=addpr('studio','')
- #_param['']=_addon.queries.get('','')
- #_param['']=_addon.queries.get('','')
- ##_param['pagestart']=addpr('pagestart',0)
- ##### /\
- ### ############################################################################################################
- ### ############################################################################################################
- def initDatabase():
- print "Building solarmovie Database"
- if ( not os.path.isdir( os.path.dirname(_database_file) ) ): os.makedirs( os.path.dirname( _database_file ) )
- db=sqlite.connect(_database_file); cursor=db.cursor()
- cursor.execute('CREATE TABLE IF NOT EXISTS seasons (season UNIQUE, contents);')
- cursor.execute('CREATE TABLE IF NOT EXISTS favorites (type, name, url, img);')
- db.commit(); db.close()
- ### ############################################################################################################
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Player Functions #####
- def PlayVideo(url, infoLabels, listitem):
- WhereAmI('@ PlayVideo -- Getting ID From: %s' % url);
- #My_infoLabels=eval(infoLabels)
- #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'] }
- infoLabels={ "Studio": _param['studio'], "ShowTitle": _param['showtitle'], "Title": _param['title'], "Year": _param['year'], "Plot": _param['plot'] }
- li=xbmcgui.ListItem(_param['title'], iconImage=_param['img'], thumbnailImage=_param['img'])
- #match=re.search( '/.+?/.+?/(.+?)/', url) ## Example: http://www.solarmovie.so/link/show/1052387/ ##
- #videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
- #html=net.http_GET(url).content
- #match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL)
- #link=match.group(1)
- link=url
- link=link.replace('/embed/', '/file/'); deb('hoster link',link)
- li.setInfo(type="Video", infoLabels=infoLabels ); li.setProperty('IsPlayable', 'true')
- try: stream_url = urlresolver.HostedMediaFile(link).resolve()
- except:
- deb('Link URL Was Not Resolved',link); deadNote("urlresolver.HostedMediaFile(link).resolve()","Failed to Resolve Playable URL."); return
- eod()
- ##xbmc.Player().stop()
- play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
- try: _addon.resolve_url(url)
- except: t=''
- try: _addon.resolve_url(stream_url)
- except: t=''
- play.play(stream_url, li); xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=li)
- try: _addon.resolve_url(url)
- except: t=''
- try: _addon.resolve_url(stream_url)
- except: t=''
- def PlayLibrary(section, url, showtitle='', showyear=''): ### Menu for Listing Hosters (Host Sites of the actual Videos)
- WhereAmI('@ Play Library: %s' % url); sources=[]; listitem=xbmcgui.ListItem()
- #eod()
- #_addon.resolve_url(url)
- if (url==''): return
- html=net.http_GET(url).content; html=html.encode("ascii", "ignore")
- ##if (_debugging==True): print html
- #if ( section == 'tv'): ## TV Show ## Title (Year) - Info
- # match=re.compile(ps('LLinks.compile.show_episode.info'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0] ### <title>Watch The Walking Dead Online for Free - Prey - S03E14 - 3x14 - SolarMovie</title>
- # if (_debugging==True): print match
- # if (match==None): return
- # ShowYear=_param['year'] #ShowYear=showyear
- # ShowTitle=match[0].strip(); EpisodeTitle=match[1].strip(); Season=match[2].strip(); Episode=match[3].strip()
- # ShowTitle=HTMLParser.HTMLParser().unescape(ShowTitle); ShowTitle=ParseDescription(ShowTitle); ShowTitle=ShowTitle.encode('ascii', 'ignore'); ShowTitle=ShowTitle.decode('iso-8859-1'); EpisodeTitle=HTMLParser.HTMLParser().unescape(EpisodeTitle); EpisodeTitle=ParseDescription(EpisodeTitle); EpisodeTitle=EpisodeTitle.encode('ascii', 'ignore'); EpisodeTitle=EpisodeTitle.decode('iso-8859-1')
- # if ('<p id="plot_' in html):
- # ShowPlot=(re.compile(ps('LLinks.compile.show.plot'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip(); ShowPlot=HTMLParser.HTMLParser().unescape(ShowPlot); ShowPlot=ParseDescription(ShowPlot); ShowPlot=ShowPlot.encode('ascii', 'ignore'); ShowPlot=ShowPlot.decode('iso-8859-1')
- # else: ShowPlot=''
- # match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
- # if (_debugging==True): print match
- # (IMDbURL,IMDbID)=match; IMDbURL=IMDbURL.strip(); IMDbID=IMDbID.strip(); My_infoLabels={ "Studio": ShowTitle+' ('+ShowYear+'): '+Season+'x'+Episode+' - '+EpisodeTitle, "Title": ShowTitle, "ShowTitle": ShowTitle, "Year": ShowYear, "Plot": ShowPlot, 'Season': Season, 'Episode': Episode, 'EpisodeTitle': EpisodeTitle, 'IMDbURL': IMDbURL, 'IMDbID': IMDbID, 'IMDb': IMDbID }; listitem.setInfo(type="Video", infoLabels=My_infoLabels )
- #else: #################### Movie ## Title (Year) - Info
- # match=re.compile(ps('LLinks.compile.show.title_year'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
- # if (_debugging==True): print match
- # if (match==None): return
- # ShowYear=match[1].strip(); ShowTitle=match[0].strip(); ShowTitle=HTMLParser.HTMLParser().unescape(ShowTitle); ShowTitle=ParseDescription(ShowTitle); ShowTitle=ShowTitle.encode('ascii', 'ignore'); ShowTitle=ShowTitle.decode('iso-8859-1'); ShowPlot=(re.compile(ps('LLinks.compile.show.plot'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip(); ShowPlot=HTMLParser.HTMLParser().unescape(ShowPlot); ShowPlot=ParseDescription(ShowPlot); ShowPlot=ShowPlot.encode('ascii', 'ignore'); ShowPlot=ShowPlot.decode('iso-8859-1'); match=re.compile(ps('LLinks.compile.imdb.url_id'), re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]
- # if (_debugging==True): print match
- # (IMDbURL,IMDbID)=match; IMDbURL=IMDbURL.strip(); IMDbID=IMDbID.strip(); My_infoLabels={ "Studio": ShowTitle+' ('+ShowYear+')', "Title": ShowTitle, "ShowTitle": ShowTitle, "Year": ShowYear, "Plot": ShowPlot, 'IMDbURL': IMDbURL, 'IMDbID': IMDbID, 'IMDb': IMDbID }; listitem.setInfo(type="Video", infoLabels=My_infoLabels )
- ### Both -Movies- and -TV Shows- ### Hosters
- try: matchH=re.compile(ps('LLinks.compile.hosters2'), re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)
- except: matchH=''
- #deb('length of matchH',str(len(matchH)))
- #print matchH
- if (len(matchH) > 0):
- oList=[]; hList=[]; matchH=sorted(matchH, key=lambda item: item[3], reverse=True)
- for url, host, quality, age in matchH:
- url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
- try: mID=re.compile('/.+?/.+?/([0-9]+)/', re.DOTALL | re.IGNORECASE).findall(url)[0]
- except: mID=''
- #deb('Media Passed',str(host)+' | '+str(quality)+' | '+str(age)+' | '+str(url)+' | '+str(mID))
- if (mID is not ''):
- oList.append(host+' ['+quality+'] ('+age+')')
- hList.append([url,host,quality,age,mID])
- try: rt=askSelection(oList,'Select Source:')
- except: rt=''
- print rt
- if (rt==None) or (rt=='none') or (rt==False) or (rt==''): return
- hItem=hList[rt]
- deb('ID',hItem[4])
- urlB='%s/link/play/%s/' % (ps('_domain_url'),hItem[4])
- html=net.http_GET(urlB).content
- try: url=re.compile('<iframe.+?src="(.+?)"', re.MULTILINE | re.DOTALL | re.IGNORECASE).findall(html)[0]
- except: url=''
- url=url.replace('/embed/', '/file/'); deb('hoster url',url)
- #oList=[]
- #for url, host, quality, age in match:
- # url=url.strip(); host=host.strip(); quality=quality.strip(); age=age.strip()
- # print 'Media Failed: '+str(host)+' | '+str(quality)+' | '+str(age)+' | '+url
- # if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
- # try: MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
- # except: MediaID=''
- # try: MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
- # except: MediaHost=''
- # print 'Media Passed: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
- # if (MediaHost is not '') and (MediaID is not ''):
- # oList.append(urlresolver.HostedMediaFile(host=MediaHost, media_id=MediaID))
- ##
- #
- #try: url=urlresolver.choose_source(oList)
- #except: return
- #
- #MediaID=urlresolver.HostedMediaFile(url=url).get_media_url()
- #MediaHost=urlresolver.HostedMediaFile(url=url).get_host()
- #print 'Media: '+str(MediaHost)+' | '+str(MediaID)+' | '+url
- #print str(urlresolver.HostedMediaFile(url=url.strip()).valid_url())
- #if (urlresolver.HostedMediaFile(url=url.strip()).valid_url()):
- #
- #
- #
- #
- #videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
- #html=net.http_GET(url).content; match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); link=match.group(1); link=link.replace('/embed/', '/file/'); deb('hoster link',link)
- #
- deb('video',url)
- liz=xbmcgui.ListItem(_param['showtitle'], iconImage="DefaultVideo.png", thumbnailImage=_param['img'])
- if ( section == 'tv'): ## TV Show ## Title (Year) - Info
- liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
- else: #################### Movies ### Title (Year) - Info
- liz.setInfo( type="Video", infoLabels={ "Title": _param['showtitle']+' ('+_param['showyear']+')', "Studio": 'SolarMovie.so' } )
- liz.setProperty("IsPlayable","true")
- ##pl=xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
- ##pl.clear()
- ##pl.add(url, liz)
- ##xbmc.Player().play(pl)
- play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
- print url
- stream_url = urlresolver.HostedMediaFile(url).resolve()
- print stream_url
- play.play(stream_url, liz)
- #play.play(url, liz)
- liz.setPath(url)
- xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
- _addon.resolve_url(url)
- _addon.resolve_url(stream_url)
- ##
- ##
- ##
- ##count=1
- ##for url, host, quality, age in match:
- ## host=host.strip(); quality=quality.strip(); name=str(count)+". "+host+' - [[B]'+quality+'[/B]] - ([I]'+age+'[/I])'
- ## if urlresolver.HostedMediaFile(host=host, media_id='xxx'):
- ## img=ps('Hosters.icon.url')+host; My_infoLabels['quality']=quality; My_infoLabels['age']=age; My_infoLabels['host']=host; _addon.add_directory({'section': section, 'img': _param['img'], 'mode': 'PlayVideo', 'url': url, 'quality': quality, 'age': age, 'infoLabels': My_infoLabels, 'listitem': listitem}, {'title': name}, img=img, is_folder=False); count=count+1
- eod()
- else: return
- ### ################################################################
- def DownloadStop(): ## Testing ## Doesn't work yet.
- global CancelDownload
- CancelDownload=True
- #global CancelDownload
- eod()
- #download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
- #if (download_method=='Progress'):
- # dp=xbmcgui.DialogProgress() ## For Frodo and earlier.
- # dp.close()
- #elif (download_method=='ProgressBG'):
- # dp=xbmcgui.DialogProgressBG() ## Only works on daily build of XBMC.
- # dp.close()
- #elif (download_method=='Test'):
- # t=''
- #elif (download_method=='Hidden'):
- # t=''
- #else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
- #try: t=''
- #except: t=''
- def DownloadStatus(numblocks, blocksize, filesize, dlg, download_method, start_time, section, url, img, LabelName, ext, LabelFile):
- if (CancelDownload==True):
- try:
- if (download_method=='Progress'): ## For Frodo and earlier.
- dlg.close()
- elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
- dlg.close()
- elif (download_method=='Test'): t=''
- elif (download_method=='Hidden'): t=''
- except: t=''
- try:
- percent = min(numblocks * blocksize * 100 / filesize, 100)
- currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
- kbps_speed = numblocks * blocksize / (time.time() - start_time)
- if kbps_speed > 0: eta = (filesize - numblocks * blocksize) / kbps_speed
- else: eta = 0
- kbps_speed /= 1024
- total = float(filesize) / (1024 * 1024)
- #if (download_method=='Progress'): ## For Frodo and earlier.
- # line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
- # line1 +=' '+percent+'%'
- # line2 = 'Speed: %.02f Kb/s ' % kbps_speed
- # line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
- # dlg.update(percent, line1, line2, line3)
- #elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
- # line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
- # line1 +=' '+percent+'%'
- # line2 ='Speed: %.02f Kb/s ' % kbps_speed
- # line2 +='ETA: %02d:%02d' % divmod(eta, 60)
- # dlg.update(percent, line1, line2)
- #elif (download_method=='Test'):
- # mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
- # spd = 'Speed: %.02f Kb/s ' % kbps_speed
- # est = 'ETA: %02d:%02d' % divmod(eta, 60)
- # Header= ext+' '+mbs+' '+percent+'%'
- # Message= est+' '+spd
- #elif (download_method=='Hidden'): t=''
- #if (time.time()==start_time) or (int(str(time.time())[-5:1]) == 0): # and (int(str(time.time())[-5:2]) < 10):
- #if (int(time.strptime(time.time(),fmt='%S')) == 0):
- #if (str(percent) in ['0','1','5','10','15','20','25','30','35','40','45','50','55','60','65','70','75','80','85','90','91','92','93','94','95','96','97','98','99','100']):
- #if (str(percent) == '0' or '1' or '5' or '10' or '15' or '20' or '25' or '30' or '35' or '40' or '45' or '50' or '55' or '60' or '65' or '70' or '75' or '80' or '85' or '90' or '91' or '92' or '93' or '94' or '95' or '96' or '97' or '98' or '99' or '100'):
- #if ('.' in str(percent)): pCheck=int(str(percent).split('.')[0])
- #else: pCheck=percent
- #pCheck=int(str(percent)[1:])
- #if (CurrentPercent is not pCheck):
- # global CurrentPercent
- # CurrentPercent=pCheck
- # myNote(header=Header,msg=Message,delay=100,image=img)
- ##myNote(header=Header,msg=Message,delay=1,image=img)
- except:
- percent=100
- if (download_method=='Progress'): ## For Frodo and earlier.
- t=''
- dlg.update(percent)
- elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
- t=''
- dlg.update(percent)
- elif (download_method=='Test'): t=''
- #myNote(header='100%',msg='Download Completed',delay=15000,image=img)
- elif (download_method=='Hidden'): t=''
- if (download_method=='Progress'): ## For Frodo and earlier.
- line1 = '%.02f MB of %.02f MB' % (currently_downloaded, total)
- line1 +=' '+str(percent)+'%'
- line2 = 'Speed: %.02f Kb/s ' % kbps_speed
- line3 = 'ETA: %02d:%02d' % divmod(eta, 60)
- dlg.update(percent, line1, line2, line3)
- elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
- line1 ='%.02f MB of %.02f MB' % (currently_downloaded, total)
- line1 +=' '+str(percent)+'%'
- line2 ='Speed: %.02f Kb/s ' % kbps_speed
- line2 +='ETA: %02d:%02d' % divmod(eta, 60)
- dlg.update(percent, line1, line2)
- elif (download_method=='Test'):
- mbs = '%.02f MB of %.02f MB' % (currently_downloaded, total)
- spd = 'Speed: %.02f Kb/s ' % kbps_speed
- est = 'ETA: %02d:%02d' % divmod(eta, 60)
- Header= ext+' '+mbs+' '+str(percent)+'%'
- Message= est+' '+spd
- elif (download_method=='Hidden'): t=''
- if (download_method=='Progress'): ## For Frodo and earlier.
- try:
- if dlg.iscanceled(): ## used for xbmcgui.DialogProgress() but causes an error with xbmcgui.DialogProgressBG()
- dlg.close()
- #deb('Download Error','Download canceled.'); myNote('Download Error','Download canceled.')
- #raise StopDownloading('Stopped Downloading')
- except: t=''
- elif (download_method=='ProgressBG'): ## Only works on daily build of XBMC.
- try:
- if (dlg.isFinished()):
- dlg.close()
- except: t=''
- def DownloadRequest(section, url,img,LabelName):
- if (LabelName=='') and (_param['title'] is not ''): LabelName==_param['title']
- if (LabelName=='') and (_param['showtitle'] is not ''): LabelName==_param['showtitle']
- LabelFile=clean_filename(LabelName)
- deb('LabelName',LabelName)
- if (LabelName==''): deb('Download Error','Missing Filename String.'); myNote('Download Error','Missing Filename String.'); return
- if (section==ps('section.wallpaper')): FolderDest=xbmc.translatePath(addst("download_folder_wallpapers"))
- elif (section==ps('section.tv')): FolderDest=xbmc.translatePath(addst("download_folder_tv"))
- elif (section==ps('section.movie')): FolderDest=xbmc.translatePath(addst("download_folder_movies"))
- else: FolderDest=xbmc.translatePath(addst("download_folder_movies"))
- if os.path.exists(FolderDest)==False: os.mkdir(FolderDest)
- if os.path.exists(FolderDest):
- if (section==ps('section.tv')) or (section==ps('section.movie')):
- ### param >> url: /link/show/1466546/
- match=re.search( '/.+?/.+?/(.+?)/', url) ## Example: http://www.solarmovie.so/link/show/1052387/ ##
- videoId=match.group(1); deb('Solar ID',videoId); url=BASE_URL + '/link/play/' + videoId + '/' ## Example: http://www.solarmovie.so/link/play/1052387/ ##
- html=net.http_GET(url).content; match=re.search( '<iframe.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL); link=match.group(1); link=link.replace('/embed/', '/file/'); deb('hoster link',link)
- try: stream_url = urlresolver.HostedMediaFile(link).resolve()
- except: stream_url=''
- ext=Download_PrepExt(stream_url,'.flv')
- else:
- stream_url=url
- ext=Download_PrepExt(stream_url,'.jpg')
- t=1; c=1
- if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext))):
- t=LabelFile
- while t==LabelFile:
- if os.path.isfile(xbmc.translatePath(os.path.join(FolderDest,LabelFile+'['+str(c)+']'+ext)))==False:
- LabelFile=LabelFile+'['+str(c)+']'
- c=c+1
- start_time = time.time()
- deb('start_time',str(start_time))
- download_method=addst('download_method') ### 'Progress|ProgressBG|Hidden'
- urllib.urlcleanup()
- if (download_method=='Progress'):
- dp=xbmcgui.DialogProgress(); dialogType=12 ## For Frodo and earlier.
- dp.create('Downloading', LabelFile+ext)
- urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
- myNote('Download Complete',LabelFile+ext,15000)
- elif (download_method=='ProgressBG'):
- dp=xbmcgui.DialogProgressBG(); dialogType=13 ## Only works on daily build of XBMC.
- dp.create('Downloading', LabelFile+ext)
- urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
- myNote('Download Complete',LabelFile+ext,15000)
- elif (download_method=='Test'):
- dp=xbmcgui.DialogProgress()
- myNote('Download Started',LabelFile+ext,15000)
- urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
- myNote('Download Complete',LabelFile+ext,15000)
- elif (download_method=='Hidden'):
- dp=xbmcgui.DialogProgress()
- myNote('Download Started',LabelFile+ext,15000)
- urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
- myNote('Download Complete',LabelFile+ext,15000)
- elif (download_method=='jDownloader (StreamURL)'):
- myNote('Download','sending to jDownloader plugin',15000)
- xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % stream_url)
- #return
- elif (download_method=='jDownloader (Link)'):
- myNote('Download','sending to jDownloader plugin',15000)
- xbmc.executebuiltin("XBMC.RunPlugin(plugin://plugin.program.jdownloader/?action=addlink&url=%s)" % link)
- #return
- else: deb('Download Error','Incorrect download method.'); myNote('Download Error','Incorrect download method.'); return
- ##
- ##urllib.urlretrieve(stream_url, xbmc.translatePath(os.path.join(FolderDest,LabelFile+ext)), lambda nb, bs, fs: DownloadStatus(nb, bs, fs, dp, download_method, start_time, section, url, img, LabelName, ext, LabelFile)) #urllib.urlretrieve(url, localfilewithpath)
- ##
- #myNote('Download Complete',LabelFile+ext,15000)
- ##
- #### xbmc.translatePath(os.path.join(FolderDest,localfilewithpath+ext))
- _addon.resolve_url(url)
- _addon.resolve_url(stream_url)
- #
- #
- else: deb('Download Error','Unable to create destination path.'); myNote('Download Error','Unable to create destination path.'); return
- def PlayTrailer(url,_title,_year,_image): ### Not currently used ###
- WhereAmI('@ PlayVideo: %s' % url) #; sources=[]; url=url.decode('base-64')
- #if ('<h2>Movie trailer</h2>' not in url): eod(); return
- EmbedID=''; html=net.http_GET(url).content #getURL(url)
- html=messupText(html,True,True,True,False)
- #print str(html)
- if ('traileraddict.com/emd/' in html):
- deb('Found','traileraddict.com/emd/')
- #EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
- try: EmbedID=re.compile('traileraddict.com/emd/(\d+)"', re.DOTALL).findall(html)[0].strip()
- except: EmbedID=''
- if (EmbedID==''):
- #print html
- #ImdbID=re.compile('<strong>IMDb ID:</strong>[\n]\s+<a href=".+?">(\d+)</a>"', re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- try: ImdbID=re.compile('%2Ftitle%2Ftt(\d+)%2F"', re.DOTALL).findall(html)[0].strip()
- except: ImdbID=''
- if (ImdbID==''): eod(); deb('Error Playing Trailer','No Imdb ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
- deb('ImdbID',ImdbID)
- thtml=getURL('http://api.traileraddict.com/?imdb='+ImdbID)
- try: EmbedID=re.compile('"http://www.traileraddict.com/emd/([0-9]+)"', re.DOTALL).findall(thtml)[0].strip()
- except: EmbedID=''
- if (EmbedID==''): eod(); deb('Error Playing Trailer','No Embed Video ID.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
- deb('EmbedID',EmbedID)
- vhtml=getURL('http://www.traileraddict.com/fvar.php?tid='+EmbedID) #vhtml=getURL('http://www.traileraddict.com/fvarhd.php?tid='+EmbedID)
- #print vhtml
- if ('Error: Trailer is (Possibly Temporarily) Unavailable' in vhtml): deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
- try: thumb=re.compile('&image=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
- except: thumb=_param['img']
- try: title=re.compile('&filmtitle=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
- except: title=_param['title']
- try: url=re.compile('&fileurl=(.+?)&', re.DOTALL).findall(vhtml)[0].strip()
- except:
- try: url=re.compile('&fileurl=(.+?)[\n]\s+&', re.DOTALL).findall(vhtml)[0].strip()
- except: url=''
- if (url==''): eod(); deb('Error Playing Trailer','No Url was found from vhtml.'); deadNote('Problem with the Trailer','Trailer is Unavailable.'); return
- url=urllib.unquote_plus(url)
- deb('video',url)
- liz=xbmcgui.ListItem(_param['showtitle'], iconImage=thumb, thumbnailImage=_image)
- liz.setInfo( type="Video", infoLabels={ "Title": title, "Studio": _title+' ('+_year+')' } )
- liz.setProperty("IsPlayable","true")
- play=xbmc.Player(xbmc.PLAYER_CORE_AUTO) ### xbmc.PLAYER_CORE_AUTO | xbmc.PLAYER_CORE_DVDPLAYER | xbmc.PLAYER_CORE_MPLAYER | xbmc.PLAYER_CORE_PAPLAYER
- play.play(url, liz)
- #liz.setPath(url)
- #xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
- _addon.resolve_url(url)
- #eod(); return
- ##### /\ ##### Player Functions #####
- ### ############################################################################################################
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Weird, Stupid, or Plain up Annoying Functions. #####
- def netURL(url): ### Doesn't seem to work.
- return net.http_GET(url).content
- def remove_accents(input_str): ### Not even sure rather this one works or not.
- #nkfd_form = unicodedata.normalize('NFKD', unicode(input_str))
- #return u"".join([c for c in nkfd_form if not unicodedata.combining(c)])
- return input_str
- ##### /\ ##### Weird, Stupid, or Plain up Annoying Functions. #####
- ### ############################################################################################################
- ### ############################################################################################################
- ### ############################################################################################################
- ##### Menus #####
- def Trailers_Genres(section, url):
- WhereAmI('@ the Genre Menu for Trailers')#print 'Browse by genres screen'
- browsebyImg=checkImgLocal(art('genre','.jpg'))
- pathA='http://www.solarmovie.so/coming-soon/'; pathC=''#'/#coming-soon'
- if ('popularity' in url): pathB='popularity/'
- elif ('date' in url): pathB='date/'
- else: eod(); return
- TrailersGNERES=ps('Trailers.GENRES')
- ItemCount=len(TrailersGNERES) # , total_items=ItemCount
- for genre in TrailersGNERES:
- img=''; imgName=genre #; pre='http://icons.iconarchive.com/icons/sirubico/movie-genre/128/'
- if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.primal','extras','moviegenresposter',imgName+'.jpg'))
- if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','skin.tangency','extras','moviegenresposter',imgName+'.jpg'))
- if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','PrimeWire',imgName+'.png'))
- if (img==''): img=checkImgLocal(os.path.join(ps('special.home'),'addons','plugin.video.1channel','art','themes','Glossy_Black',imgName+'.png'))
- if (img=='') and (browsebyImg is not ''): img=browsebyImg
- if (img==''): img=_artSun
- if (genre.lower()=='all'): url=pathA+pathB+('')+pathC
- else: url=pathA+pathB+(genre.lower())+pathC
- _addon.add_directory({'section': section,'mode': 'TrailersList','url': url,'genre': genre,'bygenre': genre }, {'title': genre},img=img,fanart=_artFanart, total_items=ItemCount)
- set_view('list',addst('default-view')); eod()
- def mGetItemPage(url):
- deb('Fetching html from Url',url)
- try: html=net.http_GET(url).content
- except: html=''
- if (html=='') or (html=='none') or (html==None) or (html==False): return ''
- else:
- html=HTMLParser.HTMLParser().unescape(html); html=_addon.decode(html); html=_addon.unescape(html); html=ParseDescription(html); html=html.encode('ascii', 'ignore'); html=html.decode('iso-8859-1'); deb('Length of HTML fetched',str(len(html)))
- return html
- def mGetDataTest(html,toGet): ## For Testing Only
- resultCnt=0; results={}; debob(toGet)
- for item in toGet:
- parseTag='<p id="plot_\d+">(.+?)</p>'; item=item.lower()
- results[item]=(re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip()
- return results
- def mGetDataPlot(html,parseTag='<p id=\"plot_\d+\">(.+?)</p>'): ## Working Temp-Fix
- if ('<p id="plot_' in html):
- try: return (re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0]).strip()
- except: return ''
- else: return ''
- def mGetDataGroup2String(html,parseTag='',ifTag='',startTag='',endTag='',Topic=''):
- if (ifTag in html):
- html=(((html.split(startTag)[1])).split(endTag)[0]).strip()
- try: results=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
- except: return ''
- i=0; r=''
- for result in results:
- if (i==0): r=result.strip()
- else: r=r+', '+result.strip()
- i=i+1
- deb(Topic,r); return r
- else: return ''
- 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.
- return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
- 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.
- return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
- 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.
- return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
- 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.
- return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
- 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.
- return mGetDataGroup2String(html,parseTag,ifTag,startTag,endTag,Topic)
- def mdGetTV(html,toGet):
- resultCnt=0; results={}; debob(toGet)
- for item in toGet:
- item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; parsePreResult=''; rCheck=False
- if (item=='result.url'): ###
- 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">'
- if ('>English</td>' in html): rCheck=True
- elif (item=='result.id'): ###
- parseMethod='re.compile'; parseTag='<tr><td class="\D+">\d+</td>.+?href="/index.php.+?tab=series.+?id=(\d+)&lid=7">' ## & 's were parsed out earlier. ##
- if ('>English</td>' in html): rCheck=True
- elif (item=='fanart'): ###
- 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>'
- if ('" target="_blank">View Full Size</a></td></tr>' in html): rCheck=True
- elif (item=='thetvdb.episode.overviews'): ###
- parseMethod='split'; parseTag='<td>Overview: </td>'; parseTag2='</tr>'; deb('get item',item)
- if ('<td>Overview: </td>' in html): rCheck=True
- elif (item=='thetvdb.episode.overview1'): ###
- parseMethod='split'; parseTag='<textarea rows="10" cols="45" name="Overview_7" style="display: inline">'; parseTag2='</textarea>'; deb('get item',item)
- if ('<td>Overview: </td>' in html): rCheck=True
- elif (item=='thetvdb.episode.overview'): ###
- parseMethod='re.compile'; parseTag='<textarea rows="10" cols="45" name="Overview_7" style="display: inline">(.+?)</textarea>'; deb('get item',item)
- if ('<td>Overview: </td>' in html): rCheck=True
- #else: rCheck=False
- #if (rCheck==False): print html
- deb('rCheck',str(rCheck))
- if (rCheck==True): ## Trying to do away with errors for results that dont contain the requested information.
- if (parseMethod=='re.compile2'): ## returns 2nd result
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[1].strip()
- if (results[item]==''): results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- elif (parseMethod=='re.compile'): ## returns 1st result
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- elif (parseMethod=='re.compile.fanart'): ## returns 1st result
- resultCnt=resultCnt+1; html2=(html.split('<h1>Fan Art</h1>')[1]).split('</table>')[0]
- if ('View Full Size' in html2): results[item]=parsePreResult+re.compile(parseTag, re.IGNORECASE | re.DOTALL).findall(html2)[0].strip()
- else: results[item]=''
- elif (parseMethod=='re.compile.prefix'): ## returns 1st result
- try: results[item]=parsePreResult+re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- except: results[item]=''
- resultCnt=resultCnt+1
- elif (parseMethod=='re.compile.group'): ## returns a group of results
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
- elif (parseMethod=='split'):
- resultCnt=resultCnt+1; results[item]=(((html.split(parseTag)[1])).split(parseTag2)[0]).strip()
- elif (parseMethod=='re.search2'): ## returns 2nd result
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(2)
- elif (parseMethod=='re.search'): ## returns 1st result
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(1)
- elif (parseMethod=='re.search.group'): ## returns a group of results
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group()
- else:
- resultCnt=resultCnt+1; results[item]=''
- else:
- resultCnt=resultCnt+1; results[item]=''
- if debugging==True: print results
- return results
- def mdGetSplitFindGroup(html,ifTag='', parseTag='',startTag='',endTag=''):
- if (ifTag=='') or (parseTag=='') or (startTag=='') or (endTag==''): return ''
- if (ifTag in html):
- html=(((html.split(startTag)[1])).split(endTag)[0]).strip()
- try: return re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
- except: return ''
- else: return ''
- def mdGetMovie(html,toGet):
- resultCnt=0; results={}; debob(toGet)
- for item in toGet:
- item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; parsePreResult=''; rCheck=False
- if (item=='result.poster'): ###
- parseTag='<div class="poster">[\n]\s+<a href=".+?" title=".+?"><img class="right_shadow" src="(.+?)" width="\d+" height="\d+" /></a>'
- parseMethod='re.compile'
- if ('<div class="poster">' in html): rCheck=True
- elif (item=='result.url'): ###
- parsePreResult=_setting['meta.movie.domain']
- parseTag='<div class="poster">[\n]\s+<a href="(.+?)" title=".+?"><img class="right_shadow" src=".+?" width="\d+" height="\d+" /></a>'
- parseMethod='re.compile.prefix'
- if ('<div class="poster">' in html): rCheck=True
- elif (item=='og.image'): ###
- parseTag='<meta property="og:image" content="(.+?)" />'
- parseMethod='re.compile'
- if ('<meta property="og:image" content="' in html): rCheck=True
- elif (item=='og.image2'): ###
- parseTag='<meta property="og:image" content="(.+?)" />'
- parseMethod='re.compile2'
- if ('<meta property="og:image" content="' in html): rCheck=True
- elif (item=='og.plot'): ###
- parseTag='<meta property="og:description" content="(.+?)" />'
- parseMethod='re.compile'
- if ('<meta property="og:description" content="' in html): rCheck=True
- #if (item=='fanart'): ###
- # parseTag='<strong>IMDb rating:</strong>[\n]\s+(.+?)\s+\(.+? votes\)'
- # parseMethod='re.compile.group'
- # if ('<strong>IMDb rating:</strong>' in html): rCheck=True
- #else: rCheck=False
- deb('rCheck',str(rCheck))
- if (rCheck==True): ## Trying to do away with errors for results that dont contain the requested information.
- if (parseMethod=='re.compile2'): ## returns 2nd result
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[1].strip()
- if (results[item]==''): results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- elif (parseMethod=='re.compile'): ## returns 1st result
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- elif (parseMethod=='re.compile.prefix'): ## returns 1st result
- resultCnt=resultCnt+1; results[item]=parsePreResult+re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)[0].strip()
- elif (parseMethod=='re.compile.group'): ## returns a group of results
- resultCnt=resultCnt+1; results[item]=re.compile(parseTag, re.MULTILINE | re.IGNORECASE | re.DOTALL).findall(html)
- elif (parseMethod=='split'):
- resultCnt=resultCnt+1; results[item]=(((html.split(parseTag)[1])).split(parseTag2)[0]).strip()
- elif (parseMethod=='re.search2'): ## returns 2nd result
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(2)
- elif (parseMethod=='re.search'): ## returns 1st result
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group(1)
- elif (parseMethod=='re.search.group'): ## returns a group of results
- resultCnt=resultCnt+1; match=re.search(parseTag, html, re.IGNORECASE | re.MULTILINE | re.DOTALL); results[item]=match.group()
- else:
- resultCnt=resultCnt+1; results[item]=''
- else:
- resultCnt=resultCnt+1; results[item]=''
- if debugging==True: print results
- return results
- def mGetData(html,toGet):
- #if (html=='') or (html=='none') or (html==None) or (html==False):
- # deb('mGetData','html is empty')
- # return None
- resultCnt=0; results={}; debob(toGet)
- for item in toGet:
- item=item.lower();parseMethod=''; parseTag=''; parseTag2=''; parseTag3=''; rCheck=False
- if (item=='plot') or (item=='movieplot') or (item=='showplot'): ###
- parseTag='<p id="plot_\d+">(.+?)</p>'
- parseMethod='re.compile'
- if ('<p id="plot_' in html):
- rCheck=True; deb("found","'<p id=\"plot_'")
- elif (item=='imdbrating'): ### 7.3
- parseMethod='re.compile'; parseTag='<strong>IMDb rating:</strong>[\n]\s+(.+?)\s+\(.+? votes\)'
- if ('<strong>IMDb rating:</strong>' in html): rCheck=True
- elif (item=='episodeplot'): ###
- parseMethod='re.compile2'; parseTag='<p id="plot_\d+">(.+?)</p>'
- if ('<p id="plot_' in html): rCheck=True
- elif (item=='latestepisodeplot'): ###
- parseMethod='re.compile2'; parseTag='<p id="plot_\d+">(.+?)</p>'
- if ('<p id="plot_' in html): rCheck=True
- elif (item=='imdbid'): ### 0816711
- parseMethod='re.compile'; parseTag='<strong>IMDb ID:</strong>[\n]\s+<a href=".+?">(\d+)</a>'
- if ('<strong>IMDb ID:</strong>' in html): rCheck=True
- elif (item=='imdburl'): ### http://anonym.to/?http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt0816711%2F
- parseMethod='re.compile'; parseTag='<strong>IMDb ID:</strong>[\n]\s+<a href="(.+?)">\d+</a>'
- if ('<strong>IMDb ID:</strong>' in html): rCheck=True
- elif (item=='imdbvotes'): ### 2,814
- parseMethod='re.compile'; parseTag='<strong>IMDb rating:</strong>[\n]\s+.+?\s+\((.+?) votes\)'
- if ('<strong>IMDb rating:</strong>' in html): rCheck=True
- elif (item=='duration'): ### 116 min
- parseMethod='re.compile'; parseTag='<strong>Duration:</strong>[\n]\s+(.+?)<'
- if ('<strong>Duration:</strong>' in html): rCheck=True
- elif (item=='duration2'):
- parseMethod='strip'; parseTag='<strong>Duration:</strong>'; parseTag2='<'
- if ('<strong>Duration:</strong>' in html): rCheck=True
- elif (item=='premiered'): ### June 21, 2013
- parseMethod='re.compile'; parseTag='<strong>Release Date:</strong>[\n]\s+(.+?)\s+[\n]\s+</div>'
- if ('<strong>Release Date:</strong>' in html): rCheck=True
- elif (item=='premiered2'):
- parseMethod='strip'; parseTag='<strong>Release Date:</strong>'; parseTag2='<'
- if ('<strong>Release Date:</strong>' in html): rCheck=True
- elif (item=='reelasedate'): ### June 21, 2013
- parseMethod='re.compile'; parseTag='<strong>Release Date:</strong>[\n]\s+(.+?)\s+[\n]\s+</div>'
- if ('<strong>Release Date:</strong>' in html): rCheck=True
- elif (item=='reelasedate2'):
- parseMethod='strip'; parseTag='<strong>Release Date:</strong>'; parseTag2='<'
- if ('<strong>Release Date:</strong>' in html): rCheck=True
- elif (item=='Votes'): ### 86
- parseMethod='re.compile'; parseTag='<strong>Solar rating:</strong>[\n]\s+<span class="js-votes"[\n]\s+>(\d+\s+votes</span>'
- if ('<strong>Solar rating:</strong>' in html) and ('<span class="js-votes"' in html) and ('votes</span>' in html): rCheck=True
- elif (item=='coverimage'): ### http://static.solarmovie.so/images/movies/0460681_150x220.jpg
- parseMethod='re.search'; parseTag='coverImage">.+?src="(.+?)"'
- if ('coverImage">' in html): rCheck=True
- elif (item=='season'): ###
- parseMethod='re.search'; parseTag="toggleSeason\('(\d+)'\)"
- if ('toggleSeason' in html): rCheck=True
- elif (item=='seasons'): ###
- parseMethod='re.search.group'; parseTag="toggleSeason\('(\d+)'\)"
- if ('toggleSeason' in html): rCheck=True
- elif (item=='episode'): ###
- 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>'
- if ('<span class="epname">' in html) and (' links</a>' in html): rCheck=True
- elif (item=='episodes'): ###
- 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>'
- if ('<span class="epname">' in html): rCheck=True
- else: rCheck=False
- ### Year
- # Fantasy</a> produced in
- # <a href="/tv/watch-tv-shows-2005.html">
- # 2005</a>
- ### Country
- # [<a href="/tv/tv-shows-from-usa.html">USA</a>]
- ### Latest Episode
- # <div class="mediaDescription latestTvEpisode">
- # <h5>Latest Episode:
- # <a href="/tv/supernatural-2005/season-8/episode-23/">
- # Sacrifice (<span>s08e23</span>)</a>
- # <em class="releaseDate">May 15, 2013</em>
- # </h5>
- #<p id="plot_476403">Sam and De…
Large files files are truncated, but you can click here to view the full file