def _getVideoUrl6( self, video_page_url ): movie_id = self.USER_MOVIES_URL_RE.search( video_page_url ).group(1) # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( "http://mosii.gametrailers.com/getmediainfo4.php?umid=%s" % movie_id ) # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "video_page.html" ), "w") f.write( htmlData ) f.close() # Parse HTML response... params = dict(part.split('=') for part in htmlData.split('&')) umfilename = urllib.unquote( params[ "umfilename" ] ) # Video URL... video_url = "http://umtrailers.gametrailers.com/gt_usermovies/um_%s.flv" % umfilename # # Return value # video_urls = [] video_urls.append( video_url ) return video_urls
def getVideos( self ) : # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( "http://www.gametrailers.com/top20.php?toplist=media&topsublist=yesterday&plattyfilt=all&page=%u" % ( (self.current_page - 1 ) * 20 ) ) # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "page_%i.html" % self.current_page), "w") f.write( htmlData ) f.close() # Parse response... soupStrainer = SoupStrainer ( "div", { "id" : "top_media" } ) beautifulSoup = BeautifulSoup( htmlData, soupStrainer ) # # Parse movie entries... # div_top_media = beautifulSoup.find ("div", { "id" : "top_media_yesterday" } ) videos = self.parseMediaDiv( div_top_media ) if len( videos ) == 0 : div_top_media = beautifulSoup.find ("div", { "id" : "top_media_week" } ) videos = self.parseMediaDiv( div_top_media ) for video in videos : # Add to list... listitem = xbmcgui.ListItem( video[ "title" ], iconImage="DefaultVideo.png", thumbnailImage=video[ "thumbnail" ] ) listitem.setInfo( "video", { "Title" : video[ "title" ], "Studio" : "GameTrailers", "Plot" : video[ "plot" ], "Genre" : video[ "date" ], "Overlay" : video[ "overlay" ] } ) plugin_play_url = '%s?action=play&video_page_url=%s' % ( sys.argv[ 0 ], urllib.quote_plus( video[ "video_page" ] ) ) xbmcplugin.addDirectoryItem( handle=int(sys.argv[ 1 ]), url=plugin_play_url, listitem=listitem, isFolder=False) # # Get the number of entries... # div_reviewlist_barshort2 = div_top_media.find( "div", { "class" : "reviewlist_barshort2" } ) div_reviewlist_bartext = div_reviewlist_barshort2.find( "div", { "class" : "reviewlist_bartext" } ) reviewlist = div_reviewlist_bartext.string.strip() reviewlist_result = self.ENTRY_LIST_RE.search( reviewlist ) entry_no_start = reviewlist_result.group(1) entry_no_end = reviewlist_result.group(2) # Next page entry... listitem = xbmcgui.ListItem (__language__(30503), iconImage = "DefaultFolder.png", thumbnailImage = os.path.join(self.IMAGES_PATH, 'next-page.png')) xbmcplugin.addDirectoryItem( handle = int(sys.argv[1]), url = "%s?action=list-top20&plugin_category=%s&page=%i" % ( sys.argv[0], self.plugin_category, self.current_page + 1 ), listitem = listitem, isFolder = True) # Disable sorting... xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) # Label (top-right)... xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=( "%s (" + __language__(30501) + ")" ) % ( self.plugin_category, entry_no_start, entry_no_end ) ) # End of directory... xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def _getVideoUrl2(self, video_page_url ): # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( video_page_url ) # Parse HTML page... beautifulSoup = BeautifulSoup( htmlData ) embed = beautifulSoup.find( "embed" ) if embed == None : return [] filename = embed[ "flashvars" ][ 9: ] url = re.compile( "(.+?)&" ).search( filename ).group( 1 ) # # Get XML data.... # if not url.startswith( "http" ) : wins_xml_url = "http://www.gametrailers.com%s" % url else : wins_xml_url = url usock = urllib.urlopen( wins_xml_url ) xmldoc = xml.dom.minidom.parse( usock ) usock.close() # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "wins_xml_reply.xml" ), "w") f.write( xmldoc.toxml() ) f.close() # Get the movie url... fileinfoNode = xmldoc.documentElement.getElementsByTagName( "fileinfo" )[0] sdNode = fileinfoNode.getElementsByTagName( "sd" )[0] sdFlvNode = sdNode.getElementsByTagName( "flv" )[0] video_url = sdFlvNode.childNodes[0].nodeValue if self.video_quality == "1" : hdNode = fileinfoNode.getElementsByTagName( "hd" )[0] hdFlvNode = hdNode.getElementsByTagName ( "flv" )[0] if hdFlvNode.childNodes[0].nodeValue : video_url = hdFlvNode.childNodes[0].nodeValue # # Return value # video_urls = [] video_urls.append( video_url ) return video_urls
def getVideos( self ) : # # Get HTML page... # url = "http://www.gametrailers.com/feeds/line_listing_results/video_hub/6bc9c4b7-0147-4861-9dac-7bfe8db9a141/?sortBy=most_recent&category=Review¤tPage=%d" % ( self.current_page ) httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( url ) # Parse response... beautifulSoup = BeautifulSoup( htmlData ) # # Parse movie entries... # lis = beautifulSoup.findAll ( "div", { "class" : "video_information" } ) for li in lis : div_holder = li.find ( "div", { "class" : "holder" } ) # Title h3 = div_holder.find ( "h3" ) h4 = div_holder.find ( "h4" ) title = "%s - %s" % ( h3.a.string.strip(), h4.a.string.strip() ) # Thumbnail a_thumbnail = div_holder.find ( "a", { "class" : "thumbnail" } ) a_thumbnail_imgs = a_thumbnail.findAll ( "img" ) thumbnail_url = a_thumbnail_imgs[ -1 ] [ "src" ] # Video page... video_page_url = a_thumbnail[ "href" ] # Add to list... listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail_url ) listitem.setInfo( "video", { "Title" : title, "Studio" : "GameTrailers" } ) plugin_play_url = '%s?action=play&video_page_url=%s' % ( sys.argv[ 0 ], urllib.quote_plus( video_page_url ) ) xbmcplugin.addDirectoryItem( handle=int(sys.argv[ 1 ]), url=plugin_play_url, listitem=listitem, isFolder=False) # Next page entry... listitem = xbmcgui.ListItem ( __language__(30503), iconImage = "DefaultFolder.png", thumbnailImage = os.path.join(__images_path__, 'next-page.png')) xbmcplugin.addDirectoryItem( handle = int(sys.argv[1]), url = "%s?action=list-reviews&plugin_category=%s&page=%i" % ( sys.argv[0], self.plugin_category, self.current_page + 1 ), listitem = listitem, isFolder = True) # Disable sorting... xbmcplugin.addSortMethod( handle = int( sys.argv[ 1 ] ), sortMethod = xbmcplugin.SORT_METHOD_NONE ) # End of directory... xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded = True )
def _getVideoUrl5( self, video_page_url ): # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( video_page_url ) # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "play_url_5.html" ), "w") f.write( htmlData ) f.close() # # Parse HTML page (get number of parts)... # soupStrainer = SoupStrainer ( "div", { "id" : "media_div" } ) beautifulSoup = BeautifulSoup( htmlData, parseOnlyThese=soupStrainer ) episode_no = re.compile( "myFlash.addVariable\('episode', '(.*)'\)" ).search( beautifulSoup.script.string ).group( 1 ) part_count = int( re.compile( "myFlash.addVariable\('eppartcount', '(.*)'\)" ).search( beautifulSoup.script.string ).group( 1 ) ) # # Return value # video_urls = [] for part_no in range(1, part_count + 1) : hd_part = "" if self.video_quality == "1" : if ( 4 <= int(episode_no) and int(episode_no) <= 21 ) : hd_part = "_h264" video_url = "http://trailers.gametrailers.com/gt_vault/br_ep%s_pt%s%s.flv" % ( episode_no, part_no, hd_part ) video_urls.append( video_url ) return video_urls
def getVideos( self ) : # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( "http://%s.gametrailers.com/?show=&page=%u" % ( self.platform, self.current_page ) ) # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "page_platform_%i.html" % self.current_page), "w") f.write( htmlData ) f.close() # Parse response... soupStrainer = SoupStrainer ( "div", { "id" : "AllMedia" } ) beautifulSoup = BeautifulSoup( htmlData, soupStrainer ) # # Parse movie entries... # table_entries = beautifulSoup.findAll ( "table", { "width" : "100%" } ) for table_entry in table_entries : table_entry_tr = table_entry.find ("tr" ) table_entry_tr_tds = table_entry_tr.findAll ( "td" ) table_entry_tr_td_1 = table_entry_tr_tds[0] table_entry_tr_td_2 = table_entry_tr_tds[1] div_gamepage_content_row_thumb = table_entry_tr_td_1.find( "div", { "class" : "gamepage_content_row_thumb" } ) # Video page URL.... div_newlist_movie_sd_hd = div_gamepage_content_row_thumb.find( "div", { "class" : "newestlist_movie_format_SDHD" } ) if (div_newlist_movie_sd_hd) : a_list = div_newlist_movie_sd_hd.findAll( "a" ) hd_movie_page_url = a_list[0][ "href" ] sd_movie_page_url = a_list[1][ "href" ] if (self.video_quality == "1" and hd_movie_page_url) : # HD video_page_url = hd_movie_page_url overlay = xbmcgui.ICON_OVERLAY_HD else : video_page_url = sd_movie_page_url # SD overlay = xbmcgui.ICON_OVERLAY_NONE else: div_newestlist_movie_sd = div_gamepage_content_row_thumb.find( "div", { "class" : "newestlist_movie_format_SD" } ) video_page_url = div_newestlist_movie_sd.a[ "href" ] overlay = xbmcgui.ICON_OVERLAY_NONE # Thumbnail URL... thumbnail_url = div_gamepage_content_row_thumb.img[ "src" ] thumbnail_url = thumbnail_url.replace( " ", "%20" ) # Game title... h3_movie_title = table_entry_tr_td_2.find( "h3", { "class" : "MovieTitle" } ) game_title = h3_movie_title.a.string.strip() # Movie title... table_entry_tr_td_2_div_2 = table_entry_tr_td_2.findAll ( "div" )[1] movie_title = table_entry_tr_td_2_div_2.a.string.strip() title = game_title + " - " + movie_title # Plot... plot = table_entry_tr_td_2_div_2.contents[2].strip() plot = plot.strip("- ") # Date... div_movie_file_size = table_entry_tr_td_2.find( "div", { "class" : "MovieFileSize" } ) if len( div_movie_file_size.contents) > 1 : date = div_movie_file_size.contents[2].strip() else : date = div_movie_file_size.string.strip() date = date.replace( "ago ago", "ago" ) date = date.replace( "Posted", "") # Add to list... listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail_url ) listitem.setInfo( "video", { "Title" : title, "Studio" : "GameTrailers", "Plot" : plot, "Genre" : date, "Overlay" : overlay } ) plugin_play_url = '%s?action=play&video_page_url=%s' % ( sys.argv[ 0 ], urllib.quote_plus( video_page_url ) ) xbmcplugin.addDirectoryItem( handle=int(sys.argv[ 1 ]), url=plugin_play_url, listitem=listitem, isFolder=False) # Next page entry... listitem = xbmcgui.ListItem (__language__(30503), iconImage = "DefaultFolder.png", thumbnailImage = os.path.join(self.IMAGES_PATH, 'next-page.png')) xbmcplugin.addDirectoryItem( handle = int(sys.argv[1]), url = "%s?action=list-platform&platform=%s&plugin_category=%s&page=%i" % ( sys.argv[0], self.platform, self.plugin_category, self.current_page + 1 ), listitem = listitem, isFolder = True) # Disable sorting... xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) # Label (top-right)... xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=( "%s (" + __language__(30502) + ")" ) % ( self.plugin_category, self.current_page ) ) # End of directory... xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def _getVideoUrl7( self, video_page_url ): video_urls = [] # # Video format (SD or HD)... # rendition_size = "sd" if (self.video_quality == "1" ) : rendition_size = "hd" # # Get HTML page... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( video_page_url ) # # Parse HTML source... # beautifulSoup = BeautifulSoup( htmlData ) media_player_info = beautifulSoup.find( "div", { "class" : "module video_information-player" } ) if (media_player_info != None) : data_content_id = media_player_info[ "data-contentid" ] # # Parse RSS feed (one or more video parts)... # url_rss = "http://www.gametrailers.com/feeds/mrss/?uri=%s" % data_content_id data_rss = HTTPCommunicator().get( url_rss ) doc_rss = xml.dom.minidom.parseString( data_rss ) item_nodes = doc_rss.documentElement.getElementsByTagName( "item" ) for item_node in item_nodes : # Get video parts... media_group_node = item_node.getElementsByTagName( "media:group" )[0] media_category_nodes = media_group_node.getElementsByTagName( "media:category" ) for media_category_node in media_category_nodes : if (media_category_node.attributes[ "scheme" ].nodeValue == "urn:mtvn:id" ) : media_id = media_category_node.firstChild.nodeValue # Get video URL for part... url_xml = "http://www.gametrailers.com/feeds/mediagen/?uri=%s&forceProgressive=true&renditionSize=%s" % ( media_id, rendition_size) data_xml = HTTPCommunicator().get( url_xml ) doc_xml = xml.dom.minidom.parseString( data_xml ) # Parse XML... rendition_node = doc_xml.documentElement.getElementsByTagName( "rendition" )[0] src_node = rendition_node.getElementsByTagName( "src" )[0] video_url = src_node.firstChild.nodeValue video_urls.append( video_url ) # Cleanup... doc_xml = None break # # Return value # return video_urls # # The End #
def _getVideoUrl3( self, video_page_url ): movie_id = self.VIDEO_URL_RE.search( video_page_url ).group(2) # # Get video URL (method #1)... # httpCommunicator = HTTPCommunicator() htmlData = httpCommunicator.get( "http://mosii.gametrailers.com/getmediainfo4.php?hd=1&mid=%s" % movie_id ) # Debug if (self.DEBUG) : f = open(os.path.join( xbmc.translatePath( "special://profile" ), "plugin_data", "video", sys.modules[ "__main__" ].__plugin__, "video_page.html" ), "w") f.write( htmlData ) f.close() # Parse HTML response... params = dict(part.split('=', 1) for part in htmlData.split('&')) umfilename = urllib.unquote( params[ "umfilename" ] ) hasHD = urllib.unquote( params.get("hasHD") ) # SD preferred, but the URL is for HD... if self.video_quality == "0" and hasHD == "0": umthumbnail = urllib.unquote( params.get("umthumbnail") ) movie_id_sd = self.MOSES_MOVIES_THUMBS.search( umthumbnail ).group(1) # Get data... usock = urllib.urlopen( "http://mosii.gametrailers.com/getmediainfo4.php?hd=1&mid=%s" % movie_id_sd ) htmlData = usock.read() usock.close() # Parse response... params = dict(part.split('=', 1) for part in htmlData.split('&')) umfilename = urllib.unquote( params[ "umfilename" ] ) # # Video URL... # if (self.video_format == "0") : video_url = "http://trailers.gametrailers.com/gt_vault/%s.flv" % umfilename elif (self.video_format == "1") : video_url = "http://trailers.gametrailers.com/gt_vault/%s.mov" % umfilename elif (self.video_format == "2") : video_url = "http://trailers.gametrailers.com/gt_vault/%s.wmv" % umfilename # # Get video URL (method #2)... # if not httpCommunicator.exists(video_url) : neo_xml_url = "http://www.gametrailers.com/neo/?page=xml.mediaplayer.Mediagen&movieId=%s" % movie_id usock = urllib.urlopen( neo_xml_url ) xmldoc = xml.dom.minidom.parse( usock ) usock.close() video_nodes = xmldoc.documentElement.getElementsByTagName( "video" ) if video_nodes != None : src_nodes = video_nodes[0].getElementsByTagName( "src" ) if src_nodes != None : video_url = src_nodes[0].childNodes[0].nodeValue # # Return value # video_urls = [] video_urls.append( video_url ) return video_urls