sources.append(media) source = urlresolver.choose_source(sources) if source: stream_url = source.resolve() else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({ 'mode': 'movies', 'section': 'movies' }, {'title': 'Movies'}, img=IconPath + 'Movies.png') addon.add_directory({'mode': 'tv', 'section': 'tv'}, {'title': 'TV Shows'}) addon.add_directory({'mode': 'resolver_settings'}, {'title': 'Resolver Settings'}, is_folder=False, img=IconPath + 'Resolver_Settings.png') elif mode == 'movies': addon.add_directory({ 'mode': 'moviesaz', 'section': 'moviesaz' }, {'title': 'A-Z'}, img=IconPath + "AZ.png") addon.add_directory({
elif mode == 'tv': browse = addon.queries.get('browse', False) if browse == 'alpha': letter = addon.queries.get('letter', False) if letter: url = 'http://tubeplus.me/browse/tv-shows/All_Genres/%s/' % letter html = net.http_GET(url).content r = '<div class="list_item.+?src="(.+?)".+?<a class="plot".+?' + \ 'href="(.+?)".+?<b>(.+?)<\/b>.+?<\/b>(.+?)<' regex = re.finditer(r, html, re.DOTALL) for s in regex: thumb, url, title, plot = s.groups() addon.add_directory({ 'mode': 'series', 'url': base_url + url }, {'title': title}, img=base_url + thumb) else: addon.add_directory( { 'mode': 'tv', 'browse': 'alpha', 'letter': '-' }, {'title': '#'}) for l in string.uppercase: addon.add_directory( { 'mode': 'tv', 'browse': 'alpha',
dialog = xbmcgui.Dialog() index = dialog.select('Choose a video source', roles) if index >= 0: stream_url = links[index] else: stream_url = False else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({'mode': 'plinkett', 'url': MainUrl}, {'title': 'Plinkett Reviews'}, img=IconPath + 'plinkett.jpg') addon.add_directory({'mode': 'halfbag', 'url': MainUrl + 'half-in-the-bag/'}, {'title': 'Half in the Bag'}, img=IconPath + 'halfbag.jpg') addon.add_directory({'mode': 'featurefilms', 'url': MainUrl + 'films/'}, {'title': 'Feature Films'}) addon.add_directory({'mode': 'shortfilms', 'url': MainUrl + 'shorts/'}, {'title': 'Short Films'}) elif mode == 'plinkett': url = addon.queries['url'] html = get_http_error(url) r = re.search('Plinkett Reviews</a>.+?<ul class="sub-menu">(.+?)</ul>', html, re.DOTALL) if r: match = re.compile('<li.+?><a href="(.+?)">(.+?)</a></li>').findall(r.group(1)) else: match = None # Add each link found as a directory item
elif mode == 'mainexit': sys_exit() mainmenu() elif mode == 'tvchannels': tvchannels() elif mode == 'classics': print 'Retrieving: %s' % url html = net.http_GET(url).content page = int(page_num) if page > 1: addon.add_directory({'mode': 'mainexit'}, {'title': '[COLOR red]Back to Main Menu[/COLOR]'}, img=icon_path + 'back_arrow.png') if page < 4: page = page + 1 addon.add_directory({'mode': 'classics', 'url': classic_shows_url % page, 'page_num': page}, {'title': '[COLOR blue]Next Page[/COLOR]'}, img=icon_path + 'next_arrow.png') match = re.compile('<a Title="" href="(.+?)" target="img_m"><img border="0" src="(.+?)" style="filter:alpha\(opacity=50\); -moz-opacity:0.5" onMouseover="lightup\(this, 100\)" onMouseout="lightup\(this, 30\)" width="110" height="80"></a>(.+?)</td>').findall(html) for link, thumb, name in match: if not re.search('http://', thumb): thumb = main_url + thumb addon.add_video_item({'mode': 'channel', 'url': link}, {'title': name}, img=thumb) elif mode == 'livetv': print 'Retrieving: %s' % url html = net.http_GET(url).content
index = dialog.select('Choose a video source', roles) if index >= 0: stream_url = links[index] else: stream_url = False else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({ 'mode': 'plinkett', 'url': MainUrl }, {'title': 'Plinkett Reviews'}, img=IconPath + 'plinkett.jpg') addon.add_directory( { 'mode': 'halfbag', 'url': MainUrl + 'half-in-the-bag/' }, {'title': 'Half in the Bag'}, img=IconPath + 'halfbag.jpg') addon.add_directory({ 'mode': 'featurefilms', 'url': MainUrl + 'films/' }, {'title': 'Feature Films'}) addon.add_directory({ 'mode': 'shortfilms', 'url': MainUrl + 'shorts/'
url = BASE_URL + '/browse/' + section + suffix GetTitles(section, url, startPage= 1, numOfPages= 3) def GetSeasons(section, url, img): xbmcplugin.setContent( int( sys.argv[1] ), 'seasons' ) print 'Seasons for TV Show' html = net.http_GET(url).content match = re.search( 'coverImage">.+?src="(.+?)"', html, re.IGNORECASE | re.MULTILINE | re.DOTALL) img = match.group(1) shows = re.compile('<a class="behavior_trigger_season.+?id="trigger_(.+?)"(.+?)<h4>', re.DOTALL).findall(html) if not shows: print 'couldn\'t find seasons' else: for season_name, episodes in shows: season_name = season_name.replace( '_', ' ') addon.add_directory({'mode': 'GetEpisodes', 'section': section, 'img': img, 'episodes': episodes.encode('utf-8')}, {'title': season_name}, img= img) xbmcplugin.endOfDirectory(int(sys.argv[1])) def remove_accents(input_str): nkfd_form = unicodedata.normalize('NFKD', unicode(input_str)) return u"".join([c for c in nkfd_form if not unicodedata.combining(c)]) def GetEpisodes(section, img, episodes): print 'in Get Episodes' xbmcplugin.setContent( int( sys.argv[1] ), 'episodes' ) episodes = re.compile('epnomber.+?href="(.+?)">(.+?)<.+?/episode-.+?/">(.+?)<.+?/episode-.+?/.+?>(.+?)<', re.IGNORECASE | re.MULTILINE | re.DOTALL).findall(episodes) for epurl, epnbr, title, numOfLinks in episodes: title = HTMLParser.HTMLParser().unescape(title) #title = unicode_urlencode(title) addon.add_directory({'mode': 'GetLinks', 'section': section, 'url': BASE_URL + epurl}, {'title': epnbr + ' - ' + title + ' (' + numOfLinks.strip() + ')'}, img= img)
elif mode == 'tv': browse = addon.queries.get('browse', False) if browse == 'alpha': letter = addon.queries.get('letter', False) if letter: url = 'http://tubeplus.me/browse/tv-shows/All_Genres/%s/' % letter html = net.http_GET(url).content r = '<div class="list_item.+?src="(.+?)".+?<a class="plot".+?' + \ 'href="(.+?)".+?<b>(.+?)<\/b>.+?<\/b>(.+?)<' regex = re.finditer(r, html, re.DOTALL) for s in regex: thumb, url, title, plot = s.groups() addon.add_directory({'mode': 'series', 'url': base_url + url}, {'title': title}, img=base_url+thumb) else: addon.add_directory({'mode': 'tv', 'browse': 'alpha', 'letter': '-'}, {'title': '#'}) for l in string.uppercase: addon.add_directory({'mode': 'tv', 'browse': 'alpha', 'letter': l}, {'title': l}) else: addon.add_directory({'mode': 'tv', 'browse': 'alpha'}, {'title': 'A-Z'}) elif mode == 'movies':
elif re.search('mms:', embedcode): stream_url = re.search('"(mms:.+?)"', embedcode).group(1) elif re.search('rtsp://', embedcode): stream_url = re.search('"(rtsp://.+?)"', embedcode).group(1) elif re.search('blogspot.com', embedcode): stream_url = get_blogspot(embedcode) elif re.search('bitgravity', embedcode): stream_url = re.search('<param name="flashvars" value="File=(.+?)\?', embedcode).group(1) #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({'mode': 'channels', 'url': main_url + 'videos'}, {'title': 'Channels'}, img='') addon.add_directory({'mode': 'parsexml', 'url': rss_recent}, {'title': 'Recently Added'}, img='') addon.add_directory({'mode': 'parsexml', 'url': rss_views}, {'title': 'Most Viewed'}, img='') addon.add_directory({'mode': 'parsexml','url': rss_rating}, {'title': 'Top Rated'}, img='') addon.add_directory({'mode': 'parsexml', 'url': rss_watching}, {'title': 'Being Watched'}, img='') elif mode == 'channels': html = net.http_GET(url).content r = re.search('<div class="categories">(.+?)</div>',html,re.DOTALL).group(1) match = re.compile('<li.+?><a href="(.+?)">(.+?)</a></li>').findall(r) for link, name in match: addon.add_directory({'mode': 'channellist', 'url': link}, {'title': name}, img='')
username = addon.get_setting( 'username' ) password = addon.get_setting( 'password' ) if username == "" or password == "": addon.show_ok_dialog( [ 'Login required to access movies. Please create account in www.flyinhd.com' ], title='Login Required' ) return params = { 'login' : username, 'password' : password } try: response = net.http_POST( BASE_URL + '/login', params ) if 'login' in response.get_url(): raise urllib2.URLError( 'login failed') except urllib2.URLError, e: addon.show_ok_dialog( [ 'Wrong username or password' ], title='Login Failed' ) return addon.add_directory( { 'mode' : 'movie_recent', 'url' : BASE_URL, 'lang' : lang }, { 'title' : '[B]Most Recent[/B]' } ) #movieIndex = cache.cacheFunction( parseMoviePage, lang ) movieIndex = parseMoviePage( lang ) for key, value in sorted( movieIndex.items() ): if type( value ) != dict: mode = 'leaf' path = value + '&offset=1' else: mode = 'tree' path = key addon.add_directory( { 'mode' : mode, 'url' : path, 'lang' : lang }, { 'title' : '[B]%s[/B]' % key } ) xbmcplugin.endOfDirectory(int(sys.argv[1]))
media = urlresolver.HostedMediaFile(host=host, media_id=linkid, title=vidname + ' - ' + host + ' - ' + load + ' - ' + working) sources.append(media) source = urlresolver.choose_source(sources) if source: stream_url = source.resolve() else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({'mode': 'movies', 'section': 'movies'}, {'title': 'Movies'}, img=IconPath + 'Movies.png') addon.add_directory({'mode': 'tv', 'section': 'tv'}, {'title': 'TV Shows'}) addon.add_directory({'mode': 'search', 'section': SearchAll}, {'title': 'Search All'}) addon.add_directory({'mode': 'resolver_settings'}, {'title': 'Resolver Settings'}, is_folder=False, img=IconPath + 'Resolver_Settings.png') setView(None, 'default-view') elif mode == 'movies': addon.add_directory({'mode': 'moviesaz', 'section': 'moviesaz'}, {'title': 'A-Z'}, img=IconPath + "AZ.png") addon.add_directory({'mode': 'moviespopular', 'section': 'moviespopular'}, {'title': 'Popular'}) addon.add_directory({'mode': 'favourites', 'video_type': VideoType_Movies}, {'title': 'Favourites'}) addon.add_directory({'mode': 'search', 'section': SearchMovies}, {'title': 'Search'}) addon.add_directory({'mode': 'movieslatest', 'section': 'movieslatest'}, {'title': 'Latest Added Links'}) addon.add_directory({'mode': 'moviesgenre', 'section': 'moviesgenre'}, {'title': 'Genre'}, img=IconPath + 'Genre.png') addon.add_directory({'mode': 'moviesyear', 'section': 'moviesyear'}, {'title': 'Year'}) setView(None, 'default-view')
html = net.http_GET(url).content media_id = re.search('<input type="hidden" value="(.+?)" id="vid" />', html, re.DOTALL).group(1) host = re.search('<input type="hidden" value="(.+?)" id="vhost" />', html, re.DOTALL).group(1) stream_url = urlresolver.HostedMediaFile(host=host, media_id=media_id).resolve() else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({'mode': 'movies', 'section': 'movies'}, {'title': 'Movies'}, img=icon_path + 'Movies.jpg') addon.add_directory({'mode': 'tv', 'section': 'tv'}, {'title': 'TV Shows'}, img='') addon.add_directory({'mode': 'cartoons', 'section': 'cartoons', 'url': main_url + 'videos?g=4&mt=1'}, {'title':'Cartoons'}, img='') addon.add_directory({'mode': 'documentary', 'section': 'documentary', 'url': main_url + 'videos?g=5&mt=1'}, {'title': 'Documentaries'}, img='') addon.add_directory({'mode': 'musicvid', 'section': 'musicvid', 'url': main_url + 'videos?g=17&mt=1'}, {'title': 'Music Videos'}, img='') addon.add_directory({'mode': 'resolver_settings'}, {'title': 'Resolver Settings'}, is_folder=False, img='') elif mode == 'movies': addon.add_directory({'mode': 'moviestop', 'url': main_url, 'section': 'movie'}, {'title': 'Top Movies'}, img='') addon.add_directory({'mode': 'moviesaz', 'section': 'movie'}, {'title': 'A-Z'}, img='') addon.add_directory({'mode': 'moviesgenre', 'url': main_url + 'videos?mt=1', 'section': 'movie'}, {'title': 'Genre'}, img='') addon.add_directory({'mode': 'moviesrecent', 'url': main_url + 'videos?a=dr&mt=1', 'section': 'movie'}, {'title': 'Recently Released'}, img='') addon.add_directory({'mode': 'moviesadded', 'url': main_url + 'videos?a=da&mt=1', 'section': 'movie'}, {'title': 'Recently Added'}, img='') addon.add_directory({'mode': 'moviespopular', 'url': main_url + 'videos?a=m&mt=1', 'section': 'movie'}, {'title': 'Most Popular'}, img='') addon.add_directory({'mode': 'moviesyear', 'url': main_url + 'videos?mt=1', 'section': 'movie'}, {'title': 'Year'}, img='')
elif mode == 'mainexit': sys_exit() mainmenu() elif mode == 'tvchannels': tvchannels() elif mode == 'classics': print 'Retrieving: %s' % url html = net.http_GET(url).content page = int(page_num) if page > 1: addon.add_directory({'mode': 'mainexit'}, {'title': '[COLOR red]Back to Main Menu[/COLOR]'}, img=icon_path + 'back_arrow.png') if page < 4: page = page + 1 addon.add_directory( { 'mode': 'classics', 'url': classic_shows_url % page, 'page_num': page }, {'title': '[COLOR blue]Next Page[/COLOR]'}, img=icon_path + 'next_arrow.png') match = re.compile( '<a Title="" href="(.+?)" target="img_m"><img border="0" src="(.+?)" style="filter:alpha\(opacity=50\); -moz-opacity:0.5" onMouseover="lightup\(this, 100\)" onMouseout="lightup\(this, 30\)" width="110" height="80"></a>(.+?)</td>' ).findall(html)
total = int(r.group(1).replace(',', '')) else: total = 0 r = 'class="index_item.+?href="(.+?)".+?src="(.+?)".+?' + \ 'alt="Watch (.+?)"' regex = re.finditer(r, html, re.DOTALL) urls = [] for s in regex: url, thumb, title = s.groups() if url not in urls: urls.append(url) if section == 'tv': addon.add_directory({'mode': 'series', 'url': base_url + url}, {'title': title}, img=thumb, total_items=total) else: addon.add_video_item({'url': base_url + url}, {'title': title}, img=thumb, total_items=total) elif genre: if genre != 'All': addon.add_directory({'mode': 'browse', 'section': section, 'genre': genre, 'letter': 'All'}, {'title': 'All'}) addon.add_directory({'mode': 'browse', 'section': section,
nextpage = re.search('<a href="(.+?)"> Next Search Page</a>', html) if not nextpage: loop = True page += 1 for item in matches: parts = re.match('(.+?)#####(.+?)$', item) if parts: addon.add_directory({'mode': 'tvseasons', 'url': parts.group(1), 'section': 'tv', 'show': parts.group(2)}, {'title': parts.group(2)}, img='', total_items=numMatches) addon.end_of_directory() if mode == 'main': print 'main' addon.add_directory({'mode': 'tvaz', 'section': 'tv'}, {'title':'A-Z'}, img='') addon.add_directory({'mode': 'latest', 'url': main_url + '/latest', 'section': 'tv'}, {'title': 'Newest Episodes Added'}) addon.add_directory({'mode': 'popular', 'url': main_url + '/new', 'section': 'tv'}, {'title': 'This Weeks Popular Episodes'}) addon.add_directory({'mode': 'schedule', 'url': main_url + '/tvschedule', 'section': 'tv'}, {'title': 'TV Schedule'}) addon.add_directory({'mode': 'genres', 'url': main_url +'/genres/', 'section': 'tv'}, {'title': 'TV Shows Genres'}) addon.add_directory({'mode': 'search', 'section': 'tv'}, {'title':'Search'}) addon.end_of_directory() elif mode == 'tvaz': AZ_Menu('tvseriesaz','/letters/%s') elif mode == 'tvseriesaz': get_video_list(url) elif mode == 'latest': get_latest(url) elif mode == 'popular': get_latest(url)
'tv') page = 1 url = addon.queries['url'] while page <= numpages: if addon.queries['multipage'] == 'yes': if page == 1: url = addon.queries['url'] else: url = ('%s?page=%s') % (addon.queries['url'], page) else: page = 9998 html = net.http_GET(url).content match = MatchTvEntries(html) for thumbnail, title, url in match: url = base_url + url addon.add_directory( { 'mode' : 'findtvseasons', 'type' : 'tv', 'url' : url}, title, thumbnail, cm=cm) page = page + 1 elif mode == 'findtvseasons': cm.add_context('Jump to favorites', { 'mode' : 'showfavorites' }, True) cm.add_context('Go to addon main screen', { 'mode' : 'main' }, True) cm.add_favorite('Save solarmovie favorite', { 'mode' : 'findepisodes' },'savefavorite', 'tv') html = net.http_GET(addon.queries['url']).content match=re.compile('<h4><a href="(.+?)">\n\s+Season\s(.+?)</a>').findall(html) if match: dict = {} for url, season in match: season = season.rjust(2,'0')
else: total = 0 r = 'class="index_item.+?href="(.+?)".+?src="(.+?)".+?' + \ 'alt="Watch (.+?)"' regex = re.finditer(r, html, re.DOTALL) urls = [] for s in regex: url, thumb, title = s.groups() if url not in urls: urls.append(url) if section == 'tv': addon.add_directory( { 'mode': 'series', 'url': base_url + url }, {'title': title}, img=thumb, total_items=total) else: addon.add_video_item({'url': base_url + url}, {'title': title}, img=thumb, total_items=total) elif genre: if genre != 'All': addon.add_directory( { 'mode': 'browse', 'section': section,
'year': year }, meta, img=meta['cover_url'], fanart=meta['backdrop_url'], contextmenu_items=cm, context_replace=True) except UnicodeDecodeError, err: meta['title'] = meta['title'].decode('utf-8') addon.add_directory( { 'mode': 'GetLinks', 'section': section, 'url': url, 'title': title, 'year': year }, meta, img=meta['cover_url'], fanart=meta['backdrop_url'], contextmenu_items=cm, context_replace=True) def PlayTrailer(url): url = url.decode('base-64') print 'Attempting to resolve and play trailer at %s' % url sources = [] hosted_media = urlresolver.HostedMediaFile(url=url) sources.append(hosted_media) source = urlresolver.choose_source(sources)
url = '%s/?letter=%s&sort=alphabet&page=%s&%s' % (base_url, letter, page, section) try: addon.log_debug('fetching %s' % url) html = net.http_GET(url).content except urllib2.URLError, e: html = '' addon.log_error('got http error %d fetching %s' % (e.code, web_url)) r = 'class="index_item.+?href="(.+?)".+?src="(.+?)".+?alt="Watch (.+?)"' regex = re.finditer(r, html, re.DOTALL) for s in regex: url, thumb, title = s.groups() addon.add_directory({'mode': 'series', 'url': base_url + url}, title, img=thumb) if html.find('> >> <'): addon.add_directory({'mode': 'browse', 'section': section, 'page': int(page) + 1, 'letter': letter}, 'Next Page') else: addon.add_directory({'mode': 'browse', 'section': section, 'letter': '123'}, '#') for l in string.uppercase: addon.add_directory({'mode': 'browse', 'section': section,
print "tap_num::" + str(tap_num) #get tid pindex = url.find("id=") stemp = url[pindex + 3:] tid = stemp[:stemp.find("&")] print "tid::" + tid for i in range((tap_page-1)*20+1, min((tap_page-1)*20+21,tap_num+1)): tap_url = "http://giaitri.com/new/loadplayer.php?tid=" + tid + "&sid=" + str(i) #addon.add_directory({'mode': 'giaitricom_tap_play', 'tap_url' : tap_url}, {'title': 'Tap ' + str(i)}) addon.add_video_item({'url': tap_url, 'site' : 'giaitricom'},{'title': 'Tap ' + str(i)}) if tap_num > (tap_page*20): addon.add_directory({'mode': 'giaitricom_tap_list','phim_url' : url, 'page' : str(tap_page+1)}, {'title': 'Next page ... ' + str(((tap_page)*20 +1)) + ' to ' + str(min(tap_num,(tap_page+1)*20))}) elif mode == 'giaitricom_cat': url = addon.queries.get('cat_url', '') #page cat_page = addon.queries.get('cat_page', '1') print "cat_page::" + cat_page url1 = url + "&page=" + cat_page html = utf8decode(net.http_GET(url1).content) ret = common.parseDOM(html, "div", attrs = { "class": "s1" }) if not ret: ret = common.parseDOM(html, "div", attrs = { "class": "s1_alt" })
#Search by IMDB ID meta = metaget.get_meta('movie','The Hangover',imdb_id='tt1119646') add_video(meta, 'movie') #Search by Name + Year meta = metaget.get_meta('movie','40 Year Old Virgin', year='2005') add_video(meta, 'movie') #Search by TMDB ID meta = metaget.get_meta('movie','Horrible Bosses', tmdb_id='51540') add_video(meta, 'movie') #Search for TV Show meta = metaget.get_meta('tvshow','The Simpsons') addon.add_directory({'url': 'none', 'mode': 'tvseasons', 'imdb_id': meta['imdb_id']}, meta, img=meta['cover_url'], fanart=meta['backdrop_url']) #episode=metaget.get_episode_meta('tt0096697', '1', '1') #print episode elif mode == 'watch_mark': metaget=metahandlers.MetaData() metaget.change_watched(video_type, name, imdb_id, tmdb_id) xbmc.executebuiltin("Container.Refresh") elif mode == 'refresh_meta': year = addon.queries.get('year', None) metaget=metahandlers.MetaData()
name = 'Full' media = urlresolver.HostedMediaFile(host=host, media_id=linkid, title=name + ' - ' + host + ' - ' + load + ' - ' + working) sources.append(media) source = urlresolver.choose_source(sources) if source: stream_url = source.resolve() else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({'mode': 'movies', 'section': 'movies'}, {'title': 'Movies'}, img=IconPath + 'Movies.png') addon.add_directory({'mode': 'tv', 'section': 'tv'}, {'title': 'TV Shows'}) addon.add_directory({'mode': 'resolver_settings'}, {'title': 'Resolver Settings'}, is_folder=False, img=IconPath + 'Resolver_Settings.png') elif mode == 'movies': addon.add_directory({'mode': 'moviesaz', 'section': 'moviesaz'}, {'title': 'A-Z'}, img=IconPath + "AZ.png") addon.add_directory({'mode': 'moviesgenre', 'section': 'moviesgenre'}, {'title': 'Genre'}, img=IconPath + 'Genre.png') addon.add_directory({'mode': 'movieslatest', 'section': 'movieslatest'}, {'title': 'Latest'}) addon.add_directory({'mode': 'moviespopular', 'section': 'moviespopular'}, {'title': 'Popular'}) addon.add_directory({'mode': 'moviesyear', 'section': 'moviesyear'}, {'title': 'Year'}) elif mode == 'moviesaz': AZ_Menu('movieslist',MovieUrl + 'browse/') elif mode == 'moviesgenre': url = MovieUrl
host = re.search('<input type="hidden" value="(.+?)" id="vhost" />', html, re.DOTALL).group(1) stream_url = urlresolver.HostedMediaFile(host=host, media_id=media_id).resolve() else: stream_url = False #Play the stream if stream_url: addon.resolve_url(stream_url) if mode == 'main': addon.add_directory({ 'mode': 'movies', 'section': 'movies' }, {'title': 'Movies'}, img=icon_path + 'Movies.jpg') addon.add_directory({ 'mode': 'tv', 'section': 'tv' }, {'title': 'TV Shows'}, img='') addon.add_directory( { 'mode': 'cartoons', 'section': 'cartoons', 'url': main_url + 'videos?g=4&mt=1' }, {'title': 'Cartoons'}, img='') addon.add_directory(
sys_exit() mainmenu() elif mode == "tvchannels": tvchannels() elif mode == "classics": print "Retrieving: %s" % url html = net.http_GET(url).content page = int(page_num) if page > 1: addon.add_directory( {"mode": "mainexit"}, {"title": "[COLOR red]Back to Main Menu[/COLOR]"}, img=icon_path + "back_arrow.png" ) if page < 4: page = page + 1 addon.add_directory( {"mode": "classics", "url": classic_shows_url % page, "page_num": page}, {"title": "[COLOR blue]Next Page[/COLOR]"}, img=icon_path + "next_arrow.png", ) match = re.compile( '<a Title="" href="(.+?)" target="img_m"><img border="0" src="(.+?)" style="filter:alpha\(opacity=50\); -moz-opacity:0.5" onMouseover="lightup\(this, 100\)" onMouseout="lightup\(this, 30\)" width="110" height="80"></a>(.+?)</td>' ).findall(html) for link, thumb, name in match: if not re.search("http://", thumb):
{'title': '2gb-hosting'}) elif mode == 'tv': browse = addon.queries.get('browse', False) if browse == 'alpha': letter = addon.queries.get('letter', False) if letter: url = 'http://tubeplus.me/browse/tv-shows/All_Genres/%s/' % letter html = net.http_GET(url).content r = '<div class="list_item.+?src="(.+?)".+?<a class="plot".+?' + \ 'href="(.+?)".+?<b>(.+?)<\/b>.+?<\/b>(.+?)<' regex = re.finditer(r, html, re.DOTALL) for s in regex: thumb, url, title, plot = s.groups() addon.add_directory({'mode': 'series', 'url': base_url + url}, title, img=base_url+thumb) else: addon.add_directory({'mode': 'tv', 'browse': 'alpha', 'letter': '-'}, '#') for l in string.uppercase: addon.add_directory({'mode': 'tv', 'browse': 'alpha', 'letter': l}, l) else: addon.add_directory({'mode': 'tv', 'browse': 'alpha'}, 'A-Z') elif mode == 'series':
class CraftsyPlugin(): addon = None net = None logo = None profile_path = None cookie_file = None base_url = None free_url = 'http://www.craftsy.com.edgesuite.net/' pay_url = 'http://cd1.craftsy.com/' def __init__(self): self.addon = Addon('plugin.video.craftsy', sys.argv) self.net = Net() self.logo = os.path.join(self.addon.get_path(), 'art','logo.jpg') self.profile_path = self.addon.get_profile() self.cookie_file = os.path.join(self.profile_path, 'craftsy.cookies') try: os.makedirs(os.path.dirname(self.cookie_file)) except OSError: pass self.net.set_cookies(self.cookie_file) self.base_url = 'http://www.craftsy.com' def __get_image(self, url): fname = os.path.join(self.profile_path, md5.new(url).digest()) print fname if os.path.isfile(fname): return fname return url def __check_link(self, url): if (re.match('^/', url)): return 'http:' + url return url def __fetch_regexp_idx(self, r, idx, default = None): if (r == None): return default if (len(r.groups()) < idx + 1): return default return r.groups()[idx] def check_login(self): source = self.net.http_GET(self.base_url + '/my/home?NAVIGATION_PAGE_CONTEXT_ATTR=NONE').content r = re.search('<title>([^<]+)</title>', source) title = r.groups()[0] if title == 'Welcome Back to Craftsy!': return False return True def __get_url(self, url): return self.net.http_GET(url).content.encode('utf8').replace("\n", "").replace("\r", "") def add_classes(self): source = self.__get_url(self.base_url + '/my/home?NAVIGATION_PAGE_CONTEXT_ATTR=NONE') source = re.sub('<div class="classCard mostRecent".*?</div>.*?</div>.*?</div>.*?</div>', '', source) source = re.sub('<div class="continueArea".*?</div>.*?</div>', '', source) # parts = re.split('<div class="classBot myClassBot">', source) r = re.findall('<a href="(/lecture[^\"]+)"(.*?)</a>[ \s\t]*<div class="classBot myClassBot">.*?<a href="([^"]+)"', source) for i in r: url = i[2] if (re.match('^/', url)): url = self.base_url + url t = re.search('<h4>([^<]+)</h4>', i[1]) title = 'N/A' title = self.__fetch_regexp_idx(t, 0, 'N/A') img = self.base_url + '/images/craftsy/noImageTitleCard.png' t = re.search('<img src="([^"]+)" alt="[^"]+" onerror', i[1]) _u = self.__fetch_regexp_idx(t, 0) if (_u != None): img = self.__check_link(_u) # print self.__get_image(img) self.addon.add_directory({'mode': 'classes', 'url': url}, {'title': title}, fanart=img, img=img) def __try_resolve(self, pattern, video): r = re.search(pattern, video) return self.__fetch_regexp_idx(r, 0) def resolve_url(self, lesson_url): pattern = '&([0-9]+)&(pay|free)$' l = re.search(pattern, lesson_url) lesson_id = self.__fetch_regexp_idx(l, 0) lesson_type = self.__fetch_regexp_idx(l, 1, 'pay') lesson_url = re.sub(pattern, '', lesson_url) q = self.addon.get_setting('quality') t = self.addon.get_setting('type') source = self.__get_url(lesson_url) uid = re.search('/([0-9]+)\\.html(\\?t=[0-9]*){0,1}$', lesson_url) url_id = self.__fetch_regexp_idx(uid, 0) if (url_id == None): return None r = re.search('arbitraryId = ([0-9]+),', source) arbitraryId = self.__fetch_regexp_idx(r, 0) if (arbitraryId != None): url_id = arbitraryId suffix = lesson_id + '/' + url_id + '/' + url_id + '-' + q + '.' + t if lesson_type == 'free': print "THE URL TO PLAY IS " + self.free_url + suffix return self.free_url + suffix else: return self.pay_url + suffix # r = re.search('(<video.*?</video>)', source) # if (len(r.groups()) == 0): # return None # else: # video = r.groups()[0] # video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.' + t + ')"', video) # if (video_url == None): # video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.[^\\.]+)"', video) # if (video_url == None): # video_url = self.__try_resolve('<source src="([^"]+)"', video) # return video_url def add_lessons(self, class_url): source = self.__get_url(class_url) # self.net.http_GET(class_url).content l = re.search('\,([0-9]+)$', class_url) lesson_id = self.__fetch_regexp_idx(l, 0) if (lesson_id == None): self.addon.show_error_dialog(['Could not fetch the lesson ID']); return None r = re.findall('(<tr class="classLesson.*?</tr>)', source) first = True lesson_type = 'pay' for i in r: text = i el = re.search('<td class="lessonName">.*?<a href="([^"]+)">(.*?)</a>', text) href = self.__fetch_regexp_idx(el, 0) if href != None: href = self.__check_link(href) title = self.__fetch_regexp_idx(el, 1, 'N/A') if (first): if (title.lower() == 'welcome to your free mini-class!'): lesson_type = 'free' im = re.search('<td class="lessonImage">.*?<img src="([^"]+)"', text) img = self.__check_link(self.__fetch_regexp_idx(im, 0, os.path.join(self.addon.get_path(), 'art','no-img.jpg'))) self.addon.add_video_item({'url': href + '&' + lesson_id + '&' + lesson_type}, {'title': title}, img = img, fanart = img) first = False def do_login(self): try: if self.check_login(): return True data=(('email', self.addon.get_setting('username')), ('password', self.addon.get_setting('password')), ('forwardUrl', '/')) source = self.net.http_POST(self.base_url + '/doLogin.json?isCraftsyAjax=true', data).content response = JSONDecoder().decode(source) self.net.save_cookies(self.cookie_file) self.net.set_cookies(self.cookie_file) return response.get("success") except Exception as e: print e return False
cm.append(('Show Information', 'XBMC.Action(Info)')) else: meta['title'] = name meta['backdrop_url'] = '' meta['cover_url'] = img try: addon.add_directory({'mode': 'GetLinks', 'section': section, 'url': url, 'title': name, 'year': year}, meta, img= meta['cover_url'], fanart= meta['backdrop_url'], contextmenu_items= cm, context_replace=True) except UnicodeEncodeError, err: meta['title'] = meta['title'].encode('utf-8') addon.add_directory({'mode': 'GetLinks', 'section': section, 'url': url, 'title': title, 'year': year}, meta, img= meta['cover_url'], fanart= meta['backdrop_url'], contextmenu_items= cm, context_replace=True) except UnicodeDecodeError, err: meta['title'] = meta['title'].decode('utf-8') addon.add_directory({'mode': 'GetLinks', 'section': section, 'url': url, 'title': title, 'year': year}, meta, img= meta['cover_url'], fanart= meta['backdrop_url'], contextmenu_items= cm, context_replace=True) def PlayTrailer(url): url = url.decode('base-64') print 'Attempting to resolve and play trailer at %s' % url sources = [] hosted_media = urlresolver.HostedMediaFile(url=url) sources.append(hosted_media) source = urlresolver.choose_source(sources) if source: stream_url = source.resolve() else: stream_url = '' xbmc.Player().play(stream_url) def GetImdbId(imdbUrl): print 'imdbUrl is %s' % imdbUrl