def ASIN_LOOKUP(ASINLIST): results = len(ASINLIST.split(',')) - 1 # &NumberOfResults=400 BROWSE_PARAMS = '&asinList=' + ASINLIST + '&NumberOfResults=' + str( results) + '&IncludeAll=T&playbackInformationRequired=true&version=2' url = BUILD_BASE_API('catalog/GetASINDetails') + BROWSE_PARAMS return demjson.decode(common.getATVURL(url))
def APP_LEVEL3(): url = BUILD_BASE_API('catalog/GetCategoryList') + '&version=1' data = common.getATVURL(url) json = demjson.decode(data) del data categories = json['message']['body']['categories'][int( common.args.url.split(',')[0])]['categories'][int( common.args.url.split(',')[1])]['categories'][int( common.args.url.split(',')[2])]['categories'] del json for item in categories: if item.has_key('categories'): common.addDir(item['title'], 'appfeed', 'APP_LEVEL4', common.args.url + ',' + str(categories.index(item))) else: cm = [( 'Export to Library', 'XBMC.RunPlugin(plugin://plugin.video.amazon?mode="appfeed"&sitemode="BROWSE_EXPORT"&url="%s")' % (urllib.quote_plus(item['query'])))] common.addDir(item['title'], 'appfeed', 'BROWSE', item['query'], cm=cm) xbmcplugin.endOfDirectory(pluginhandle)
def getList(ContentType, start=0, isPrime=True, NumberOfResults=250, OrderBy='SalesRank', version=2): if isPrime: BROWSE_PARAMS = '&OfferGroups=B0043YVHMY' BROWSE_PARAMS += '&NumberOfResults=' + str(NumberOfResults) BROWSE_PARAMS += '&StartIndex=' + str(start) BROWSE_PARAMS += '&ContentType=' + ContentType BROWSE_PARAMS += '&OrderBy=' + OrderBy #BROWSE_PARAMS +='&Detailed=T' #BROWSE_PARAMS +='&IncludeNonWeb=T' #BROWSE_PARAMS += #&HighDef=F # T or F ?? #&playbackInformationRequired=false #&OrderBy=SalesRank #SuppressBlackedoutEST=T #&HideNum=T #&Detailed=T #&AID=1 #&IncludeNonWeb=T BROWSE_PARAMS += '&version=' + str(version) url = BUILD_BASE_API('catalog/Browse') + BROWSE_PARAMS return demjson.decode(common.getATVURL(url))
def SEARCH_SUGGEST_PRIME(): BROWSE_PARAMS = '&query='+common.args.url+'&version=1' url = BUILD_BASE_API('catalog/GetSearchSuggestions')+BROWSE_PARAMS data = common.getATVURL(url) suggestions = demjson.decode(data)['message']['body']['searchSuggestion'] if len(suggestions) > 0: selected=xbmcgui.Dialog().select('Suggestions', [suggestion for suggestion in suggestions]) SEARCH_PRIME(searchString=urllib.quote_plus(suggestions[selected]))
def SEARCH_SUGGEST_PRIME(): BROWSE_PARAMS = '&query=' + common.args.url + '&version=1' url = BUILD_BASE_API('catalog/GetSearchSuggestions') + BROWSE_PARAMS data = common.getATVURL(url) suggestions = demjson.decode(data)['message']['body']['searchSuggestion'] if len(suggestions) > 0: selected = xbmcgui.Dialog().select( 'Suggestions', [suggestion for suggestion in suggestions]) SEARCH_PRIME(searchString=urllib.quote_plus(suggestions[selected]))
def APP_LEVEL1(): url = BUILD_BASE_API('catalog/GetCategoryList')+'&version=1' data = common.getATVURL(url) json = demjson.decode(data) del data categories = json['message']['body']['categories'][int(common.args.url)]['categories'] del json for item in categories: if item.has_key('categories'): common.addDir(item['title'],'appfeed','APP_LEVEL2',common.args.url+','+str(categories.index(item))) else: common.addDir(item['title'],'appfeed','BROWSE',item['query']) xbmcplugin.endOfDirectory(pluginhandle)
def APP_LEVEL0(): url = BUILD_BASE_API('catalog/GetCategoryList') + '&version=1' data = common.getATVURL(url) json = demjson.decode(data) del data categories = json['message']['body']['categories'] del json for item in categories: if item.has_key('categories'): common.addDir(item['title'], 'appfeed', 'APP_LEVEL1', str(categories.index(item))) else: common.addDir(item['title'], 'appfeed', 'BROWSE', item['query']) xbmcplugin.endOfDirectory(pluginhandle)
def APP_LEVEL3(): url = BUILD_BASE_API('catalog/GetCategoryList')+'&version=1' data = common.getATVURL(url) json = demjson.decode(data) del data categories = json['message']['body']['categories'][int(common.args.url.split(',')[0])]['categories'][int(common.args.url.split(',')[1])]['categories'][int(common.args.url.split(',')[2])]['categories'] del json for item in categories: if item.has_key('categories'): common.addDir(item['title'],'appfeed','APP_LEVEL4',common.args.url+','+str(categories.index(item))) else: cm = [('Export to Library', 'XBMC.RunPlugin(plugin://plugin.video.amazon?mode="appfeed"&sitemode="BROWSE_EXPORT"&url="%s")' % ( urllib.quote_plus(item['query']) ) ) ] common.addDir(item['title'],'appfeed','BROWSE',item['query'],cm=cm) xbmcplugin.endOfDirectory(pluginhandle)
def getList(ContentType,start=0,isPrime=True,NumberOfResults=250,OrderBy='SalesRank',version=2): if isPrime: BROWSE_PARAMS = '&OfferGroups=B0043YVHMY' BROWSE_PARAMS +='&NumberOfResults='+str(NumberOfResults) BROWSE_PARAMS +='&StartIndex='+str(start) BROWSE_PARAMS +='&ContentType='+ContentType BROWSE_PARAMS +='&OrderBy='+OrderBy #BROWSE_PARAMS +='&Detailed=T' #BROWSE_PARAMS +='&IncludeNonWeb=T' #BROWSE_PARAMS += #&HighDef=F # T or F ?? #&playbackInformationRequired=false #&OrderBy=SalesRank #SuppressBlackedoutEST=T #&HideNum=T #&Detailed=T #&AID=1 #&IncludeNonWeb=T BROWSE_PARAMS +='&version='+str(version) url = BUILD_BASE_API('catalog/Browse')+BROWSE_PARAMS return demjson.decode(common.getATVURL(url))
def BROWSE_ADDITEMS(url, results, index, search=False, series4season=False, HD=False, export=False): data = common.getATVURL(url) json = demjson.decode(data) del data titles = json['message']['body']['titles'] del json if len(titles) == results: if index == 0: page = 1 else: page = index / results if not search or not export: common.addDir('Next Page (%s-%s)' % (page * results + 1, (page + 1) * results), 'appfeed', 'BROWSE_NEXT', common.args.url, page=page) Movies = False Series = False Season = False Episode = False if series4season: allSeries = '' for title in titles: if title['contentType'] == 'MOVIE': ADD_MOVIE(title['titleId'], export=export) Movies = True elif title['contentType'] == 'SERIES': ADD_SERIES(title['titleId'], export=export) Series = True elif title['contentType'] == 'SEASON': if series4season: seriesId = title['ancestorTitles'][0]['titleId'] if seriesId not in allSeries: ADD_SERIES(seriesId, export=export) allSeries += seriesId + ',' Series = True else: asin = title['titleId'] ADD_SEASON(asin, seriesTitle=search, export=export) for format in title['formats']: if format['videoFormatType'] == 'HD': for offer in format['offers']: if offer['offerType'] == 'SEASON_PURCHASE': asin = offer['asin'] #ADD_SEASON(asin,seriesTitle=True) ADD_SEASON(asin, seriesTitle=search, submode='BROWSE_EPISODES_HD', export=export) Season = True elif title['contentType'] == 'EPISODE': asin = title['titleId'] if HD: for format in title['formats']: if format['videoFormatType'] == 'HD': for offer in format['offers']: if offer['offerType'] == 'PURCHASE': asin = offer['asin'] ADD_EPISODE(asin, seriesTitle=search, export=export) Episode = True if not export: if Series: view = 'showview' xbmcplugin.setContent(pluginhandle, 'tvshows') elif Season: view = 'seasonview' xbmcplugin.setContent(pluginhandle, 'tvshows') elif Movies: view = 'movieview' xbmcplugin.setContent(pluginhandle, 'Movies') elif Episode: view = 'episodeview' xbmcplugin.setContent(pluginhandle, 'Episodes') else: view = 'showview' xbmcplugin.setContent(pluginhandle, 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable = common.addon.getSetting("viewenable") if viewenable == 'true': view = int(common.addon.getSetting(view)) xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
def URL_LOOKUP(url): return demjson.decode(common.getATVURL(url + PARAMETERS.replace('?', '&')))
def URL_LOOKUP(url): return demjson.decode(common.getATVURL(url+PARAMETERS.replace('?','&')))
def ASIN_LOOKUP(ASINLIST): results = len(ASINLIST.split(','))-1 # &NumberOfResults=400 BROWSE_PARAMS = '&asinList='+ASINLIST+'&NumberOfResults='+str(results)+'&IncludeAll=T&playbackInformationRequired=true&version=2' url = BUILD_BASE_API('catalog/GetASINDetails')+BROWSE_PARAMS return demjson.decode(common.getATVURL(url))
def BROWSE_ADDITEMS(url,results,index,search=False,series4season=False,HD=False,export=False): data = common.getATVURL(url) json = demjson.decode(data) del data titles = json['message']['body']['titles'] del json if len(titles) == results: if index == 0: page = 1 else: page = index/results if not search or not export: common.addDir('Next Page (%s-%s)'% (page*results+1,(page+1)*results),'appfeed','BROWSE_NEXT',common.args.url,page=page) Movies = False Series = False Season = False Episode = False if series4season: allSeries = '' for title in titles: if title['contentType'] == 'MOVIE': ADD_MOVIE(title['titleId'],export=export) Movies = True elif title['contentType'] == 'SERIES': ADD_SERIES(title['titleId'],export=export) Series = True elif title['contentType'] == 'SEASON': if series4season: seriesId = title['ancestorTitles'][0]['titleId'] if seriesId not in allSeries: ADD_SERIES(seriesId,export=export) allSeries += seriesId+',' Series = True else: asin = title['titleId'] ADD_SEASON(asin,seriesTitle=search,export=export) for format in title['formats']: if format['videoFormatType'] == 'HD': for offer in format['offers']: if offer['offerType'] == 'SEASON_PURCHASE': asin = offer['asin'] #ADD_SEASON(asin,seriesTitle=True) ADD_SEASON(asin,seriesTitle=search,submode='BROWSE_EPISODES_HD',export=export) Season = True elif title['contentType'] == 'EPISODE': asin = title['titleId'] if HD: for format in title['formats']: if format['videoFormatType'] == 'HD': for offer in format['offers']: if offer['offerType'] == 'PURCHASE': asin = offer['asin'] ADD_EPISODE(asin,seriesTitle=search,export=export) Episode = True if not export: if Series: view='showview' xbmcplugin.setContent(pluginhandle, 'tvshows') elif Season: view = 'seasonview' xbmcplugin.setContent(pluginhandle, 'tvshows') elif Movies: view='movieview' xbmcplugin.setContent(pluginhandle, 'Movies') elif Episode: view='episodeview' xbmcplugin.setContent(pluginhandle, 'Episodes') else: view='showview' xbmcplugin.setContent(pluginhandle, 'tvshows') xbmcplugin.endOfDirectory(pluginhandle) viewenable=common.addon.getSetting("viewenable") if viewenable == 'true': view=int(common.addon.getSetting(view)) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")")