def tv_db_series_lookup(seriesname,manualsearch=False): tv_api_key = '03B8C17597ECBD64' mirror = 'http://thetvdb.com' banners = 'http://thetvdb.com/banners/' try: print 'intial search' series_lookup = 'http://www.thetvdb.com/api/GetSeries.php?seriesname='+urllib.quote_plus(seriesname) seriesid = common.getURL(series_lookup) seriesid = get_series_id(seriesid,seriesname) except: try: print 'strip search' series_lookup = 'http://www.thetvdb.com/api/GetSeries.php?seriesname='+urllib.quote_plus(seriesname.split('(')[0].split(':')[0].strip()) seriesid = common.getURL(series_lookup) seriesid = get_series_id(seriesid,seriesname) except: if manualsearch: print 'manual search' keyb = xbmc.Keyboard(seriesname, 'Manual Search') keyb.doModal() if (keyb.isConfirmed()): try: series_lookup = 'http://www.thetvdb.com/api/GetSeries.php?seriesname='+urllib.quote_plus(keyb.getText()) seriesid = common.getURL(series_lookup) seriesid = get_series_id(seriesid,seriesname) except: print 'manual search failed' return None,None,None,None,None,None else: return None,None,None,None,None,None if seriesid: return tv_db_id_lookup(seriesid,seriesname) else: return None,None,None,None,None,None
def PLAYEXTRA(): data = common.getURL(common.args.url) print data smilurl = re.compile("playlist:.*?'(.*?)',").findall(data)[0] data = common.getURL(smilurl) tree = BeautifulStoneSoup(data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) print tree.prettify() videourl = tree.find('video')['src'] item = xbmcgui.ListItem(path=videourl) xbmcplugin.setResolvedUrl(pluginhandle, True, item)
def MOVIE_VIDEOS(): xbmcplugin.setContent(pluginhandle, 'Movies') url = BASE + common.args.url data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) try:fanart = tree.find('div',attrs={'class':'more-images wallpapers'}).find('img')['src'].replace('thumbs/','') except: try:fanart = re.compile("\('(.*?)'\)").findall(tree.find('div',attrs={'id':'playerposter'})['style'])[0] except:fanart = '' checkdata = common.getURL('http://www.epixhd.com/epx/ajax/theater/soloplayer'+common.args.url) if 'This movie is not currently playing on EPIX' not in data and 'outofwindow' not in checkdata: movie_id = re.compile('csa_movie_id = "movie_(.*?)";').findall(data)[0] inqueue = CHECK_QUEUE(movie_id) movietitle = tree.find('h1',attrs={'class':'movie_title'}).string try: plot = tree.find('div',attrs={'class':'synP'}).renderContents() tags = re.compile(r'<.*?>') plot = tags.sub('', plot).strip() except: plot = '' mpaa = tree.find('span',attrs={'id':'rating'})['class'] metadata = tree.find('span',attrs={'class':'genres'}).findAll('span',recursive=False) genredata = tree.find('span',attrs={'class':'genres'}).findAll('a') genre = '' for item in genredata: genre +=item.string+',' genre = genre[:-1] if len(metadata) == 3: year = int(tree.find('span',attrs={'class':'genres'}).contents[0].strip()) runtime = metadata[1].string.replace('mins','').strip() else: year = int(metadata[0].string) runtime = metadata[2].string.replace('mins','').strip() try: poster = tree.find('div',attrs={'class':'more-images posters'}).find('img')['src'].replace('thumbs/','') except: poster = '' infoLabels={ "Title": movietitle, 'plot':plot, 'mpaa':mpaa, 'duration':runtime, 'year':year, 'genre':genre} common.addVideo('Play Movie: '+movietitle,common.args.url,poster,fanart,infoLabels=infoLabels) if inqueue: common.addDir('Remove from Queue','movie','REMOVE_QUEUE',movie_id,poster,fanart,infoLabels=infoLabels) else: common.addDir('Add to Queue','movie','ADD_QUEUE',movie_id,poster,fanart,infoLabels=infoLabels) for item in tree.findAll('div',attrs={'class':re.compile('more-videos ')}): name = item.find('h5').string thumb = item.find('img')['src'].replace('thumbs/','') common.addDir(name,'movie','MOVIE_EXTRAS',url,thumb,fanart) #view=int(common.addon.getSetting("movieview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[3])+")") xbmcplugin.endOfDirectory(pluginhandle)
def LIST_FEATURE(): data = common.getURL(BASE) url = BASE + re.compile('flashvars.xmlPath = "(.*?)";').findall(data)[0] data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.findAll('movie'): url = item.find('moviepage').string name = item.find('title').string thumb = item.find('poster').string common.addDir(name, 'movie', 'MOVIE_VIDEOS', url, thumb) #common.addVideo(name,url,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_FEATURE(): data = common.getURL(BASE) url = BASE + re.compile('flashvars.xmlPath = "(.*?)";').findall(data)[0] data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.findAll('movie'): url = item.find('moviepage').string name = item.find('title').string thumb = item.find('poster').string common.addDir(name,'movie','MOVIE_VIDEOS',url,thumb) #common.addVideo(name,url,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def PLAYVIDEO(): #common.login() #orgin = 'http://dish.epixhd.com/epx/ajax/user/originstatus/' #print common.getURL(orgin,useCookie=True) #pageurl = 'http://www.epixhd.com/epx/ajax/theater/soloplayer'+common.args.url #print common.getURL(pageurl,useCookie=True) smilurl = 'http://www.epixhd.com/epx/smil'+common.args.url+'smil.xml' data = common.getURL(smilurl,useCookie=True) authurl = 'http://www.epixhd.com/epx/ajax/theater/getToken/?movie='+common.args.url.strip('/') auth = common.getURL(authurl,useCookie=True) tree = BeautifulStoneSoup(data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) print tree.prettify() stackedUrl = 'stack://' if common.addon.getSetting("enablepreroll") == 'true': for preroll in tree.find('img').findAll('video',recursive=False): stackedUrl += buildrtmp(preroll['src'],auth).replace(',',',,')+' , ' quality = [0,3000000,2200000,1700000,1200000,900000,500000] lbitrate = quality[int(common.addon.getSetting("bitrate"))] mbitrate = 0 streams = [] movie_name = tree.find('mbrstream')['ma:asset_name'] common.args.asset_id = tree.find('mbrstream')['ma:asset_id'] for item in tree.find('mbrstream').findAll('video'): url = item['src'] bitrate = int(item['system-bitrate']) if lbitrate == 0: streams.append([bitrate/1000,url]) elif bitrate >= mbitrate and bitrate <= lbitrate: mbitrate = bitrate rtmpdata = url if lbitrate == 0: quality=xbmcgui.Dialog().select('Please select a quality level:', [str(stream[0])+'kbps' for stream in streams]) if quality!=-1: rtmpdata = streams[quality][1] else: return stackedUrl += buildrtmp(rtmpdata,auth).replace(',',',,') #p=ResumePlayer() item = xbmcgui.ListItem(path=stackedUrl) #item.setInfo( type="Video", infoLabels={"Title": movie_name}) xbmcplugin.setResolvedUrl(pluginhandle, True, item) #while not p.isPlaying(): # print 'EPIX --> Not Playing' # xbmc.sleep(100) #p.onPlayBackStarted()
def LIST_COLLECTIONS(): data = common.getURL(BASE) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.findAll('a', attrs={'class': 'showhomepagestunt'}): name = item.string common.addDir(name, 'listmovie', 'LIST_STUNT', item['stunt_id']) xbmcplugin.endOfDirectory(pluginhandle)
def LIBRARY_LIST_TV(): url = common.args.url data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'lib-item','asin':True}) totalItems = len(videos) ASINS='' for video in videos: asin = video['asin'] #appfeed.ADD_SEASON(asin,'library','LIBRARY_EPISODES',isPrime=False) if common.addon.getSetting("watchlist_tv_view") == '0': appfeed.ADD_SEASON(asin,'library','LIBRARY_EPISODES',isPrime=False,addSeries=True) elif common.addon.getSetting("watchlist_tv_view") == '1': asin1,asin2 = appfeed.ADD_SEASON_SERIES(asin,'library','LIBRARY_LIST_SEASONS',isPrime=True,checklist=ASINS) if asin1: ASINS += asin1 if asin2: ASINS += asin2 xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable=common.addon.getSetting("viewenable") if viewenable == 'true': view=int(common.addon.getSetting("showview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")")
def WATCHLIST_LIST_TV(export=False): if export: xbmclibrary.SetupLibrary() url = 'https://www.amazon.com/gp/video/watchlist/tv?show=all&sort=DATE_ADDED' data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'innerItem','id':True}) totalItems = len(videos) ASINS = '' for video in videos: asin = video['id'] if export: xbmclibrary.EXPORT_SEASON(asin) else: if common.addon.getSetting("watchlist_tv_view") == '0': appfeed.ADD_SEASON(asin,isPrime=True,inWatchlist=True,addSeries=True) elif common.addon.getSetting("watchlist_tv_view") == '1': asin1,asin2 = appfeed.ADD_SEASON_SERIES(asin,'library','WATCHLIST_LIST_SEASONS',isPrime=True,checklist=ASINS) if asin1: ASINS += asin1 if asin2: ASINS += asin2 if not export: xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable=common.addon.getSetting("viewenable") if viewenable == 'true': view=int(common.addon.getSetting("showview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")")
def getTVTree(url): data = common.getURL(url) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) atf = tree.find(attrs={'id': 'atfResults'}) if atf == None: print tree.prettify() return False atf = tree.find(attrs={'id': 'atfResults'}).findAll('div', recursive=False) try: btf = tree.find(attrs={ 'id': 'btfResults' }).findAll( 'div', recursive=False) atf.extend(btf) del btf except: print 'AMAZON: No btf found' nextpage = tree.find(attrs={ 'title': 'Next page', 'id': 'pagnNextLink', 'class': 'pagnNext' }) del data return atf, nextpage
def GETFLASHVARS(pageurl): showpage = common.getURL(pageurl,useCookie=True) flashVars = re.compile("'flashVars', '(.*?)' \+ new Date\(\)\.getTime\(\)\+ '(.*?)'",re.DOTALL).findall(showpage) flashVars =(flashVars[0][0] + flashVars[0][1]).split('&') swfUrl = re.compile("avodSwfUrl = '(.*?)'\;").findall(showpage)[0] values={'token' :'', 'deviceTypeID' :'A13Q6A55DBZB7M', 'version' :'1', 'firmware' :'1', 'customerID' :'', 'format' :'json', 'deviceID' :'', 'asin' :'' } for item in flashVars: item = item.split('=') if item[0] == 'token': values[item[0]] = item[1] elif item[0] == 'customer': values['customerID'] = item[1] elif item[0] == 'ASIN': values['asin'] = item[1] elif item[0] == 'pageType': values['pageType'] = item[1] elif item[0] == 'UBID': values['UBID'] = item[1] elif item[0] == 'sessionID': values['sessionID'] = item[1] elif item[0] == 'userAgent': values['userAgent'] = item[1] return swfUrl, values
def tv_db_id_lookup(seriesid,seriesname): tv_api_key = '03B8C17597ECBD64' mirror = 'http://thetvdb.com' banners = 'http://thetvdb.com/banners/' if seriesid: series_xml = mirror+('/api/%s/series/%s/en.xml' % (tv_api_key, seriesid)) series_xml = common.getURL(series_xml) tree = BeautifulStoneSoup(series_xml, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) try: genre = tree.find('genre').string genre = genre.replace("|",",") genre = genre.strip(",") except: print '%s - Genre Failed' % seriesname genre = None try: aired = tree.find('firstaired').string except: print '%s - Air Date Failed' % seriesname aired = None try: banner = banners + tree.find('banner').string except: print '%s - Banner Failed' % seriesname banner = None try: fanart = banners + tree.find('fanart').string except: print '%s - Fanart Failed' % seriesname fanart = None try: poster = banners + tree.find('poster').string except: print '%s - Poster Failed' % seriesname poster = None return banner, poster, fanart, genre, aired, seriesid else: return None,None,None,None,None,None
def addMoviesdb(url=MOVIE_URL,isprime=True,singlepage=False): dialog = xbmcgui.DialogProgress() dialog.create('Refreshing Prime Movie Database') dialog.update(0,'Initializing Movie Scan') if not singlepage: data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) total = int(tree.find('div',attrs={'id':'resultCount','class':'resultCount'}).span.string.replace(',','').split('of')[1].split('Results')[0].strip()) del tree; del data else: total=12 pages = (total/12)+1 increment = 100.0 / pages page = 1 percent = int(increment*page) dialog.update(percent,'Scanning Page %s of %s' % (str(page),str(pages)),'Scanned %s of %s Movies' % (str((page-1)*12),str(total))) pagenext = scrapeMoviesdb(url,isprime) if not singlepage: while pagenext: page += 1 percent = int(increment*page) dialog.update(percent,'Scanning Page %s of %s' % (str(page),str(pages)),'Scanned %s of %s Movies' % (str((page-1)*12),str(total))) pagenext = scrapeMoviesdb(pagenext,isprime) if (dialog.iscanceled()): return False
def LIBRARY_LIST_TV(): url = common.args.url data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'lib-item','asin':True}) totalItems = len(videos) for video in videos: xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') asin = video['asin'] name = video.find('',attrs={'class':'title'}).a.string thumb = video.find('img')['src'].replace('._SS160_','') if '[HD]' in name: isHD = True else: isHD = False url = common.BASE_URL+video.find('div',attrs={'class':'title'}).a['href'] #if xbmcplugin.getSetting(pluginhandle,'enablelibrarymeta') == 'true': # asin2,season,episodes,plot,creator,runtime,year,network,actors,genres,stars,votes,HD,TVDBbanner,TVDBposter,TVDBfanart = getShowInfo(url,asin,isHD) # actors = actors.split(',') # infoLabels={'Title': name,'Plot':plot,'year':year,'rating':stars,'votes':votes, # 'Genre':genres,'Season':season,'episode':episodes,'studio':network, # 'duration':runtime,'cast':actors,'TVShowTitle':name,'credits':creator} # if year <> 0: infoLabels['premiered'] = str(year) #else: infoLabels = { 'Title':name} common.addDir(name,'library','LIBRARY_EPISODES',url,thumb,thumb,infoLabels,totalItems) viewenable=xbmcplugin.getSetting(pluginhandle,"viewenable") if viewenable == 'true': view=int(xbmcplugin.getSetting(pluginhandle,"showview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")") xbmcplugin.endOfDirectory(pluginhandle)
def LIST_COLLECTIONS(): data = common.getURL(BASE) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.findAll('a',attrs={'class':'showhomepagestunt'}): name = item.string common.addDir(name,'listmovie','LIST_STUNT',item['stunt_id']) xbmcplugin.endOfDirectory(pluginhandle)
def scrapeMoviesdb(url,isprime=True): data = common.getURL(url) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) atf = tree.find(attrs={'id':'atfResults'}).findAll('div',recursive=False) try: btf = tree.find(attrs={'id':'btfResults'}).findAll('div',recursive=False) atf.extend(btf) del btf except: print 'AMAZON: No btf found' nextpage = tree.find(attrs={'title':'Next page','id':'pagnNextLink','class':'pagnNext'}) del tree del data for movie in atf: asin = movie['name'] movietitle = movie.find('a', attrs={'class':'title'}).string poster = movie.find(attrs={'class':'image'}).find('img')['src'].replace('._AA160_','') url = common.BASE_URL+'/gp/product/'+asin print getMovieInfo(asin,movietitle,url,poster,isPrime=True) del atf if nextpage: pagenext = common.BASE_URL + nextpage['href'] del nextpage return pagenext else: return False
def LIST_EPISODES(owned=False): episode_url = common.BASE_URL + '/gp/product/' + common.args.url data = common.getURL(episode_url, useCookie=owned) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) episodes = tree.find('div', attrs={ 'id': 'avod-ep-list-rows' }).findAll('tr', attrs={'asin': True}) del tree for episode in episodes: if owned: purchasecheckbox = episode.find('input', attrs={'type': 'checkbox'}) if purchasecheckbox: continue asin = episode['asin'] appfeed.ADD_EPISODE(asin, isPrime=False) xbmcplugin.setContent(int(sys.argv[1]), 'Episodes') xbmcplugin.endOfDirectory(pluginhandle, updateListing=False) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting("episodeview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def GETFLASHVARS(pageurl): showpage = common.getURL(pageurl, useCookie=True) flashVars = re.compile( "'flashVars', '(.*?)' \+ new Date\(\)\.getTime\(\)\+ '(.*?)'", re.DOTALL).findall(showpage) flashVars = (flashVars[0][0] + flashVars[0][1]).split('&') swfUrl = re.compile("avodSwfUrl = '(.*?)'\;").findall(showpage)[0] values = { 'token': '', 'deviceTypeID': 'A13Q6A55DBZB7M', 'version': '1', 'firmware': '1', 'customerID': '', 'format': 'json', 'deviceID': '', 'asin': '' } for item in flashVars: item = item.split('=') if item[0] == 'token': values[item[0]] = item[1] elif item[0] == 'customer': values['customerID'] = item[1] elif item[0] == 'ASIN': values['asin'] = item[1] elif item[0] == 'pageType': values['pageType'] = item[1] elif item[0] == 'UBID': values['UBID'] = item[1] elif item[0] == 'sessionID': values['sessionID'] = item[1] elif item[0] == 'userAgent': values['userAgent'] = item[1] return swfUrl, values
def LIBRARY_LIST_SEASONS(): asin = common.args.url series = common.args.name url = 'https://www.amazon.com/gp/video/library/tv?show=all&sort=alpha' data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'lib-item', 'asin': True}) totalItems = len(videos) for video in videos: asin = video['asin'] appfeed.ADD_SEASON(asin, 'library', 'LIBRARY_EPISODES', isPrime=True, inWatchlist=False, seriesfilter=series) xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting("seasonview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def addTVdb(url=TV_URL,isprime=True): dialog = xbmcgui.DialogProgress() dialog.create('Building Prime TV Database') dialog.update(0,'Initializing TV Scan') data = common.getURL(url) try: tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) total = int(tree.find('div',attrs={'id':'resultCount','class':'resultCount'}).span.string.replace(',','').split('of')[1].split('Results')[0].strip()) except: total=12 del tree; del data pages = (total/12)+1 increment = 100.0 / pages page = 1 percent = int(increment*page) dialog.update(percent,'Scanning Page %s of %s' % (str(page),str(pages)),'Added %s Episodes' % str(0)) pagenext,episodetotal = scrapeTVdb(url,isprime) while pagenext: page += 1 percent = int(increment*page) dialog.update(percent,'Scanning Page %s of %s' % (str(page),str(pages)),'Added %s Episodes' % str(episodetotal)) pagenext,nextotal = scrapeTVdb(pagenext,isprime) episodetotal += nextotal if (dialog.iscanceled()): return False xbmc.sleep(2000) fixHDshows() fixGenres() fixYears()
def LIBRARY_LIST_MOVIES(): xbmcplugin.setContent(int(sys.argv[1]), 'Movies') url = common.args.url data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'lib-item','asin':True}) totalItems = len(videos) for video in videos: asin = video['asin'] movietitle = video.find('',attrs={'class':'title'}).a.string url = common.BASE_URL+video.find('div',attrs={'class':'title'}).a['href'] thumb = video.find('img')['src'].replace('._SS160_','') fanart = thumb.replace('.jpg','._BO354,0,0,0_CR177,354,708,500_.jpg') #if xbmcplugin.getSetting(pluginhandle,'enablelibrarymeta') == 'true': # asin2,movietitle,url,poster,plot,director,runtime,year,premiered,studio,mpaa,actors,genres,stars,votes,TMDBbanner,TMDBposter,TMDBfanart,isprime,watched,favor = getMovieInfo(asin,movietitle,url,poster,isPrime=False) # actors = actors.split(',') # infoLabels = { 'Title':movietitle,'Plot':plot,'Year':year,'premiered':premiered, # 'rating':stars,'votes':votes,'Genre':genres,'director':director, # 'studio':studio,'duration':runtime,'mpaa':mpaa,'cast':actors} #else: infoLabels = { 'Title':movietitle} common.addVideo(movietitle,url,thumb,fanart,infoLabels=infoLabels,totalItems=totalItems) viewenable=common.addon.getSetting("viewenable") if viewenable == 'true': view=int(xbmcplugin.getSetting(pluginhandle,"movieview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")") xbmcplugin.endOfDirectory(pluginhandle)
def WATCHLIST_LIST_MOVIES(export=False): if export: xbmclibrary.SetupLibrary() url = 'https://www.amazon.com/gp/video/watchlist/movie?show=all&sort=DATE_ADDED' data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'innerItem', 'id': True}) totalItems = len(videos) for video in videos: asin = video['id'] if export: xbmclibrary.EXPORT_MOVIE(asin) else: appfeed.ADD_MOVIE(asin, isPrime=True, inWatchlist=True) if not export: xbmcplugin.setContent(int(sys.argv[1]), 'Movies') xbmcplugin.endOfDirectory(pluginhandle) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting("movieview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def LIST_GENRE(): url = genreURL + '1/1/1/' data = common.getURL(url) jsondata = demjson.decode(data) for url, name in jsondata['all_items'].iteritems(): common.addDir(name, 'listmovie', 'LIST_GENRE_FILTERED', url) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_GENRE(): url = genreURL + '1/1/1/' data = common.getURL(url) jsondata = demjson.decode(data) for url,name in jsondata['all_items'].iteritems(): common.addDir(name,'listmovie','LIST_GENRE_FILTERED',url) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_ALPHA_FILTERED(): url = alphaURL + common.args.url + '/1/4000/' data = common.getURL(url) jsondata = demjson.decode(data) for movie in jsondata['content']: try: thumb = movie['movie_playerposter'].replace('thumbs/','') except: thumb = '' common.addDir(movie['movie_title'],'movie','MOVIE_VIDEOS',movie['movie_url'],thumb,thumb) #common.addVideo(movie['movie_title'],movie['movie_url'],thumb,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_ALPHA(): url = alphaURL + '1/1/1/' data = common.getURL(url) jsondata = demjson.decode(data) for url, name in jsondata['all_items'].iteritems(): if name == 'ALL': name = '(ALL)' common.addDir(name, 'listmovie', 'LIST_ALPHA_FILTERED', url) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_STUNT(id=common.args.url): url = 'http://www.epixhd.com/ajax/getstuntlimited/?stunt_id='+id+'&limit=72' data = common.getURL(url) jsondata = demjson.decode(data) for movie in jsondata['rs']: movie = jsondata['rs'][movie] print movie common.addDir(movie['title'],'movie','MOVIE_VIDEOS','/'+movie['short_name']+'/') #common.addVideo(movie['title'],'/'+movie['short_name']+'/') xbmcplugin.endOfDirectory(pluginhandle)
def LIST_ALPHA(): url = alphaURL + '1/1/1/' data = common.getURL(url) jsondata = demjson.decode(data) for url,name in jsondata['all_items'].iteritems(): if name == 'ALL': name = '(ALL)' common.addDir(name,'listmovie','LIST_ALPHA_FILTERED',url) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_POP(): url = 'http://www.epixhd.com/all-movies/' data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.find('div',attrs={'id':'am-top-posters'}).findAll('a'): url = item['href']+'/' name = item['href'].replace('/','').replace('-',' ').title() thumb = item.find('img')['src'].replace('thumbs/','') common.addDir(name,'movie','MOVIE_VIDEOS',url,thumb,thumb) #common.addVideo(name,url,thumb,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_QUEUE(): url = 'http://www.epixhd.com/epx/ajax/myqueue/' data = common.getURL(url,useCookie=True) jsondata = demjson.decode(data) for movie in jsondata['queue']: try: poster = movie['poster'].replace('thumbs/','') except: poster = '' try: fanart = movie['playerposter'].replace('thumbs/','') except: fanart = '' common.addDir(movie['title'],'movie','MOVIE_VIDEOS','/'+movie['short_name']+'/',poster,fanart) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_POP(): url = 'http://www.epixhd.com/all-movies/' data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) for item in tree.find('div', attrs={'id': 'am-top-posters'}).findAll('a'): url = item['href'] + '/' name = item['href'].replace('/', '').replace('-', ' ').title() thumb = item.find('img')['src'].replace('thumbs/', '') common.addDir(name, 'movie', 'MOVIE_VIDEOS', url, thumb, thumb) #common.addVideo(name,url,thumb,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def LIST_STUNT(id=common.args.url): url = 'http://www.epixhd.com/ajax/getstuntlimited/?stunt_id=' + id + '&limit=72' data = common.getURL(url) jsondata = demjson.decode(data) for movie in jsondata['rs']: movie = jsondata['rs'][movie] print movie common.addDir(movie['title'], 'movie', 'MOVIE_VIDEOS', '/' + movie['short_name'] + '/') #common.addVideo(movie['title'],'/'+movie['short_name']+'/') xbmcplugin.endOfDirectory(pluginhandle)
def GETTRAILERS(getstream): try: data = common.getURL(getstream,'atv-ps.amazon.com') print data rtmpdata = demjson.decode(data) print rtmpdata sessionId = rtmpdata['message']['body']['streamingURLInfoSet']['sessionId'] cdn = rtmpdata['message']['body']['streamingURLInfoSet']['cdn'] rtmpurls = rtmpdata['message']['body']['streamingURLInfoSet']['streamingURLInfo'] return rtmpurls, sessionId, cdn except: return False, False, False
def GETSTREAMS(getstream): try: data = common.getURL(getstream,'atv-ps.amazon.com',useCookie=True) print data rtmpdata = demjson.decode(data) print rtmpdata sessionId = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['sessionId'] cdn = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['cdn'] rtmpurls = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['streamingURLInfo'] title = rtmpdata['message']['body']['metadata']['title'].replace('[HD]','') return rtmpurls, sessionId, cdn, title except: return False, False, False
def LIST_GENRE_FILTERED(): url = genreURL + common.args.url + '/1/4000/' data = common.getURL(url) jsondata = demjson.decode(data) for movie in jsondata['content']: try: thumb = movie['movie_playerposter'].replace('thumbs/', '') except: thumb = '' common.addDir(movie['movie_title'], 'movie', 'MOVIE_VIDEOS', movie['movie_url'], thumb, thumb) #common.addVideo(movie['movie_title'],movie['movie_url'],thumb,thumb) xbmcplugin.endOfDirectory(pluginhandle)
def GETTRAILERS(getstream): try: data = common.getURL(getstream, 'atv-ps.amazon.com') print data rtmpdata = demjson.decode(data) print rtmpdata sessionId = rtmpdata['message']['body']['streamingURLInfoSet'][ 'sessionId'] cdn = rtmpdata['message']['body']['streamingURLInfoSet']['cdn'] rtmpurls = rtmpdata['message']['body']['streamingURLInfoSet'][ 'streamingURLInfo'] return rtmpurls, sessionId, cdn except: return False, False, False
def GETSTREAMS(getstream): data = common.getURL(getstream,'atv-ps.amazon.com',useCookie=True) print data rtmpdata = demjson.decode(data) print rtmpdata try: drm = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['drm'] if drm <> 'NONE': xbmcgui.Dialog().ok('DRM Detected','This video uses %s DRM' % drm) except:pass sessionId = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['sessionId'] cdn = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['cdn'] rtmpurls = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0]['streamingURLInfo'] title = rtmpdata['message']['body']['metadata']['title'].replace('[HD]','') return rtmpurls, sessionId, cdn, title
def LIST_QUEUE(): url = 'http://www.epixhd.com/epx/ajax/myqueue/' data = common.getURL(url, useCookie=True) jsondata = demjson.decode(data) for movie in jsondata['queue']: try: poster = movie['poster'].replace('thumbs/', '') except: poster = '' try: fanart = movie['playerposter'].replace('thumbs/', '') except: fanart = '' common.addDir(movie['title'], 'movie', 'MOVIE_VIDEOS', '/' + movie['short_name'] + '/', poster, fanart) xbmcplugin.endOfDirectory(pluginhandle)
def SEARCH_PRIME(): keyboard = xbmc.Keyboard('')#Put amazon prime video link here.') keyboard.doModal() q = keyboard.getText() if (keyboard.isConfirmed()): xbmcplugin.setContent(0, 'Movies')#int(sys.argv[1]) url = common.args.url + ( urllib.quote_plus(keyboard.getText())) + "%2Cp_85%3A2470955011&page=1" data = common.getURL(url,useCookie=False) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) #videos = tree.findAll('div',attrs={'class':re.compile("^result.+product$"),'name':True}) atf = tree.find(attrs={'id':'atfResults'}).findAll('div',recursive=False,attrs={'name':True}) try: btf = tree.find(attrs={'id':'btfResults'}).findAll('div',recursive=False,attrs={'name':True}) atf.extend(btf) del btf except: print 'AMAZON: No btf found' del tree del data #nextpage = tree.find(attrs={'title':'Next page','id':'pagnNextLink','class':'pagnNext'}) totalItems = len(atf) print totalItems for video in atf: #price = video.find('span',attrs={'class':'price'}) #print price #if (price != None and price.string != None and price.string.strip() == '$0.00'): asin = video['name'] movietitle = video.find('',attrs={'class':'data'}).a.string url = video.find('div',attrs={'class':'data'}).a['href'] # thumb = video.find('img')['src'].replace('._AA160_','') # was SS160 for purchased tv/movies, regular search is just this fanart = thumb infoLabels = { 'Title':movietitle} prices = video.findAll(attrs={'class':'priceInfo'}) episodes = False for price in prices: if 'episode' in price.renderContents(): episodes = True if episodes: common.addDir(movietitle,'library','LIST_EPISODES', url,thumb,fanart,infoLabels) else: fanart = fanart.replace('.jpg','._BO354,0,0,0_CR177,354,708,500_.jpg') common.addVideo(movietitle,url,thumb,fanart,infoLabels=infoLabels,totalItems=totalItems) #viewenable=common.addon.getSetting("viewenable") #if viewenable == 'true': # view=int(xbmcplugin.getSetting(pluginhandle,"movieview")) # xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")") xbmcplugin.endOfDirectory(pluginhandle)
def PLAY(rtmpurls, swfUrl, Trailer=False, resolve=True, title=False): print rtmpurls quality = [0, 2500, 1328, 996, 664, 348] lbitrate = quality[int(common.addon.getSetting("bitrate"))] mbitrate = 0 streams = [] for data in rtmpurls: url = data['url'] bitrate = int(data['bitrate']) if lbitrate == 0: streams.append([bitrate, url]) elif bitrate >= mbitrate and bitrate <= lbitrate: mbitrate = bitrate rtmpurl = url if lbitrate == 0: quality = xbmcgui.Dialog().select( 'Please select a quality level:', [str(stream[0]) + 'kbps' for stream in streams]) print quality if quality != -1: rtmpurl = streams[quality][1] protocolSplit = rtmpurl.split("://") pathSplit = protocolSplit[1].split("/") hostname = pathSplit[0] appName = protocolSplit[1].split(hostname + "/")[1].split('/')[0] streamAuth = rtmpurl.split(appName + '/')[1].split('?') stream = streamAuth[0].replace('.mp4', '') auth = streamAuth[1] identurl = 'http://' + hostname + '/fcs/ident' ident = common.getURL(identurl) ip = re.compile('<fcs><ip>(.+?)</ip></fcs>').findall(ident)[0] basertmp = 'rtmpe://' + ip + ':1935/' + appName + '?_fcs_vhost=' + hostname + '&ovpfv=2.1.4&' + auth finalUrl = basertmp finalUrl += " playpath=" + stream finalUrl += " pageurl=" + common.args.url finalUrl += " swfurl=" + swfUrl + " swfvfy=true" if Trailer and not resolve: finalname = Trailer + ' Trailer' item = xbmcgui.ListItem(finalname, path=finalUrl) item.setInfo(type="Video", infoLabels={"Title": finalname}) item.setProperty('IsPlayable', 'true') xbmc.Player().play(finalUrl, item) else: item = xbmcgui.ListItem(path=finalUrl) item.setInfo(type="Video", infoLabels={"Title": title}) xbmcplugin.setResolvedUrl(pluginhandle, True, item) return basertmp, ip
def GETSTREAMS(getstream): try: data = common.getURL(getstream, 'atv-ps.amazon.com', useCookie=True) print data rtmpdata = demjson.decode(data) print rtmpdata sessionId = rtmpdata['message']['body']['urlSets'][ 'streamingURLInfoSet'][0]['sessionId'] cdn = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0][ 'cdn'] rtmpurls = rtmpdata['message']['body']['urlSets'][ 'streamingURLInfoSet'][0]['streamingURLInfo'] title = rtmpdata['message']['body']['metadata']['title'].replace( '[HD]', '') return rtmpurls, sessionId, cdn, title except: return False, False, False
def MOVIE_EXTRAS(): data = common.getURL(common.args.url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) try:fanart = tree.find('div',attrs={'class':'more-images wallpapers'}).find('img')['src'].replace('thumbs/','') except: try:fanart = re.compile("\('(.*?)'\)").findall(tree.find('div',attrs={'id':'playerposter'})['style'])[0] except:fanart = '' for item in tree.findAll('div',attrs={'class':re.compile('more-videos ')}): name = item.find('h5').string if name == common.args.name: for extra in item.findAll('a'): print extra.string if extra.string == None or extra.string == 'more' or extra.string == 'less': continue thumb = re.compile('"src", "(.*?)"\)').findall(extra['onmouseover'])[0].replace('thumbs/','') common.addVideo(extra.string.strip(),BASE+extra['href'],thumb,fanart,extra=True) xbmcplugin.endOfDirectory(pluginhandle)
def PLAY(rtmpurls,swfUrl,Trailer=False,resolve=True,title=False): print rtmpurls quality = [0,2500,1328,996,664,348] lbitrate = quality[int(common.addon.getSetting("bitrate"))] mbitrate = 0 streams = [] for data in rtmpurls: url = data['url'] bitrate = int(data['bitrate']) if lbitrate == 0: streams.append([bitrate,url]) elif bitrate >= mbitrate and bitrate <= lbitrate: mbitrate = bitrate rtmpurl = url if lbitrate == 0: quality=xbmcgui.Dialog().select('Please select a quality level:', [str(stream[0])+'kbps' for stream in streams]) print quality if quality!=-1: rtmpurl = streams[quality][1] protocolSplit = rtmpurl.split("://") pathSplit = protocolSplit[1].split("/") hostname = pathSplit[0] appName = protocolSplit[1].split(hostname + "/")[1].split('/')[0] streamAuth = rtmpurl.split(appName+'/')[1].split('?') stream = streamAuth[0].replace('.mp4','') auth = streamAuth[1] identurl = 'http://'+hostname+'/fcs/ident' ident = common.getURL(identurl) ip = re.compile('<fcs><ip>(.+?)</ip></fcs>').findall(ident)[0] basertmp = 'rtmpe://'+ip+':1935/'+appName+'?_fcs_vhost='+hostname+'&ovpfv=2.1.4&'+auth finalUrl = basertmp finalUrl += " playpath=" + stream finalUrl += " pageurl=" + common.args.url finalUrl += " swfurl=" + swfUrl + " swfvfy=true" if Trailer and not resolve: finalname = Trailer+' Trailer' item = xbmcgui.ListItem(finalname,path=finalUrl) item.setInfo( type="Video", infoLabels={ "Title": finalname}) item.setProperty('IsPlayable', 'true') xbmc.Player().play(finalUrl,item) else: item = xbmcgui.ListItem(path=finalUrl) item.setInfo( type="Video", infoLabels={ "Title": title}) xbmcplugin.setResolvedUrl(pluginhandle, True, item) return basertmp, ip
def GETSUBTITLES(values): getsubs = 'https://atv-ps.amazon.com/cdp/catalog/GetSubtitleUrls' getsubs += '?NumberOfResults=1' getsubs += '&firmware=LNX%2010,3,181,14%20PlugIn' getsubs += '&deviceTypeID='+values['deviceTypeID'] getsubs += '&customerID='+values['customerID'] getsubs += '&deviceID='+values['deviceID'] getsubs += '&format=json' getsubs += '&asin='+values['asin'] getsubs += '&version=2' getsubs += '&token='+values['token'] getsubs += '&videoType=content' data = common.getURL(getsubs,'atv-ps.amazon.com',useCookie=True) subtitleLanguages = demjson.decode(data)['message']['body']['subtitles']['content']['languages'] if len(subtitleLanguages) > 0: subtitleUrl = subtitleLanguages[0]['url'] subtitles = CONVERTSUBTITLES(subtitleUrl) common.SaveFile(os.path.join(common.pluginpath,'resources','cache',values['asin']+'.srt'), subtitles)
def LIBRARY_LIST_MOVIES(): url = common.args.url data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'lib-item','asin':True}) totalItems = len(videos) for video in videos: asin = video['asin'] appfeed.ADD_MOVIE(asin,isPrime=False) xbmcplugin.setContent(int(sys.argv[1]), 'Movies') xbmcplugin.endOfDirectory(pluginhandle) viewenable=common.addon.getSetting("viewenable") if viewenable == 'true': view=int(common.addon.getSetting("movieview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")")
def LIBRARY_LIST_MOVIES(): url = common.args.url data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'lib-item', 'asin': True}) totalItems = len(videos) for video in videos: asin = video['asin'] appfeed.ADD_MOVIE(asin, isPrime=False) xbmcplugin.setContent(int(sys.argv[1]), 'Movies') xbmcplugin.endOfDirectory(pluginhandle) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting("movieview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def GETSTREAMS(getstream): data = common.getURL(getstream, 'atv-ps.amazon.com', useCookie=True) print data rtmpdata = demjson.decode(data) print rtmpdata try: drm = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0][ 'drm'] if drm <> 'NONE': xbmcgui.Dialog().ok('DRM Detected', 'This video uses %s DRM' % drm) except: pass sessionId = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][ 0]['sessionId'] cdn = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][0][ 'cdn'] rtmpurls = rtmpdata['message']['body']['urlSets']['streamingURLInfoSet'][ 0]['streamingURLInfo'] title = rtmpdata['message']['body']['metadata']['title'].replace( '[HD]', '') return rtmpurls, sessionId, cdn, title
def GETSUBTITLES(values): getsubs = 'https://atv-ps.amazon.com/cdp/catalog/GetSubtitleUrls' getsubs += '?NumberOfResults=1' getsubs += '&firmware=LNX%2010,3,181,14%20PlugIn' getsubs += '&deviceTypeID=' + values['deviceTypeID'] getsubs += '&customerID=' + values['customerID'] getsubs += '&deviceID=' + values['deviceID'] getsubs += '&format=json' getsubs += '&asin=' + values['asin'] getsubs += '&version=2' getsubs += '&token=' + values['token'] getsubs += '&videoType=content' data = common.getURL(getsubs, 'atv-ps.amazon.com', useCookie=True) subtitleLanguages = demjson.decode( data)['message']['body']['subtitles']['content']['languages'] if len(subtitleLanguages) > 0: subtitleUrl = subtitleLanguages[0]['url'] subtitles = CONVERTSUBTITLES(subtitleUrl) common.SaveFile( os.path.join(common.pluginpath, 'resources', 'cache', values['asin'] + '.srt'), subtitles)
def getTVTree(url): data = common.getURL(url) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) atf = tree.find(attrs={'id':'atfResults'}) if atf == None: print tree.prettify() return False atf = tree.find(attrs={'id':'atfResults'}).findAll('div',recursive=False) try: btf = tree.find(attrs={'id':'btfResults'}).findAll('div',recursive=False) atf.extend(btf) del btf except: print 'AMAZON: No btf found' nextpage = tree.find(attrs={'title':'Next page','id':'pagnNextLink','class':'pagnNext'}) del data return atf, nextpage
def LIBRARY_LIST_MOVIES(): xbmcplugin.setContent(int(sys.argv[1]), 'Movies') url = common.args.url data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'lib-item', 'asin': True}) totalItems = len(videos) for video in videos: asin = video['asin'] movietitle = video.find('', attrs={'class': 'title'}).a.string url = common.BASE_URL + video.find('div', attrs={ 'class': 'title' }).a['href'] thumb = video.find('img')['src'].replace('._SS160_', '') fanart = thumb.replace('.jpg', '._BO354,0,0,0_CR177,354,708,500_.jpg') #if xbmcplugin.getSetting(pluginhandle,'enablelibrarymeta') == 'true': # asin2,movietitle,url,poster,plot,director,runtime,year,premiered,studio,mpaa,actors,genres,stars,votes,TMDBbanner,TMDBposter,TMDBfanart,isprime,watched,favor = getMovieInfo(asin,movietitle,url,poster,isPrime=False) # actors = actors.split(',') # infoLabels = { 'Title':movietitle,'Plot':plot,'Year':year,'premiered':premiered, # 'rating':stars,'votes':votes,'Genre':genres,'director':director, # 'studio':studio,'duration':runtime,'mpaa':mpaa,'cast':actors} #else: infoLabels = {'Title': movietitle} common.addVideo(movietitle, url, thumb, fanart, infoLabels=infoLabels, totalItems=totalItems) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(xbmcplugin.getSetting(pluginhandle, "movieview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")") xbmcplugin.endOfDirectory(pluginhandle)
def scrapeMoviesdb(url, isprime=True): data = common.getURL(url) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) atf = tree.find(attrs={'id': 'atfResults'}).findAll('div', recursive=False) try: btf = tree.find(attrs={ 'id': 'btfResults' }).findAll('div', recursive=False) atf.extend(btf) del btf except: print 'AMAZON: No btf found' nextpage = tree.find(attrs={ 'title': 'Next page', 'id': 'pagnNextLink', 'class': 'pagnNext' }) del tree del data for movie in atf: asin = movie['name'] movietitle = movie.find('a', attrs={'class': 'title'}).string poster = movie.find(attrs={ 'class': 'image' }).find('img')['src'].replace('._AA160_', '') url = common.BASE_URL + '/gp/product/' + asin print getMovieInfo(asin, movietitle, url, poster, isPrime=True) del atf if nextpage: pagenext = common.BASE_URL + nextpage['href'] del nextpage return pagenext else: return False
def LIBRARY_LIST_TV(): url = common.args.url data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'lib-item', 'asin': True}) totalItems = len(videos) ASINS = '' for video in videos: asin = video['asin'] #appfeed.ADD_SEASON(asin,'library','LIBRARY_EPISODES',isPrime=False) if common.addon.getSetting("watchlist_tv_view") == '0': appfeed.ADD_SEASON(asin, 'library', 'LIBRARY_EPISODES', isPrime=False, addSeries=True) elif common.addon.getSetting("watchlist_tv_view") == '1': asin1, asin2 = appfeed.ADD_SEASON_SERIES(asin, 'library', 'LIBRARY_LIST_SEASONS', isPrime=True, checklist=ASINS) if asin1: ASINS += asin1 if asin2: ASINS += asin2 xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting("showview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def LIBRARY_LIST_TV(): url = common.args.url data = common.getURL(url, useCookie=True) scripts = re.compile(r'<script.*?script>', re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>', re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div', attrs={'class': 'lib-item', 'asin': True}) totalItems = len(videos) for video in videos: xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') asin = video['asin'] name = video.find('', attrs={'class': 'title'}).a.string thumb = video.find('img')['src'].replace('._SS160_', '') if '[HD]' in name: isHD = True else: isHD = False url = common.BASE_URL + video.find('div', attrs={ 'class': 'title' }).a['href'] #if xbmcplugin.getSetting(pluginhandle,'enablelibrarymeta') == 'true': # asin2,season,episodes,plot,creator,runtime,year,network,actors,genres,stars,votes,HD,TVDBbanner,TVDBposter,TVDBfanart = getShowInfo(url,asin,isHD) # actors = actors.split(',') # infoLabels={'Title': name,'Plot':plot,'year':year,'rating':stars,'votes':votes, # 'Genre':genres,'Season':season,'episode':episodes,'studio':network, # 'duration':runtime,'cast':actors,'TVShowTitle':name,'credits':creator} # if year <> 0: infoLabels['premiered'] = str(year) #else: infoLabels = {'Title': name} common.addDir(name, 'library', 'LIBRARY_EPISODES', url, thumb, thumb, infoLabels, totalItems) viewenable = xbmcplugin.getSetting(pluginhandle, "viewenable") if viewenable == 'true': view = int(xbmcplugin.getSetting(pluginhandle, "showview")) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")") xbmcplugin.endOfDirectory(pluginhandle)
def addMoviesdb(url=MOVIE_URL, isprime=True, singlepage=False): dialog = xbmcgui.DialogProgress() dialog.create('Refreshing Prime Movie Database') dialog.update(0, 'Initializing Movie Scan') if not singlepage: data = common.getURL(url) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) total = int( tree.find('div', attrs={ 'id': 'resultCount', 'class': 'resultCount' }).span.string.replace( ',', '').split('of')[1].split('Results')[0].strip()) del tree del data else: total = 12 pages = (total / 12) + 1 increment = 100.0 / pages page = 1 percent = int(increment * page) dialog.update( percent, 'Scanning Page %s of %s' % (str(page), str(pages)), 'Scanned %s of %s Movies' % (str((page - 1) * 12), str(total))) pagenext = scrapeMoviesdb(url, isprime) if not singlepage: while pagenext: page += 1 percent = int(increment * page) dialog.update( percent, 'Scanning Page %s of %s' % (str(page), str(pages)), 'Scanned %s of %s Movies' % (str((page - 1) * 12), str(total))) pagenext = scrapeMoviesdb(pagenext, isprime) if (dialog.iscanceled()): return False
def CONVERTSUBTITLES(url): xml = common.getURL(url) tree = BeautifulStoneSoup(xml, convertEntities=BeautifulStoneSoup.XML_ENTITIES) lines = tree.find('tt:body').findAll('tt:p') stripTags = re.compile(r'<.*?>', re.DOTALL) spaces = re.compile(r'\s\s\s+') srt_output = '' count = 1 displaycount = 1 for line in lines: sub = line.renderContents() sub = stripTags.sub(' ', sub) sub = spaces.sub(' ', sub) sub = sub.decode('utf-8') start = line['begin'].replace('.', ',') if count < len(lines): end = line['end'].replace('.', ',') line = str( displaycount) + "\n" + start + " --> " + end + "\n" + sub + "\n\n" srt_output += line count += 1 displaycount += 1 return srt_output.encode('utf-8')