def get_search_url(name, url, thumb): if settings.getSetting("quality") == '0' or len(url.split('/')[4]) > 10: meta = 'http://cdnapi.kaltura.com/p/' + thumb.split('/')[4] + '/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' + thumb.split('/')[9] data = getUrl( meta, True ) url = re.compile('<media url=\"(.+?)\"').findall(data)[0] else: if len(url.rsplit('-')) == 2: url = url.replace('-', '_') data = getUrl( url, True ) url = common.parseDOM(data, "meta", attrs = { "name": "VideoURL" }, ret = "content")[0] play_video( name, url, thumb, settings.getLocalizedString( 30007 ) )
def play_video( name, url, thumb, studio ): if studio != settings.getLocalizedString( 30007 ): try: data = getUrl( url, True ) url = re.compile('<media url=\"(.+?)\"').findall(data)[0] except: url = 'http://www.tmz.com/videos/' + thumb.split('/')[9] data = getUrl( url, True ) url = common.parseDOM(data, "meta", attrs = { "name": "VideoURL" }, ret = "content")[0] infoLabels = { "Title": name , "Studio": "TMZ: " + studio, "Plot": name } playListItem(label = name, image = thumb, path = url, infoLabels = infoLabels)
def build_sub_directory(url, thumb): saveurl = url html = getUrl('http://espn.go.com/video/') menu = common.parseDOM(html, "div", attrs = { "id": url }) channel = common.parseDOM(menu, "li", attrs = { "class": "channel" }) title = common.parseDOM(channel, "a") id = common.parseDOM(menu, "li", attrs = { "class": "channel" }, ret = "id") item_count = 0 if saveurl == 'menu2949050': shows=[ ( settings.getLocalizedString( 30009 ), 'sportscenter' ), ( settings.getLocalizedString( 30010 ), 'first%20take' ), ( settings.getLocalizedString( 30011 ), 'pti' ), ( settings.getLocalizedString( 30012 ), 'ath' ) ] for name, search in shows: url = 'http://search.espn.go.com/results?searchString=' + search + '&start=0&dims=6' u = { 'mode': '2', 'name': settings.getLocalizedString( 30005 ), 'url': url, 'type': 'history' } infoLabels = { "Title": name, "Plot": name } addListItem(label = name, image = tvshows_thumb, url = u, isFolder = True, infoLabels = infoLabels) for name in title: name = name.rsplit('(')[0] url = 'http://espn.go.com/video/format/libraryPlaylist?categoryid=' + id[item_count].replace('channel','') u = { 'mode': '2', 'name': name, 'url': url, 'type': 'null' } infoLabels = { "Title": name, "Plot": name } addListItem(label = name, image = thumb, url = u, isFolder = True, infoLabels = infoLabels) item_count += 1 xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_film_database_directory(): keyboard = xbmc.Keyboard('', settings.getLocalizedString(30011)) keyboard.doModal() search_string = keyboard.getText().rsplit(' ')[0] if ((keyboard.isConfirmed() == False) or (len(search_string) == 0)): return data = getUrl('http://www.traileraddict.com/thefilms/' + search_string) link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall(data) if len(link_title) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin, settings.getLocalizedString(30009) + search_string + '.\n' + settings.getLocalizedString(30013)) build_main_directory() return item_count = 0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = {'mode': '4', 'name': clean(title), 'url': url} addListItem(label=clean(title), image=poster_thumb, url=u, isFolder=True, totalItems=totalItems, infoLabels=False) item_count = item_count + 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_video_directory(url, page, section): if url == "search": search = True text = common.getUserInput(settings.getLocalizedString(30003), "") if text == None: return url = "channels%2F*%7Cgames%2F*%7Cflip_video_diaries%7Cfiba&text=" + urllib.quote(text) else: search = False save_url = url if page == 1 and search != True: base = "http://www.nba.com/.element/ssi/auto/2.0/aps/video/playlists/" + section + ".html?section=" else: base = "http://searchapp2.nba.com/nba-search/query.jsp?section=" url = base + url + "&season=1213&sort=recent&hide=true&type=advvideo&npp=15&start=" + str(1 + (15 * (page - 1))) html = getUrl(url) textarea = common.parseDOM(html, "textarea", attrs={"id": "jsCode"})[0] content = ( textarea.replace("\\'", "\\\\'") .replace('\\\\"', '\\\\\\"') .replace("\\n", "") .replace("\\t", "") .replace("\\x", "") ) query = json.loads(content) data = query["results"][0] count = query["metaResults"]["advvideo"] if len(data) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30004) + "\n" + settings.getLocalizedString(30005)) return for results in data: mediaDateUts = time.ctime(float(results["mediaDateUts"])) date = datetime.datetime.fromtimestamp( time.mktime(time.strptime(mediaDateUts, "%a %b %d %H:%M:%S %Y")) ).strftime("%d.%m.%Y") title = results["title"].replace("\\", "") thumb = results["metadata"]["media"]["thumbnail"]["url"].replace("136x96", "576x324") length = results["metadata"]["video"]["length"].split(":") duration = int(length[0]) * 60 + int(length[1]) plot = results["metadata"]["media"]["excerpt"].replace("\\", "") url = results["id"].replace("/video/", "").replace("/index.html", "") infoLabels = {"Title": title, "Plot": plot, "Aired": date} u = {"mode": "3", "name": title, "url": url, "thumb": thumb, "plot": plot} addListItem( label=title, image=thumb, url=u, isFolder=False, infoLabels=infoLabels, fanart=fanart, duration=duration ) if int(page) * 15 < int(count): u = {"mode": "0", "page": str(int(page) + 1), "url": save_url, "section": section} addListItem( label="[Next Page (" + str(int(page) + 1) + ")]", image=next_thumb, url=u, isFolder=True, infoLabels=False, fanart=fanart, ) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_search_directory(name, url): if url != 'library': keyboard = xbmc.Keyboard( '', settings.getLocalizedString(30007) ) keyboard.doModal() if ( keyboard.isConfirmed() == False ): return search_string = keyboard.getText().replace( ' ', '+' ) if len( search_string ) == 0: return else: search_string = name data = getUrl( 'http://www.traileraddict.com/search.php?q=' + search_string ) image = re.compile( '<center>\r\n<div style="background:url\((.*?)\);" class="searchthumb">', re.DOTALL ).findall( data ) link_title = re.compile( '</div><a href="/tags/(.*?)">(.*?)</a><br />' ).findall( data ) if len( link_title ) == 0: if url == 'library': return None dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString(30009) + search_string + '.\n' + settings.getLocalizedString(30010) ) build_main_directory() return item_count=0 totalItems = len(link_title) if url == 'library': return link_title[0][0] for url, title in link_title: url = 'http://www.traileraddict.com/tags/' + url thumb = 'http://www.traileraddict.com' + image[item_count].replace( '/pthumb.php?dir=', '' ).replace( '\r\n', '' ) u = { 'mode': '4', 'name': clean( title ), 'url': url } addListItem(label = clean( title ), image = thumb, url = u, isFolder = True, totalItems = totalItems, infoLabels = False) item_count = item_count + 1 xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_main_directory(): main=[ ( settings.getLocalizedString(30000), search_thumb, '0' ), ( settings.getLocalizedString(30001), film_reel_thumb, '1' ), ( settings.getLocalizedString(30002), clapperboard_thumb, '2' ), ( settings.getLocalizedString(30003), oscar_thumb, '3' ), ( settings.getLocalizedString(30004), popcorn_thumb, '6' ), ( settings.getLocalizedString(30015), library_thumb, '7' ) ] for name, thumbnailImage, mode in main: listitem = xbmcgui.ListItem( label = name, iconImage = "DefaultVideo.png", thumbnailImage = thumbnailImage ) u = { 'mode': mode, 'name': name } addListItem(label = name, image = thumbnailImage, url = u, isFolder = True, totalItems = 0, infoLabels = False) data = getUrl( 'http://www.traileraddict.com' ) url_thumb_x_title = re.compile( '<a href="/trailer/(.+?)"><img src="(.+?)" border="0" alt="(.+?)" title="(.+?)" style="margin:2px 10px 8px 10px;">' ).findall( data ) totalItems = len(url_thumb_x_title) for url, thumb, x, title in url_thumb_x_title: title = title.rsplit( ' - ' ) name1 = clean( title[0] ) if len( title ) > 1: name2 = clean( title[0] ) + ' (' + clean( title[1] ) + ')' else: name2 = clean( title[0] ) url = 'http://www.traileraddict.com/trailer/' + url thumb = 'http://www.traileraddict.com' + thumb cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': name2, 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % name1) ) u = { 'mode': '5', 'name': name2, 'url': url } addListItem(label = name1, image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("500", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_featured_directory( page ): save_page = page data = getUrl( 'http://www.traileraddict.com/attraction/' + str( int( page ) + 1) ) url_thumb_x_title = re.compile( '<a href="/trailer/(.+?)"><img src="(.+?)" border="0" alt="(.+?)" title="(.+?)" style="margin:8px 5px 2px 5px;"></a>' ).findall( data ) totalItems = len(url_thumb_x_title) for url, thumb, x, title in url_thumb_x_title: title = title.rsplit( ' - ' ) name1 = clean( title[0] ) if len( title ) > 1: name2 = clean( title[0] ) + ' (' + clean( title[1] ) + ')' else: name2 = clean( title[0] ) url = 'http://www.traileraddict.com/trailer/' + url thumb = 'http://www.traileraddict.com' + thumb cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': name2, 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % name1) ) u = { 'mode': '5', 'name': name2, 'url': url } addListItem(label = name1, image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) u = { 'mode': '6', 'page': str( int( save_page ) + 1 ) } addListItem(label = '[ Next Page (' + str( int( save_page ) + 2 ) + ') ]', image = next_thumb, url = u, isFolder = True, totalItems = 0, infoLabels = False) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("500", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_search_directory( url, page ): save_url = url.replace( ' ', '%20' ) url = 'http://www.pbs.org/search/?q=' + url.replace( ' ', '%20' ) + '&ss=pbs&mediatype=Video&start=' + str( page * 10 ) data = getUrl( url ) title_id_thumb = re.compile('<a title="(.*?)" target="" rel="nofollow" onclick="EZDATA\.trackGaEvent\(\'search\', \'navigation\', \'external\'\);" href="(.*?)"><img src="(.*?)" class="ez-primaryThumb"').findall(data) program = re.compile('<p class="ez-metaextra1 ez-icon">(.*?)</p>').findall(data) plot = re.compile('<p class="ez-desc">(.*?)<div class="(ez-snippets|ez-itemUrl)">', re.DOTALL).findall(data) video_count = re.compile('<b class="ez-total">(.*?)</b>').findall(data) if len(title_id_thumb) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30004 ) + '\n' + settings.getLocalizedString( 30005 ) ) return item_count = 0 for title, id, thumb in title_id_thumb: infoLabels = { "Title": clean( title ) , "Director": "PBS", "Studio": clean( program[item_count] ), "Plot": clean( plot[item_count][0] ) } u = { 'mode': '0', 'name': urllib.quote_plus( clean( program[item_count] ) ), 'program_id': urllib.quote_plus( id.rsplit('/')[4] ), 'topic': urllib.quote_plus( 'False' ) } addListItem(label = clean( title ), image = thumb, url = u, isFolder = False, infoLabels = infoLabels, fanart = fanart) item_count += 1 xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_STUDIO ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL ) if page == 0: build_programs_directory( save_url.replace( '%20', ' ' ), 0 ) if ( int( video_count[0] ) - ( 10 * int( page ) ) ) > 10: u = { 'mode': '6', 'page': str( int( page ) + 1 ), 'url': urllib.quote_plus( save_url ) } addListItem(label = '[Next Page (' + str( int( page ) + 2 ) + ')]', image = next_thumb, url = u, isFolder = True, infoLabels = False, fanart = fanart) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_STUDIO ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def get_video(url, name, plot, studio, episode, thumb, date): if '{' in url: url = ast.literal_eval(url) try: path = url[settings.getSetting('format').lower().replace('hd','hd720p30').replace('high','large').replace('low','small')]['url'] except: if 'hd' in url: path = url['hd']['url'] elif 'large' in url: path = url['large']['url'] elif 'small' in url: path = url['small']['url'] else: path = url.items()[0][1]['url'] else: oembed = getUrl('http://revision3.com/api/oembed/?url=http://revision3.com/%s/&format=json' % url) video_id = re.compile('html5player\-v(.+?)\?external').findall(oembed)[0] api = getUrl('http://revision3.com/api/flash?video_id=' + video_id) videos_api = common.parseDOM(api, "media", ret = "type") videos_api[:] = (value for value in videos_api if value != 'thumbnail') durl = {} for type_api in videos_api: content_api = clean(common.parseDOM(api, "media", attrs = { "type": type_api })[0]) durl[type_api] = content_api try: path = durl[settings.getSetting('format').lower()] except: if 'high' in durl: path = durl['high'] elif 'low' in durl: path = durl['low'] else: path = str(durl.items()[0][1]) if settings.getSetting('download') == 'true': while not settings.getSetting('downloadPath'): if settings.getSetting('download') == 'false': xbmc.executebuiltin("Container.Refresh") return dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString( 30011 )) settings.openSettings() params = { "url": path, "download_path": settings.getSetting('downloadPath'), "Title": name } downloader.download(clean_file(name) + '.' + path.split('/')[-1].split('.')[-1], params) else: infoLabels = { "Title": name, "Studio": 'Revision3: ' + studio, "Plot": plot, "Episode": int(episode), "Aired": date } playListItem(label = name, image = thumb, path = path, infoLabels = infoLabels, PlayPath = False)
def build_video_directory(name, url): if name == settings.getLocalizedString(30012): searchr = common.getUserInput(settings.getLocalizedString(30001), "") if searchr == None: build_main_directory() return url = "http://g4tv.com/videos/?sort=mostrecent&q=" + searchr.replace(" ", "%20") + "&ajax=true" nexturl = url html = getUrl(url + "&page=" + str(page)) wrap1 = common.parseDOM(html, "div", attrs={"class": "li-wrap-1"}) wrap2 = common.parseDOM(html, "div", attrs={"class": "li-wrap-2"}) desc = common.parseDOM(wrap1, "p", attrs={"class": "desc"}) info = common.parseDOM(wrap1, "p", attrs={"class": "meta-info"}) h4 = common.parseDOM(wrap1, "h4") title = common.parseDOM(h4, "a") href = common.parseDOM(h4, "a", ret="href") img = common.parseDOM(wrap2, "img", ret="src") if len(img) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30002) + "\n" + settings.getLocalizedString(30003)) build_main_directory() return for item_count in range(len(img)): if common.stripTags(info[item_count]).find("Views") == -1: length = common.stripTags(info[item_count]).rsplit("|")[1].replace(" ", "").split(":") else: length = common.stripTags(info[item_count]).rsplit("|")[2].replace(" ", "").split(":") duration = int(length[0]) * 60 + int(length[1]) thumb = img[item_count].replace("138x78", "256x256") plot = common.stripTags(clean(desc[item_count])) name = common.stripTags(clean(title[item_count])) try: posted = common.stripTags(info[item_count]).rsplit("|")[0].rsplit(":")[1].strip() if "ago" in posted: days = int(posted.rsplit(" ")[0]) aired = (datetime.date.today() - datetime.timedelta(days=days)).strftime("%d.%m.%Y") else: aired = datetime.datetime.fromtimestamp(time.mktime(time.strptime(posted, "%b %d, %Y"))).strftime( "%d.%m.%Y" ) infoLabels = {"Title": name, "Plot": plot, "Aired": aired} except: infoLabels = {"Title": name, "Plot": plot} url = href[item_count] u = {"mode": "3", "name": name, "url": url, "plot": plot, "thumb": thumb} addListItem( label=name, image=thumb, url=u, isFolder=False, infoLabels=infoLabels, fanart=False, duration=duration ) if len(img) >= 15: u = {"mode": "2", "name": name, "url": nexturl, "page": str(int(page) + 1)} infoLabels = {"Title": settings.getLocalizedString(30019), "Plot": settings.getLocalizedString(30019)} addListItem( label=settings.getLocalizedString(30019), image=next_thumb, url=u, isFolder=True, infoLabels=infoLabels ) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def play_video(url, name, download): data = getUrl(url) title = re.search('<meta itemprop="name" content="(.+?)">', data) thumb = re.search('<meta itemprop="thumbnailUrl" content="(.+?)">', data) trailerId = re.search( '<meta itemprop="embedUrl" content=".+traileraddict\.com/emd/(.+?)\?id=.+?">', data) if trailerId: data = getUrl('http://v.traileraddict.com/%s' % trailerId.group(1)) data = unwise.unwise_process(data) video_urls = re.compile("file:[\\\]*'(.+?)'").findall(data) else: return if title: name = urllib.unquote_plus( title.group(1)) + ' (' + settings.getLocalizedString(30017) + ')' if thumb: if thumb.group( 1 ) == 'http://www.traileraddict.com/images/noembed-removed.png': dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30012)) return if settings.getSetting('streamQuality') == '1': url = video_urls[1] else: url = video_urls[0] url = url.replace('%3A', ':').replace('%2F', '/').replace('%3F', '?').replace( '%3D', '=').replace('%26', '&').replace('%2F', '//').strip() infoLabels = {"Title": name, "Studio": plugin} if download == 'True': start_download(name, str(url)) else: playListItem(label=name, image=xbmc.getInfoImage("ListItem.Thumb"), path=str(url), infoLabels=infoLabels, PlayPath=False)
def play_video(name, url, plot, thumb): videokey = re.compile("videos/(.+?)/(.+?)/").findall(url) url = ( "http://g4tv.com/xml/broadbandplayerservice.asmx/GetEmbeddedHdVideo?videoKey=" + videokey[0][0] + "&playLargeVideo=true&excludedVideoKeys=&playlistType=normal&maxPlaylistSize=0" ) data = getUrl(url) url = clean(re.compile("&r=(.+?)</FilePath>").findall(data)[0]) infoLabels = {"Title": name, "Studio": plugin, "Plot": plot} playListItem(label=name, image=thumb, path=url, infoLabels=infoLabels)
def build_main_directory(url): data = json.loads(getUrl(url))['shows'] if settings.getSetting('folder') == 'true' and settings.getSetting( 'downloadPath' ) and url == BASE + 'getShows' + KEY: u = { 'mode': None, 'url': settings.getSetting( 'downloadPath' ) } infoLabels = { "Title": settings.getLocalizedString( 30012 ), "Plot": settings.getLocalizedString( 30022 ) } addListItem('[ ' + settings.getLocalizedString( 30012 ) + ' ]', downloads_thumb, u, True, 0, infoLabels, fanart_bg) if url == BASE + 'getShows' + KEY: #Featured u = { 'mode': '1', 'name': settings.getLocalizedString( 30023 ), 'url': BASE + 'getEpisodes' + KEY + '&grouping=featured', 'slug': 'None' } infoLabels = { "Title": settings.getLocalizedString( 30023 ), "Plot": settings.getLocalizedString( 30024 ) } addListItem('[ ' + settings.getLocalizedString( 30023 ) + ' ]', featured_thumb, u, True, 0, infoLabels, fanart_bg) #Most Recent u = { 'mode': '1', 'name': settings.getLocalizedString( 30013 ), 'url': BASE + 'getEpisodes' + KEY + '&grouping=latest', 'slug': 'None' } infoLabels = { "Title": settings.getLocalizedString( 30013 ), "Plot": settings.getLocalizedString( 30018 ) } addListItem('[ ' + settings.getLocalizedString( 30013 ) + ' ]', recent_thumb, u, True, 0, infoLabels, fanart_bg) #Networks u = { 'mode': '4' } infoLabels = { "Title": settings.getLocalizedString( 30027 ), "Plot": settings.getLocalizedString( 30028 ) } addListItem('[ ' + settings.getLocalizedString( 30027 ) + ' ]', networks_thumb, u, True, 0, infoLabels, fanart_bg) #Archived Shows u = { 'mode': '3', 'url': BASE + 'getShows' + KEY + '&grouping=archived' } infoLabels = { "Title": settings.getLocalizedString( 30014 ), "Plot": settings.getLocalizedString( 30019 ) } addListItem('[ ' + settings.getLocalizedString( 30014 ) + ' ]', archived_thumb, u, True, 0, infoLabels, fanart_bg) daily_data = {} for daily_show in data: if daily_show['parent_id'] != None: name = daily_show['name'] thumb = daily_show['images']['logo'].replace('\\','') url = BASE + 'getEpisodes' + KEY + '&show_id=' + daily_show['id'] daily_data[daily_show['parent_id']] = { 'name': name, 'url': url, 'plot': daily_show['summary'], 'thumb': thumb} totalItems = len(data) - len(daily_data) for show in data: if show['parent_id'] == None: if show['id'] in daily_data: daily_info = daily_data[show['id']] else: daily_info = 'None' slug = show['slug'] if not settings.getSetting(slug): fanart = fanart_bg else: fanart = settings.getSetting(slug) name = show['name'] #fanart = show['images']['hero'].replace('\\','') url = BASE + 'getEpisodes' + KEY + '&show_id=' + show['id'] u = { 'mode': '1', 'name': name, 'url': url, 'slug': slug, 'daily_info': daily_info } infoLabels = { "Title": name, "Plot": show['summary'] } addListItem(name, show['images']['logo'].replace('\\',''), u, True, totalItems, infoLabels, fanart) xbmcplugin.addSortMethod( handle = int(sys.argv[ 1 ]), sortMethod = xbmcplugin.SORT_METHOD_UNSORTED ) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_top_150_directory(): data = getUrl( 'http://www.traileraddict.com/top150' ) link_title_views = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a> <span style="font-size:7pt;">(.+?)</span>' ).findall( data ) item_count = 75 for list in range( 0, 150 ): if item_count == 150: item_count = 0 title = link_title_views[item_count][1] + ' ' + link_title_views[item_count][2] url = 'http://www.traileraddict.com/' + link_title_views[item_count][0] u = { 'mode': '4', 'name': clean( title.rsplit(' (')[0] ), 'url': url } addListItem(label = clean( title ), image = poster_thumb, url = u, isFolder = True, totalItems = 150, infoLabels = False) item_count = item_count + 1 xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def play_video( url, name, download ): data = getUrl( url ) url = re.compile( '<param name="movie" value="http://www.traileraddict.com/emb/(.+?)">' ).findall( data )[0] if data.find( 'watchplus()' ) > 0: url = 'http://www.traileraddict.com/fvarhd.php?tid=' + url else: url = 'http://www.traileraddict.com/fvar.php?tid=' + url data = getUrl( url ) thumb = re.compile( '&image=(.+?)&' ).findall( data )[0] title = re.compile( '&filmtitle=(.+?)&' ).findall( data ) if len(title): name = urllib.unquote_plus(title[0]) + ' (' + settings.getLocalizedString(30017) + ')' if thumb == 'http://www.traileraddict.com/images/noembed-removed.png': dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString( 30012 )) return url = re.compile( 'fileurl=(.+?)\n&vidwidth', re.DOTALL ).findall( data )[0] url = url.replace( '%3A', ':').replace( '%2F', '/' ).replace( '%3F', '?' ).replace( '%3D', '=' ).replace( '%26', '&' ).replace( '%2F', '//' ) infoLabels = { "Title": name , "Studio": plugin } if download == 'True': start_download(name, str(url)) else: playListItem(label = name, image = xbmc.getInfoImage( "ListItem.Thumb" ), path = str(url), infoLabels = infoLabels, PlayPath = False)
def build_featured_directory(page): save_page = page data = getUrl('http://www.traileraddict.com/attraction/' + str(int(page) + 1)) url_thumb_x_title = re.compile( '<a href="/trailer/(.+?)"><img src="(.+?)" border="0" alt="(.+?)" title="(.+?)" style="margin:8px 5px 2px 5px;"></a>' ).findall(data) totalItems = len(url_thumb_x_title) for url, thumb, x, title in url_thumb_x_title: title = title.rsplit(' - ') name1 = clean(title[0]) if len(title) > 1: name2 = clean(title[0]) + ' (' + clean(title[1]) + ')' else: name2 = clean(title[0]) url = 'http://www.traileraddict.com/trailer/' + url thumb = 'http://www.traileraddict.com' + thumb cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': name2, 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % name1)) u = {'mode': '5', 'name': name2, 'url': url} addListItem(label=name1, image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=False, cm=cm) u = {'mode': '6', 'page': str(int(save_page) + 1)} addListItem(label='[ Next Page (' + str(int(save_page) + 2) + ') ]', image=next_thumb, url=u, isFolder=True, totalItems=0, infoLabels=False) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("500", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_sub_directory(name, type): html = getUrl("http://g4tv.com/videos/index.html") content = common.parseDOM(html, "div", attrs={"id": "search_" + type}) filter = common.parseDOM(content, "a", attrs={"href": "#"}) count = common.parseDOM(content, "span", attrs={"class": "count"}) for item_count in range(len(filter) - 1): name = filter[item_count] url = "http://g4tv.com/videos/?sort=mostrecent&q=null&ajax=true&" + type + "=" + name.replace(" ", "+") u = {"mode": "2", "name": name, "url": url} infoLabels = {"Title": name, "Plot": name} addListItem( label=name + " " + count[item_count + 1], image=eval(type), url=u, isFolder=True, infoLabels=infoLabels ) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_networks_directory(): html = getUrl('http://revision3.com/networks') cards = common.parseDOM(html, "ul", attrs = { "class": "Cards show-grid" }) item = common.parseDOM(cards, "li", attrs = { "class": "Grid2 Card item" }) for network in item: image = common.parseDOM(network, "img", attrs = { "class": "thumbnail" }, ret="src")[0] url = common.parseDOM(network, "a", ret="href")[0] meta = common.parseDOM(network, "div", attrs = { "class": "meta" }) name = common.parseDOM(meta, "strong")[0] plot = common.parseDOM(meta, "p")[0].rsplit('\n ')[1] u = { 'mode': '5', 'url': url } infoLabels = { "Title": name, "Plot": plot } addListItem(name, image, u, True, len(item), infoLabels, fanart_bg) xbmcplugin.addSortMethod( handle = int(sys.argv[ 1 ]), sortMethod = xbmcplugin.SORT_METHOD_UNSORTED ) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def library_trailers( url, name, page, download ): url = 'http://api.traileraddict.com/?imdb=' + url data = getUrl( url ) slug = re.compile( '<link>http:\/\/www\.traileraddict\.com\/trailer\/(.+?)\/' ).findall( data ) if len(slug): slug = slug[0] else: slug = build_search_directory(name, 'library') if slug == None: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString( 30019) + name + '.') return url = 'http://www.traileraddict.com/tags/' + slug url = find_trailers( url, name, page, True ) url = 'http://www.traileraddict.com' + url play_video( url, name + ' (' + settings.getLocalizedString(30017) + ')', download )
def build_teams_directory(): html = getUrl("http://www.nba.com/video/") team_names = common.parseDOM(html, "a", attrs={"id": "nbaVidSelectLk"}) team_nicks = common.parseDOM(html, "a", attrs={"id": "nbaVidSelectLk"}, ret="onclick") item_count = 0 for title in team_names: nick = re.compile("\('teams/(.+?)'").findall(team_nicks[item_count])[0] url = ( "teams%2F" + nick + "%7Cgames%2F*%7Cchannels%2F*&team=" + title.replace(" ", "%20") + "&site=nba%2C" + nick ) u = {"mode": "0", "url": url, "section": nick + "_all"} addListItem(label=title, image=teams_thumb, url=u, isFolder=True, infoLabels=False, fanart=fanart) item_count += 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_most_watched_directory(): url = 'http://video.pbs.org/' data = getUrl( url ) list = common.parseDOM(data, "ul", attrs = { "class": "video-list clear clearfix" }) videos = common.parseDOM(list, "span", attrs = { "class": "title clear clearfix" }) img = common.parseDOM(list, "img", ret = "src") count = 0 for video in videos: program_id = common.parseDOM(video, "a", ret = "href")[0].rsplit('/')[4] title = common.parseDOM(video, "a")[0] label = clean(title) thumb = img[count] infoLabels = { "Title": label, "Director": "PBS", "Studio": clean(title.rsplit(' | ')[0]) } u = { 'mode': '0', 'name': label, 'program_id': program_id, 'topic': 'False', 'page': '0' } addListItem(label = label, image = thumb, url = u, isFolder = False, infoLabels = infoLabels, fanart = fanart) count += 1
def build_search_directory(name, url): if url != 'library': keyboard = xbmc.Keyboard('', settings.getLocalizedString(30007)) keyboard.doModal() if (keyboard.isConfirmed() == False): return search_string = keyboard.getText().replace(' ', '+') if len(search_string) == 0: return else: search_string = name data = getUrl('http://www.traileraddict.com/search.php?q=' + search_string) image = re.compile( '<center>\r\n<div style="background:url\((.*?)\);" class="searchthumb">', re.DOTALL).findall(data) link_title = re.compile( '</div><a href="/tags/(.*?)">(.*?)</a><br />').findall(data) if len(link_title) == 0: if url == 'library': return None dialog = xbmcgui.Dialog() ok = dialog.ok( plugin, settings.getLocalizedString(30009) + search_string + '.\n' + settings.getLocalizedString(30010)) build_main_directory() return item_count = 0 totalItems = len(link_title) if url == 'library': return link_title[0][0] for url, title in link_title: url = 'http://www.traileraddict.com/tags/' + url thumb = 'http://www.traileraddict.com' + image[item_count].replace( '/pthumb.php?dir=', '').replace('\r\n', '') u = {'mode': '4', 'name': clean(title), 'url': url} addListItem(label=clean(title), image=thumb, url=u, isFolder=True, totalItems=totalItems, infoLabels=False) item_count = item_count + 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_search_directory(url): if url == 'search': try: search = common.getUserInput("Enter search term", "").replace(' ','+') url = 'http://revision3.com/search/page?type=video&q=' + search + '&limit=10&page=1' except: return html = getUrl(url).encode('ascii', 'ignore') current = common.parseDOM(html, "span", attrs = { "class": "active" }) pageLoad = common.parseDOM(html, "a", ret = "onclick") try: strs = 'http://revision3.com' + pageLoad[-1:][0].rsplit('\'')[1] params = getParameters(strs) saveurl = strs.rstrip('&page=' + params['page']) + '&page=' + str( int(current[0]) + 1 ) if int(params['page']) > int(current[0]): next = True else: next = False except: next = False episodes = common.parseDOM(html, "li", attrs = { "class": "video" }) if len(episodes) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30009 ) + '\n' + settings.getLocalizedString( 30010 ) ) return for data in episodes: thumb = common.parseDOM(data, "img", ret = "src")[0] url = common.parseDOM(data, "a", attrs = { "class": "thumbnail" }, ret = "href" )[0] url = clean(url.replace('http://www.videosurf.com/webui/inc/go.php?redirect=','')).replace('&client_id=revision3','') title = clean(common.parseDOM(data, "a", attrs = { "class": "title" })[0]) plot = clean(common.stripTags(common.parseDOM(data, "div", attrs = { "class": "description" })[0])) try: studio = title.rsplit(' - ')[1] except: studio = 'Search' infoLabels = { "Title": title, "Studio": studio, "Plot": plot, "Episode": 0, "Aired": "0000-00-00" } u = { 'mode': '2', 'name': urllib.quote_plus(title), 'url': urllib.quote_plus(url), 'plot': urllib.quote_plus(infoLabels['Plot']), 'studio': urllib.quote_plus(infoLabels['Studio']), 'episode': urllib.quote_plus(str(infoLabels['Episode'])), 'thumb': urllib.quote_plus(thumb), 'date': urllib.quote_plus(infoLabels['Aired']) } addListItem(title, thumb, u, False, infoLabels, fanart_bg) if next == True: u = { 'mode': '4', 'url': urllib.quote_plus(saveurl), 'name': urllib.quote_plus(studio) } infoLabels = { "Title": settings.getLocalizedString( 30016 ), "Plot": settings.getLocalizedString( 30016 ) } addListItem(settings.getLocalizedString( 30016 ) + ' (' + str( int(current[0]) + 1 ) + ')', next_thumb, u, True, infoLabels, fanart_bg) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def library_trailers(url, name, page, download): url = 'http://api.traileraddict.com/?imdb=' + url data = getUrl(url) slug = re.compile( '<link>http:\/\/www\.traileraddict\.com\/trailer\/(.+?)\/').findall( data) if len(slug): slug = slug[0] else: slug = build_search_directory(name, 'library') if slug == None: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30019) + name + '.') return url = 'http://www.traileraddict.com/tags/' + slug url = find_trailers(url, name, page, True) url = 'http://www.traileraddict.com' + url play_video(url, name + ' (' + settings.getLocalizedString(30017) + ')', download)
def build_networks_directory(): html = getUrl('http://testtube.com/networks') cards = common.parseDOM(html, "ul", attrs={"class": "Cards show-grid"}) item = common.parseDOM(cards, "li", attrs={"class": "Grid2 Card item"}) for network in item: image = common.parseDOM(network, "img", attrs={"class": "thumbnail"}, ret="src")[0] url = common.parseDOM(network, "a", ret="href")[0] meta = common.parseDOM(network, "div", attrs={"class": "meta"}) name = common.parseDOM(meta, "strong")[0] plot = common.parseDOM(meta, "p")[0].rsplit('\n ')[1] u = {'mode': '5', 'url': url} infoLabels = {"Title": name, "Plot": plot} addListItem(name, image, u, True, len(item), infoLabels, fanart_bg) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_coming_soon_directory(): data = getUrl('http://www.traileraddict.com/comingsoon') margin_right = re.compile( '<div style=\"float:right(.*?)<div style="float:left; width:300px;', re.DOTALL).findall(data)[0] margin_left = re.compile( '<div style=\"float:left; width:300px;(.*?)<div style="clear:both;">', re.DOTALL).findall(data)[0] link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall(margin_left) item_count = 0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = {'mode': '4', 'name': clean(title), 'url': url} addListItem(label=clean(title), image=poster_thumb, url=u, isFolder=True, totalItems=totalItems, infoLabels=False) item_count = item_count + 1 link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall(margin_right) item_count = 0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = {'mode': '4', 'name': clean(title), 'url': url} addListItem(label=clean(title), image=poster_thumb, url=u, isFolder=True, totalItems=totalItems, infoLabels=False) item_count = item_count + 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_top_150_directory(): data = getUrl('http://www.traileraddict.com/top150') link_title_views = re.compile( '<li><a href="(.+?)" class="m_title">(.+?)</a></li>').findall(data) item_count = 75 for list in range(0, 149): if item_count == 149: item_count = 0 title = link_title_views[item_count][1] url = 'http://www.traileraddict.com' + link_title_views[item_count][0] u = {'mode': '4', 'name': clean(title.rsplit(' (')[0]), 'url': url} addListItem(label=clean(title), image=poster_thumb, url=u, isFolder=True, totalItems=150, infoLabels=False) item_count = item_count + 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_search_directory(): page = 1 checking = True string = common.getUserInput(settings.getLocalizedString( 30007 ), "") if not string: build_main_directory() return if settings.getSetting('playall') == 'true': playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() u = { 'mode': '4' } infoLabels = { "Title": '* ' + settings.getLocalizedString( 30030 ) + ' *', "Plot": settings.getLocalizedString( 30031 ) } addListItem('* ' + settings.getLocalizedString( 30030 ) + ' *', icon, u, False, 0, infoLabels, fanart) while checking: url = 'http://www.tmz.com/search/json/videos/' + urllib.quote(string) + '/' + str(page) + '.json' data = getPage(url) if data['error'] == 'HTTP Error 404: Not Found': dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30009 ) + '\n' + settings.getLocalizedString( 30010 ) ) return elif data['error'] != None: text = getUrl( url, True ) else: text = data['content'] jdata = json.loads(text) total = int(jdata['total']) if ((total - page * 25) > 0): page = page + 1 else: checking = False for results in jdata['results']: title = results['title'].encode('ascii', 'ignore') videoUrl = results['URL'].replace("\\", "") thumb = results['thumbnailUrl'].replace("\\", "") + '/width/490/height/266/type/3' infoLabels = { "Title": title, "Plot": title } u = { 'mode': '3', 'name': title, 'url': videoUrl, 'thumb': thumb } addListItem(label = title, image = thumb, url = u, isFolder = False, totalItems = total, infoLabels = infoLabels, fanart = fanart) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_video_directory( name ): data = getUrl( 'http://www.tmz.com/videos/', True ) textarea = '[{' + re.compile('{ name: \'' + name.upper() + '\',( )?\n allInitialJson: {(.+?)},\n (slug|noPaging)?', re.DOTALL).findall( data )[0][1].replace('\n', '').replace('results:','"results":') + '}]' query = json.loads(textarea)[0]["results"] totalItems = len(query) if settings.getSetting('playall') == 'true': playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() u = { 'mode': '4' } infoLabels = { "Title": '* ' + settings.getLocalizedString( 30030 ) + ' *', "Plot": settings.getLocalizedString( 30031 ) } addListItem('* ' + settings.getLocalizedString( 30030 ) + ' *', icon, u, False, 0, infoLabels, fanart) for videos in query: title = clean(videos['title'].replace("\\", "")).encode('ascii', 'ignore') duration = videos['duration'].replace("\\", "") videoUrl = videos['videoUrl'].replace("\\", "") thumb = videos['thumbnailUrl'].replace("\\", "") + '/width/490/height/266/type/3' try: if name == settings.getLocalizedString( 30003 ): time = title.rsplit(': ')[1].rsplit(' ')[1].rsplit('/') date = '20' + time[2] + '.' + time[0].zfill(2) + '.' + time[1] else: date = videos['activeDate'].rsplit('T')[0] except: date = '0000.00.00' if videoUrl.find('http://cdnbakmi.kaltura.com') == -1: low_id = videoUrl.split('_')[0].split('/')[-1:][0] + '_' + videoUrl.split('_')[1] high_id = videoUrl.split('_')[0].split('/')[-1:][0] + '_' + videoUrl.split('_')[1] + '/flavorId/0_' + videoUrl.split('_')[3] else: low_id = videoUrl.split('/')[9] high_id = videoUrl.split('/')[9] + '/flavorId/' + videoUrl.split('/')[11] if settings.getSetting("quality") == '0': url = 'http://cdnapi.kaltura.com/p/' + thumb.split('/')[4] + '/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' + low_id else: url = 'http://cdnapi.kaltura.com/p/' + thumb.split('/')[4] + '/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' + high_id infoLabels = { "Title": title, "Plot": title, "Duration": str(int(duration)/60), "aired": str(date) } u = { 'mode': '1', 'name': title, 'url': url, 'studio': name, 'thumb': thumb } addListItem(label = title, image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = infoLabels, fanart = fanart, duration = duration) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_coming_soon_directory(): data = getUrl( 'http://www.traileraddict.com/comingsoon' ) margin_right = re.compile( '<div style=\"float:right(.*?)<div style="float:left; width:300px;', re.DOTALL ).findall( data )[0] margin_left = re.compile( '<div style=\"float:left; width:300px;(.*?)<div style="clear:both;">', re.DOTALL ).findall( data )[0] link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall( margin_left ) item_count = 0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = { 'mode': '4', 'name': clean( title ), 'url': url } addListItem(label = clean( title ), image = poster_thumb, url = u, isFolder = True, totalItems = totalItems, infoLabels = False) item_count = item_count + 1 link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall( margin_right ) item_count = 0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = { 'mode': '4', 'name': clean( title ), 'url': url } addListItem(label = clean( title ), image = poster_thumb, url = u, isFolder = True, totalItems = totalItems, infoLabels = False) item_count = item_count + 1 xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_film_database_directory(): keyboard = xbmc.Keyboard( '', settings.getLocalizedString(30011) ) keyboard.doModal() search_string = keyboard.getText().rsplit(' ')[0] if ( (keyboard.isConfirmed() == False) or (len( search_string ) == 0) ): return data = getUrl( 'http://www.traileraddict.com/thefilms/' + search_string ) link_title = re.compile( '<img src="/images/arrow2.png" class="arrow"> <a href="(.+?)">(.+?)</a>' ).findall( data ) if len( link_title ) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString(30009) + search_string + '.\n' + settings.getLocalizedString(30013) ) build_main_directory() return item_count=0 totalItems = len(link_title) for url, title in link_title: url = 'http://www.traileraddict.com/' + url u = { 'mode': '4', 'name': clean( title ), 'url': url } addListItem(label = clean( title ), image = poster_thumb, url = u, isFolder = True, totalItems = totalItems, infoLabels = False) item_count = item_count + 1 xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_main_directory(url): path = url html = getUrl(url) shows = common.parseDOM(html, "ul", attrs = { "id": "shows" })[0] url_name = re.compile('<h3><a href="(.+?)">(.+?)</a></h3>').findall(shows) image = re.compile('class="thumbnail"><img src="(.+?)" /></a>').findall(shows) plot = common.parseDOM(shows, "p", attrs = { "class": "description" }) if settings.getSetting('folder') == 'true' and settings.getSetting( 'downloadPath' ) and path == 'http://revision3.com/shows/': u = { 'mode': None, 'url': settings.getSetting("downloadPath") } infoLabels = { "Title": settings.getLocalizedString( 30012 ), "Plot": settings.getLocalizedString( 30022 ) } addListItem('[ ' + settings.getLocalizedString( 30012 ) + ' ]', downloads_thumb, u, True, infoLabels, fanart_bg) if path == 'http://revision3.com/shows/': u = { 'mode': '1', 'name': urllib.quote_plus(settings.getLocalizedString( 30013 )), 'url': urllib.quote_plus('http://revision3.com/episodes/page?&hideArrows=1&type=recent&page=1') } infoLabels = { "Title": settings.getLocalizedString( 30013 ), "Plot": settings.getLocalizedString( 30018 ) } addListItem('[ ' + settings.getLocalizedString( 30013 ) + ' ]', current_thumb, u, True, infoLabels, fanart_bg) u = { 'mode': '3', 'url': urllib.quote_plus('http://revision3.com/shows/archive') } infoLabels = { "Title": settings.getLocalizedString( 30014 ), "Plot": settings.getLocalizedString( 30019 ) } addListItem('[ ' + settings.getLocalizedString( 30014 ) + ' ]', old_thumb, u, True, infoLabels, fanart_bg) u = { 'mode': '4', 'url': urllib.quote_plus('search') } infoLabels = { "Title": settings.getLocalizedString( 30015 ), "Plot": settings.getLocalizedString( 30020 ) } addListItem('[ ' + settings.getLocalizedString( 30015 ) + ' ]', search_thumb, u, True, infoLabels, fanart_bg) count = 0 for url, name in url_name: fanart = url.replace('/','') if not settings.getSetting(fanart): fanart = fanart_bg else: fanart = settings.getSetting(fanart) url = 'http://revision3.com' + url + '/episodes' u = { 'mode': '1', 'name': urllib.quote_plus(name), 'url': urllib.quote_plus(url) } infoLabels = { "Title": name, "Plot": clean(plot[count]) } addListItem(name, image[count].replace('160x160','200x200'), u, True, infoLabels, fanart) count += 1 xbmcplugin.addSortMethod( handle = int(sys.argv[ 1 ]), sortMethod = xbmcplugin.SORT_METHOD_UNSORTED ) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_networks_sub_directory(url, offset): saveurl = url html = getUrl('http://revision3.com' + url + '/episodePage?limit=25&offset=' + str(offset * 25)) networkItem = common.parseDOM(html, "li", attrs = { "class": "networkItem" }) if len(networkItem) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30026 ) + ' this page.' ) return if settings.getSetting('download') == '' or settings.getSetting('download') == 'false': if settings.getSetting('playall') == 'true': playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() u = { 'mode': '6' } infoLabels = { "Title": settings.getLocalizedString( 30030 ), "Plot": settings.getLocalizedString( 30031 ) } addListItem('* ' + settings.getLocalizedString( 30030 ) + ' *', play_thumb, u, True, 0, infoLabels, fanart_bg) for item in networkItem: url = common.parseDOM(item, "a", attrs = { "class": "playlistPlay clear" }, ret = "href")[0][1:] thumbnail = common.parseDOM(item, "div", attrs = { "class": "thumbnail" }) image = common.parseDOM(thumbnail, "img", ret = "src")[0].replace('small.thumb.jpg','medium.thumb.jpg') meta = common.parseDOM(item, "div", attrs = { "class": "meta" }) name = common.parseDOM(meta, "div", attrs = { "class": "title" })[0] studio = common.parseDOM(meta, "div", attrs = { "class": "showtitle" })[0] plot = common.parseDOM(meta, "div", attrs = { "class": "itemPreview" })[0].encode('ascii', 'ignore') infoLabels = { "Title": name, "Studio": studio, "Plot": plot } u = { 'mode': '2', 'name': name, 'url': url, 'plot': plot, 'studio': studio, 'episode': '0', 'thumb': image, 'date': '0000-00-00' } addListItem(name, image, u, False, len(networkItem), infoLabels, fanart_bg) if len(networkItem) == 25: u = { 'mode': '5', 'url': saveurl, 'offset': offset + 1 } infoLabels = { "Title": settings.getLocalizedString( 30016 ), "Plot": settings.getLocalizedString( 30016 ) } addListItem(settings.getLocalizedString( 30016 ) + ' (' + str( offset + 2 ) + ')', next_thumb, u, True, 0, infoLabels, fanart_bg) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_EPISODE ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_STUDIO ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME ) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_sub_directory(url, name, slug, offset, daily_info): if slug == None: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30029)) build_main_directory(BASE + 'getShows' + KEY) return saveurl = url data = json.loads(getUrl(url + '&offset=' + str(offset * 25))) if len(data['episodes']) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30026) + ' ' + name + '.') return if slug != 'None': try: downloads = 'http://testtube.com/' + slug + '/' + slug + '_downloads' fresult = getPage(downloads)['content'] match = re.compile('<a href="(.+?)" target="_blank">1920x1200</a>' ).findall(fresult) if len(match) > 1: fanart = match[1] else: fanart = match[0] settings.setSetting(slug, fanart) except: fanart = 'http://videos.testtube.com/revision3/images/shows/%s/%s_hero.jpg' % ( slug, slug) if getPage(fanart)['error'] == 'HTTP Error 404: Not Found': fanart = fanart_bg settings.setSetting(slug, fanart) else: settings.setSetting(slug, fanart) else: fanart = fanart_bg if daily_info != 'None' and settings.getSetting('daily') == 'true': daily_info = ast.literal_eval(daily_info) u = { 'mode': '1', 'name': daily_info['name'], 'url': daily_info['url'], 'slug': slug, 'daily_info': 'None' } infoLabels = {"Title": daily_info['name'], "Plot": daily_info['plot']} addListItem('[ ' + daily_info['name'] + ' ]', daily_info['thumb'], u, True, 0, infoLabels, fanart) if settings.getSetting('download') == '' or settings.getSetting( 'download') == 'false': if settings.getSetting('playall') == 'true': playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() u = {'mode': '6'} infoLabels = { "Title": settings.getLocalizedString(30030), "Plot": settings.getLocalizedString(30031) } addListItem('* ' + settings.getLocalizedString(30030) + ' *', play_thumb, u, True, 0, infoLabels, fanart) for episode in data['episodes']: studio = episode['show']['name'] thumb = episode['images']['medium'] url = episode['media'] plot = episode['summary'].encode('ascii', 'ignore') name = episode['name'].encode('ascii', 'ignore') episodenum = episode['number'] date = episode['published'].rsplit('T')[0] duration = int(episode['duration']) infoLabels = { "Title": name, "Studio": studio, "Plot": plot, "Episode": int(episodenum), "Aired": date } u = { 'mode': '2', 'name': name, 'url': url, 'plot': plot, 'studio': studio, 'episode': episodenum, 'thumb': thumb, 'date': date } addListItem(plot, thumb, u, False, len(data['episodes']), infoLabels, fanart, duration) if (int(data['total']) - ((offset + 1) * 25)) > 0: u = { 'mode': '1', 'name': studio, 'url': saveurl, 'slug': slug, 'offset': offset + 1, 'daily_info': 'None' } infoLabels = { "Title": settings.getLocalizedString(30016), "Plot": settings.getLocalizedString(30016) } addListItem( settings.getLocalizedString(30016) + ' (' + str(offset + 2) + ')', next_thumb, u, True, 0, infoLabels, fanart) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_STUDIO) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_networks_sub_directory(url, offset): saveurl = url html = getUrl('http://testtube.com' + url + '/episodePage?limit=25&offset=' + str(offset * 25)) networkItem = common.parseDOM(html, "li", attrs={"class": "networkItem"}) if len(networkItem) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30026) + ' this page.') return if settings.getSetting('download') == '' or settings.getSetting( 'download') == 'false': if settings.getSetting('playall') == 'true': playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() u = {'mode': '6'} infoLabels = { "Title": settings.getLocalizedString(30030), "Plot": settings.getLocalizedString(30031) } addListItem('* ' + settings.getLocalizedString(30030) + ' *', play_thumb, u, True, 0, infoLabels, fanart_bg) for item in networkItem: url = common.parseDOM(item, "a", attrs={"class": "playlistPlay clear"}, ret="href")[0][1:] thumbnail = common.parseDOM(item, "div", attrs={"class": "thumbnail"}) image = common.parseDOM(thumbnail, "img", ret="src")[0].replace('small.thumb.jpg', 'medium.thumb.jpg') meta = common.parseDOM(item, "div", attrs={"class": "meta"}) name = common.parseDOM(meta, "div", attrs={"class": "title"})[0].encode('ascii', 'ignore') studio = common.parseDOM(meta, "div", attrs={"class": "showtitle"})[0] plot = common.parseDOM(meta, "div", attrs={"class": "itemPreview" })[0].encode('ascii', 'ignore') infoLabels = {"Title": name, "Studio": studio, "Plot": plot} u = { 'mode': '2', 'name': name, 'url': url, 'plot': plot, 'studio': studio, 'episode': '0', 'thumb': image, 'date': '0000-00-00' } addListItem(name, image, u, False, len(networkItem), infoLabels, fanart_bg) if len(networkItem) == 25: u = {'mode': '5', 'url': saveurl, 'offset': offset + 1} infoLabels = { "Title": settings.getLocalizedString(30016), "Plot": settings.getLocalizedString(30016) } addListItem( settings.getLocalizedString(30016) + ' (' + str(offset + 2) + ')', next_thumb, u, True, 0, infoLabels, fanart_bg) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_STUDIO) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME) setViewMode("503") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def find_trailers(url, name, page, library): save_name = name save_page = page data = getUrl(url).decode('ascii', 'ignore') link_thumb = re.compile( '<a href="(.+?)"><img src="(.+?)" name="thumb').findall(data) thumbs = re.compile('img src="/psize\.php\?dir=(.+?)" style').findall(data) if len(thumbs) == 0: thumb = "DefaultVideo.png" else: thumb = 'http://www.traileraddict.com/' + thumbs[0] title = re.compile( '<div class="abstract"><h2><a href="(.+?)">(.+?)</a></h2><br />', re.DOTALL).findall(data) trailers = re.compile('<dl class="dropdown">(.+?)</dl>', re.DOTALL).findall(data) if len(title) == 0 and len(trailers) == 0: list = common.parseDOM(data, "div", attrs={"class": "info"}) header = common.parseDOM(data, "div", attrs={"class": "trailerheader"}) nexturl = common.parseDOM(header, "a", attrs={"title": "Next Page"}, ret="href") totalItems = len(list) if totalItems == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30012)) ok = dialog.ok(plugin, settings.getLocalizedString(30051)) buggalo.addExtraData('url', url) buggalo.addExtraData('name', name) raise Exception('find_trailers Error A') return for video in list: h2 = common.parseDOM(video, "h2") title = common.parseDOM(h2, "a")[0] url = 'http://www.traileraddict.com' + common.parseDOM( h2, "a", ret="href")[0] thumb = 'http://www.traileraddict.com' + common.parseDOM( video, "img", attrs={"class": "dimmer"}, ret="src")[0].replace( '-t.jpg', '.jpg') #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode( { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name)) u = { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url } addListItem(label=clean(title), image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=False, cm=cm) if len(nexturl) > 0: url = 'http://www.traileraddict.com' + nexturl[0] u = { 'mode': '4', 'name': save_name, 'url': url, 'page': str(int(save_page) + 1) } addListItem(label='[Next Page (' + str(int(save_page) + 2) + ')]', image=next_thumb, url=u, isFolder=True, totalItems=0, infoLabels=False) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("502", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1])) return item_count = 0 if len(trailers) > 0: check1 = re.compile( '<a href="(.+?)"><img src="\/images\/usr\/arrow\.png" border="0" style="float:right;" \/>(.+?)</a>' ).findall(trailers[0]) check2 = re.compile( '<a href="(.+?)"( style="(.*?)")?>(.+?)<br />').findall( trailers[0]) totalItems = len(check1) totalItems2 = len(check2) if totalItems > 0: url_title = check1 if library == True: return url_title[0][0] for url, title in url_title: url = 'http://www.traileraddict.com' + url cm = [] run = sys.argv[0] + '?' + urllib.urlencode( { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name)) infoLabels = { "Title": title, "Plot": save_name + ' (' + clean(title) + ')' } u = { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url } addListItem(label=clean(title), image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=False, cm=cm) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("502", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1])) elif totalItems2 > 0: url_title = check2 if library == True: return url_title[0][0] for url, trash1, trash2, title in url_title: url = 'http://www.traileraddict.com' + url #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name.decode('ascii', 'ignore') + ' (' + clean(title) + ')', 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name.decode('ascii', 'ignore'))) u = { 'mode': '5', 'name': save_name.decode('ascii', 'ignore') + ' (' + clean(title) + ')', 'url': url } addListItem(label=clean(title), image=thumb, url=u, isFolder=False, totalItems=totalItems2, infoLabels=False, cm=cm) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("502", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1])) else: # dia = xbmcgui.Dialog() # ok = dia.ok(plugin, settings.getLocalizedString(30006) ) # ok = dia.ok(plugin, settings.getLocalizedString( 30051 )) # buggalo.addExtraData('url', url) # buggalo.addExtraData('name', save_name) # raise Exception('find_trailers Error 2') # xbmc.executebuiltin('Notification('+plugin+',Only video clips were found!,5000,'+icon_thumb+')') list = common.parseDOM(data, "div", attrs={"class": "info"}) header = common.parseDOM(data, "div", attrs={"class": "trailerheader"}) nexturl = common.parseDOM(header, "a", attrs={"title": "Next Page"}, ret="href") totalItems = len(list) if totalItems == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30012)) ok = dialog.ok(plugin, settings.getLocalizedString(30051)) buggalo.addExtraData('url', url) buggalo.addExtraData('name', name) raise Exception('find_trailers Error B') return for video in list: h2 = common.parseDOM(video, "h2") title = common.parseDOM(h2, "a")[0] url = 'http://www.traileraddict.com' + common.parseDOM( h2, "a", ret="href")[0] thumb = 'http://www.traileraddict.com' + common.parseDOM( video, "img", attrs={"class": "dimmer"}, ret="src")[0].replace('-t.jpg', '.jpg') #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode( { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name)) u = { 'mode': '5', 'name': save_name + ' (' + clean(title) + ')', 'url': url } addListItem(label=clean(title), image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=False, cm=cm) if len(nexturl) > 0: url = 'http://www.traileraddict.com' + nexturl[0] u = { 'mode': '4', 'name': save_name, 'url': url, 'page': str(int(save_page) + 1) } addListItem(label='[Next Page (' + str(int(save_page) + 2) + ')]', image=next_thumb, url=u, isFolder=True, totalItems=0, infoLabels=False) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("502", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1])) else: totalItems = len(link_thumb) for url, thumb2 in link_thumb: if clean(title[item_count][1]).find('Trailer') > 0: url = 'http://www.traileraddict.com' + url cm = [] run = sys.argv[0] + '?' + urllib.urlencode( { 'mode': '5', 'name': save_name + ' (' + clean(title[item_count][1]) + ')', 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name)) infoLabels = { "Title": title[item_count][1], "Plot": save_name + ' (' + clean(title[item_count][1]) + ')' } u = { 'mode': '5', 'name': save_name + ' (' + clean(title[item_count][1]) + ')', 'url': url } addListItem(label=clean(title[item_count][1]), image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=False, cm=cm) item_count = item_count + 1 xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("502", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1]))
except Exception, e: print 'PBS - Using backup_url' if backup_url != 'None': infoLabels = { "Title": name , "Studio": "PBS: " + studio, "Plot": plot } playListItem(label = name, image = thumb, path = clean(backup_url), infoLabels = infoLabels, PlayPath = False) return else: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30008 ) ) ok = dialog.ok(plugin, settings.getLocalizedString( 30051 )) buggalo.addExtraData('url', url) buggalo.addExtraData('error', str(e)) buggalo.addExtraData('info', studio + ' - ' + name) raise Exception("redirect_url ERROR") return data = getUrl( url + '&format=SMIL' ) print 'PBS - ' + studio + ' - ' + name try: print data except: pass try: msg = common.parseDOM(data, "ref", ret = "title")[0] if msg == 'Unauthorized': dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30008 ) ) return if msg == 'Unavailable': dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30015 ) + '\n' + settings.getLocalizedString( 30016 ) ) return
def find_trailers( url, name, page, library ): save_name = name save_page = page data = getUrl( url ).decode('ascii', 'ignore') link_thumb = re.compile( '<a href="(.+?)"><img src="(.+?)" name="thumb' ).findall( data ) thumbs = re.compile( 'img src="/psize\.php\?dir=(.+?)" style' ).findall( data ) if len( thumbs ) == 0: thumb = "DefaultVideo.png" else: thumb = 'http://www.traileraddict.com/' + thumbs[0] title = re.compile( '<div class="abstract"><h2><a href="(.+?)">(.+?)</a></h2><br />', re.DOTALL ).findall( data ) trailers = re.compile( '<dl class="dropdown">(.+?)</dl>', re.DOTALL ).findall( data ) if len(title) == 0 and len(trailers) == 0: list = common.parseDOM(data, "div", attrs = { "class": "info" }) header = common.parseDOM(data, "div", attrs = { "class": "trailerheader" }) nexturl = common.parseDOM(header, "a", attrs = { "title": "Next Page" }, ret = "href") totalItems = len(list) if totalItems == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString( 30012 )) ok = dialog.ok(plugin, settings.getLocalizedString( 30051 )) buggalo.addExtraData('url', url) buggalo.addExtraData('name', name) raise Exception('find_trailers Error A') return for video in list: h2 = common.parseDOM(video, "h2") title = common.parseDOM(h2, "a")[0] url = 'http://www.traileraddict.com' + common.parseDOM(h2, "a", ret = "href")[0] thumb = 'http://www.traileraddict.com' + common.parseDOM(video, "img", attrs = { "class": "dimmer" }, ret = "src")[0].replace('-t.jpg','.jpg') #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name) ) u = { 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url } addListItem(label = clean( title ), image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) if len(nexturl) > 0: url = 'http://www.traileraddict.com' + nexturl[0] u = { 'mode': '4', 'name': save_name, 'url': url, 'page': str( int( save_page ) + 1 ) } addListItem(label = '[Next Page (' + str( int( save_page ) + 2 ) + ')]', image = next_thumb, url = u, isFolder = True, totalItems = 0, infoLabels = False) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("502", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) ) return item_count = 0 if len( trailers ) > 0: check1 = re.compile( '<a href="(.+?)"><img src="\/images\/usr\/arrow\.png" border="0" style="float:right;" \/>(.+?)</a>' ).findall( trailers[0] ) check2 = re.compile( '<a href="(.+?)"( style="(.*?)")?>(.+?)<br />' ).findall( trailers[0] ) totalItems = len( check1 ) totalItems2 = len( check2 ) if totalItems > 0: url_title = check1 if library == True: return url_title[0][0] for url, title in url_title: url = 'http://www.traileraddict.com' + url cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name) ) infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } u = { 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url } addListItem(label = clean( title ), image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("502", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) ) elif totalItems2 > 0: url_title = check2 if library == True: return url_title[0][0] for url, trash1, trash2, title in url_title: url = 'http://www.traileraddict.com' + url #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name.decode('ascii', 'ignore') + ' (' + clean( title ) + ')', 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name.decode('ascii', 'ignore')) ) u = { 'mode': '5', 'name': save_name.decode('ascii', 'ignore') + ' (' + clean( title ) + ')', 'url': url } addListItem(label = clean( title ), image = thumb, url = u, isFolder = False, totalItems = totalItems2, infoLabels = False, cm = cm) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("502", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) ) else: # dia = xbmcgui.Dialog() # ok = dia.ok(plugin, settings.getLocalizedString(30006) ) # ok = dia.ok(plugin, settings.getLocalizedString( 30051 )) # buggalo.addExtraData('url', url) # buggalo.addExtraData('name', save_name) # raise Exception('find_trailers Error 2') # xbmc.executebuiltin('Notification('+plugin+',Only video clips were found!,5000,'+icon_thumb+')') list = common.parseDOM(data, "div", attrs = { "class": "info" }) header = common.parseDOM(data, "div", attrs = { "class": "trailerheader" }) nexturl = common.parseDOM(header, "a", attrs = { "title": "Next Page" }, ret = "href") totalItems = len(list) if totalItems == 0: dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString( 30012 )) ok = dialog.ok(plugin, settings.getLocalizedString( 30051 )) buggalo.addExtraData('url', url) buggalo.addExtraData('name', name) raise Exception('find_trailers Error B') return for video in list: h2 = common.parseDOM(video, "h2") title = common.parseDOM(h2, "a")[0] url = 'http://www.traileraddict.com' + common.parseDOM(h2, "a", ret = "href")[0] thumb = 'http://www.traileraddict.com' + common.parseDOM(video, "img", attrs = { "class": "dimmer" }, ret = "src")[0].replace('-t.jpg','.jpg') #infoLabels = { "Title": title, "Plot": save_name + ' (' + clean( title ) + ')' } cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name) ) u = { 'mode': '5', 'name': save_name + ' (' + clean( title ) + ')', 'url': url } addListItem(label = clean( title ), image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) if len(nexturl) > 0: url = 'http://www.traileraddict.com' + nexturl[0] u = { 'mode': '4', 'name': save_name, 'url': url, 'page': str( int( save_page ) + 1 ) } addListItem(label = '[Next Page (' + str( int( save_page ) + 2 ) + ')]', image = next_thumb, url = u, isFolder = True, totalItems = 0, infoLabels = False) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("502", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) ) else: totalItems = len(link_thumb) for url, thumb2 in link_thumb: if clean( title[item_count][1] ).find( 'Trailer' ) > 0: url = 'http://www.traileraddict.com' + url cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': save_name + ' (' + clean( title[item_count][1] ) + ')', 'url': url, 'download': 'True' }) cm.append( (settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run) ) cm.append( (settings.getLocalizedString(30014), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % save_name) ) infoLabels = { "Title": title[item_count][1], "Plot": save_name + ' (' + clean( title[item_count][1] ) + ')' } u = { 'mode': '5', 'name': save_name + ' (' + clean( title[item_count][1] ) + ')', 'url': url } addListItem(label = clean( title[item_count][1] ), image = thumb, url = u, isFolder = False, totalItems = totalItems, infoLabels = False, cm = cm) item_count = item_count + 1 xbmcplugin.addSortMethod( handle = int( sys.argv[1] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("502", "movies") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def get_video(url, name, plot, studio, episode, thumb, date): if '{' in url: url = ast.literal_eval(url) try: path = url[settings.getSetting('format').lower().replace( 'hd', 'hd720p30').replace('high', 'large').replace('low', 'small')]['url'] except: if 'hd' in url: path = url['hd']['url'] elif 'large' in url: path = url['large']['url'] elif 'small' in url: path = url['small']['url'] else: path = url.items()[0][1]['url'] else: oembed = getUrl( 'http://testtube.com/api/oembed/?url=http://testtube.com/%s/&format=json' % url) video_id = re.compile('html5player\-v(.+?)\?external').findall( oembed)[0] api = getUrl('http://testtube.com/api/flash?video_id=' + video_id) videos_api = common.parseDOM(api, "media", ret="type") videos_api[:] = (value for value in videos_api if value != 'thumbnail') durl = {} for type_api in videos_api: content_api = clean( common.parseDOM(api, "media", attrs={"type": type_api})[0]) durl[type_api] = content_api try: path = durl[settings.getSetting('format').lower()] except: if 'high' in durl: path = durl['high'] elif 'low' in durl: path = durl['low'] else: path = str(durl.items()[0][1]) if settings.getSetting('download') == 'true': while not settings.getSetting('downloadPath'): if settings.getSetting('download') == 'false': xbmc.executebuiltin("Container.Refresh") return dialog = xbmcgui.Dialog() ok = dialog.ok(plugin, settings.getLocalizedString(30011)) settings.openSettings() params = { "url": path, "download_path": settings.getSetting('downloadPath'), "Title": name } downloader.download( clean_file(name) + '.' + path.split('/')[-1].split('.')[-1], params) else: infoLabels = { "Title": name, "Studio": 'TestTube: ' + studio, "Plot": plot, "Episode": int(episode), "Aired": date } playListItem(label=name, image=thumb, path=path, infoLabels=infoLabels, PlayPath=False)
def build_main_directory(url): data = json.loads(getUrl(url))['shows'] if settings.getSetting('folder') == 'true' and settings.getSetting( 'downloadPath') and url == BASE + 'getShows' + KEY: u = {'mode': None, 'url': settings.getSetting('downloadPath')} infoLabels = { "Title": settings.getLocalizedString(30012), "Plot": settings.getLocalizedString(30022) } addListItem('[ ' + settings.getLocalizedString(30012) + ' ]', downloads_thumb, u, True, 0, infoLabels, fanart_bg) if url == BASE + 'getShows' + KEY: #Featured u = { 'mode': '1', 'name': settings.getLocalizedString(30023), 'url': BASE + 'getEpisodes' + KEY + '&grouping=featured', 'slug': 'None' } infoLabels = { "Title": settings.getLocalizedString(30023), "Plot": settings.getLocalizedString(30024) } addListItem('[ ' + settings.getLocalizedString(30023) + ' ]', featured_thumb, u, True, 0, infoLabels, fanart_bg) #Most Recent u = { 'mode': '1', 'name': settings.getLocalizedString(30013), 'url': BASE + 'getEpisodes' + KEY + '&grouping=latest', 'slug': 'None' } infoLabels = { "Title": settings.getLocalizedString(30013), "Plot": settings.getLocalizedString(30018) } addListItem('[ ' + settings.getLocalizedString(30013) + ' ]', recent_thumb, u, True, 0, infoLabels, fanart_bg) # #Networks # u = { 'mode': '4' } # infoLabels = { "Title": settings.getLocalizedString( 30027 ), "Plot": settings.getLocalizedString( 30028 ) } # addListItem('[ ' + settings.getLocalizedString( 30027 ) + ' ]', networks_thumb, u, True, 0, infoLabels, fanart_bg) # #Archived Shows # u = { 'mode': '3', 'url': BASE + 'getShows' + KEY + '&grouping=archived' } # infoLabels = { "Title": settings.getLocalizedString( 30014 ), "Plot": settings.getLocalizedString( 30019 ) } # addListItem('[ ' + settings.getLocalizedString( 30014 ) + ' ]', archived_thumb, u, True, 0, infoLabels, fanart_bg) daily_data = {} for daily_show in data: if daily_show['parent_id'] != None: name = daily_show['name'] thumb = daily_show['images']['logo'].replace('\\', '') url = BASE + 'getEpisodes' + KEY + '&show_id=' + daily_show['id'] daily_data[daily_show['parent_id']] = { 'name': name, 'url': url, 'plot': daily_show['summary'], 'thumb': thumb } totalItems = len(data) - len(daily_data) for show in data: if show['parent_id'] == None: if show['id'] in daily_data: daily_info = daily_data[show['id']] else: daily_info = 'None' slug = show['slug'] if not settings.getSetting(slug): fanart = fanart_bg else: fanart = settings.getSetting(slug) name = show['name'] #fanart = show['images']['hero'].replace('\\','') url = BASE + 'getEpisodes' + KEY + '&show_id=' + show['id'] u = { 'mode': '1', 'name': name, 'url': url, 'slug': slug, 'daily_info': daily_info } infoLabels = {"Title": name, "Plot": show['summary']} addListItem(name, show['images']['logo'].replace('\\', ''), u, True, totalItems, infoLabels, fanart) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) setViewMode("515") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_sub_directory(url, thumb): saveurl = url html = getUrl('http://espn.go.com/video/') html = html.decode('UTF-8','ignore') #Swedemon/Mrdally204 Change 2015-08-31 menu = common.parseDOM(html, "div", attrs = { "id": url }) channel = common.parseDOM(menu, "li", attrs = { "class": "channel" }) title = common.parseDOM(channel, "a") id = common.parseDOM(menu, "li", attrs = { "class": "channel" }, ret = "id") item_count = 0 if saveurl == 'menu2949050': shows=[ ( settings.getLocalizedString( 30009 ), 'sportscenter' ), ( settings.getLocalizedString( 30010 ), 'first%20take' ), ( settings.getLocalizedString( 30011 ), 'pti' ), ( settings.getLocalizedString( 30012 ), 'ath' ), ( 'Mike and Mike', 'mike%20and%20mike' ), ( 'Outside the Lines', 'outside%the%lines' ), ( 'E:60', 'e:60' ), ( 'Olbermann', 'olbermann' ), ( 'SC Featured', 'sc%20featured' ), ( 'Wider World of Sports', 'wider%20world%20of%20sports' ), ( 'This is Sportscenter', 'this%20is%20sportscenter' ), ( 'Grantland', 'grantland' ) ] for name, search in shows: url = 'http://search.espn.go.com/results?searchString=' + search + '&start=0&dims=6' u = { 'mode': '2', 'name': settings.getLocalizedString( 30005 ), 'url': url, 'type': 'history' } infoLabels = { "Title": name, "Plot": name } addListItem(label = name, image = tvshows_thumb, url = u, isFolder = True, infoLabels = infoLabels) if saveurl == 'menu2949049': categories=[ ( 'The Latest', 'the%20latest' ), ( 'NFL', 'nfl' ), ( 'NBA', 'nba' ), ( 'NHL', 'nhl' ), ( 'MLB', 'mlb' ), ( 'Tennis', 'tennis' ), ( 'NASCAR', 'nascar' ), ( 'Golf', 'golf' ), ( 'Boxing', 'boxing' ), ( 'MMA', 'mma' ), ( 'Action Sports', 'action%20sports' ), ( 'College Football', 'college%20football' ), ( 'College Hoops', 'college%20hoops' ), ( 'ESPN FC', 'espn%20fc' ), ( 'ESPNcricinfo', 'espncricinfo' ), ( 'ESPNU', 'espnu' ), ( 'Fantasy', 'fantasy' ), ( 'Racing', 'racing' ), ( 'Sport Science', 'sport%20science' ), ( "Women's Basketball", "women's%20basketball" ) ] for name, search in categories: url = 'http://search.espn.go.com/results?searchString=' + search + '&start=0&dims=6' u = { 'mode': '2', 'name': settings.getLocalizedString( 30005 ), 'url': url, 'type': 'history' } infoLabels = { "Title": name, "Plot": name } addListItem(label = name, image = tvshows_thumb, url = u, isFolder = True, infoLabels = infoLabels) for name in title: name = name.rsplit('(')[0] url = 'http://espn.go.com/video/format/libraryPlaylist?categoryid=' + id[item_count].replace('channel','') u = { 'mode': '2', 'name': name, 'url': url, 'type': 'null' } infoLabels = { "Title": name, "Plot": name } addListItem(label = name, image = thumb, url = u, isFolder = True, infoLabels = infoLabels) item_count += 1 xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
def build_features_list(save_page): metaget = metahandlers.MetaData() form_data = {'page': save_page} data = getUrl('http://www.traileraddict.com/ajax/features_home.php', form_data=form_data) movie_info = re.compile( 'class="featured_box[ sp rb]*">(.+?)</a>[\\r\\n\\t]+</div>', re.DOTALL).findall(data) for movie in movie_info: url_thumb_x_title = re.compile( '<a href="(.+?)" class="movie_img" title="(.+?)"><img alt=".+?" src="(.+?)" />' ).findall(movie) totalItems = len(url_thumb_x_title) for url, title, thumb in url_thumb_x_title: title = title.rsplit(' - ') name1 = clean(title[0]) if len(title) > 1: name2 = clean(title[0]) + ' (' + clean(title[1]) + ')' else: name2 = clean(title[0]) url = 'http://www.traileraddict.com' + url thumb = 'http:' + thumb cm = [] run = sys.argv[0] + '?' + urllib.urlencode({ 'mode': '5', 'name': name2, 'url': url, 'download': 'True' }) cm.append((settings.getLocalizedString(30059), "XBMC.RunPlugin(%s)" % run)) cm.append((settings.getLocalizedString( 30014 ), "XBMC.RunPlugin(plugin://plugin.video.couchpotato_manager/movies/add?title=%s)" % name1)) cm.append(('Show Information', 'XBMC.Action(Info)')) u = {'mode': '5', 'name': name2, 'url': url} #Try to clean up the name as best we can before grabbing meta data scrape_name = name1.lower().replace( 'theatrical trailer', '').replace('feature trailer', '').replace('international trailer', '').replace( 'final trailer', '').replace('red band', '').replace( 'feature red band', '').replace('international red band ', '').replace('trailer', '') meta = metaget.get_meta('movie', scrape_name) meta['title'] = name1 meta['trailer'] = '' addListItem(label=name1, image=thumb, url=u, isFolder=False, totalItems=totalItems, infoLabels=meta, cm=cm) if save_page < 94: u = {'mode': '6', 'page': str(int(save_page) + 1)} addListItem(label='[Next Page (' + str(int(save_page) + 1) + ')]', image=next_thumb, url=u, isFolder=True, totalItems=0, infoLabels=False) xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE) setViewMode("500", "movies") xbmcplugin.endOfDirectory(int(sys.argv[1]))
def build_video_directory(url, name, type): nextname = name if name == settings.getLocalizedString( 30005 ): if page == 0 and type != 'history': try: newStr = common.getUserInput(settings.getLocalizedString( 30005 ), '').replace(' ','%20') except: return presets = settings.getSetting( "presets_search" ) if presets == '': save_str = newStr else: if presets.find(newStr + ' |') == -1: save_str = presets + ' | ' + newStr else: save_str = presets settings.setSetting("presets_search", save_str) else: newStr = getParameters(url)["searchString"] url = 'http://search.espn.go.com/results?searchString=' + newStr + '&start=' + str(int(page) * 16) + '&dims=6' nexturl = url html = getUrl(url).decode('ascii', 'ignore') html = html.decode('UTF-8','ignore') #Swedemon/Mrdally204 Change 2015-08-31 results = common.parseDOM(html, "li", attrs = { "class": "result video-result" }) titledata = common.parseDOM(results, "h3") title = common.parseDOM(titledata, "a", attrs = { "rel": "nofollow" }) if len(title) == 0: dialog = xbmcgui.Dialog() ok = dialog.ok( plugin , settings.getLocalizedString( 30013 ) + '\n' + settings.getLocalizedString( 30014 ) ) remove_menu(newStr,'search') return img = common.parseDOM(results, "a", attrs = { "class": "list-thumb" }) desc = common.parseDOM(results, "p") thumb = common.parseDOM(img, "img", ret = "src" ) pagenum = common.parseDOM(html, "div", attrs = { "class": "page-numbers" })[0] maxlength = common.parseDOM(pagenum, "span")[1].replace('of ','') value = common.parseDOM(pagenum, "input", attrs = { "id": "page-number" }, ret = "value" )[0] pagecount = [ value, maxlength ] else: nexturl = url html = getUrl(url + "&pageNum=" + str(int(page)) + "&sortBy=&assetURL=http://assets.espn.go.com&module=LibraryPlaylist&pagename=vhub_index") html = html.decode('UTF-8','ignore') #Swedemon/Mrdally204 Change 2015-08-31 videocell = common.parseDOM(html, "div", attrs = { "class": "video-cell" }) title = common.parseDOM(videocell, "h5") thumb = common.parseDOM(videocell, "img", ret = "src") desc = common.parseDOM(common.parseDOM(videocell, "p", attrs = { "class": "watch-now" }), "a", ret = "href") try: pagecount = common.parseDOM(html, "div", attrs = { "class": "page-numbers" })[0].rsplit(' of ') except: pagecount = '' item_count = 0 #print 'videocell='+str(videocell)+'title='+str(title)+'thumb='+str(thumb)+'desc='+str(desc)+'pagecount='+str(pagecount) for name in title: if '/espn360/' not in thumb[item_count]: if 'http://' in desc[item_count]: plot = name else: plot = desc[item_count] try: data = thumb[item_count].replace('_thumdnail_wbig.jpg','').replace('.jpg','').rsplit('motion/') url = data[1] except: data = thumb[item_count].replace('_thumdnail_wbig.jpg','').replace('.jpg','').rsplit('/')[-4:] if len(data) >= 4: url = data[0] + '/' + data[1] + '/' + data[2] + '/' + data[3] else: url = 'null' thumbnailImage = thumb[item_count].replace('_thumdnail_wbig','') u = { 'mode': '3', 'name': name, 'url': url.replace('motion/',''), 'thumb': thumbnailImage, 'plot': plot } infoLabels = { "Title": name, "Plot": plot } addListItem(label = name, image = thumbnailImage, url = u, isFolder = False, infoLabels = infoLabels) item_count += 1 if pagecount and pagecount[0] != pagecount[1]: u = { 'mode': '2', 'name': nextname, 'url': nexturl, 'page': str(int(page) + 1), 'type': 'null' } infoLabels = { "Title": settings.getLocalizedString( 30003 ), "Plot": settings.getLocalizedString( 30003 ) } addListItem(label = settings.getLocalizedString( 30003 ), image = next_thumb, url = u, isFolder = True, infoLabels = infoLabels) xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod = xbmcplugin.SORT_METHOD_NONE ) setViewMode("503") xbmcplugin.endOfDirectory( int( sys.argv[1] ) )