def playVideo( self ) : if (self.DEBUG) : print "video_page_url = " + self.video_page_url # # Get current list item details... # title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) thumbnail = xbmc.getInfoImage( "ListItem.Thumb" ) studio = unicode( xbmc.getInfoLabel( "ListItem.Studio" ), "utf-8" ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) genre = unicode( xbmc.getInfoLabel( "ListItem.Genre" ), "utf-8" ) # # Show wait dialog while parsing data... # dialogWait = xbmcgui.DialogProgress() dialogWait.create( __language__(30504), title ) # # Video page URL = /player/48119.html # if (self.PLAYER_URL_RE.match( self.video_page_url ) ) : video_urls = self._getVideoUrl1( self.video_page_url ) # # Video page URL = /episode/bonusround/303?ch=2&sd=1 # elif (self.EPISODE_BONUSROUND_URL_RE.match ( self.video_page_url ) ) : video_urls = self._getVideoUrl2( self.video_page_url ) # # Video page URL = /video/brutal-b-roll-darksiders/49436 # elif (self.VIDEO_URL_RE.match( self.video_page_url ) ) : video_urls = self._getVideoUrl3( self.video_page_url ) # # Video page URL = /gametrailerstv_player.php?ep=60&ch=1&sd=1 # Video page URL = /episode/gametrailers-tv/64&ch=2&sd=0?ep=64&ch=2&sd=0 # elif (self.GAMETRAILERS_TV_PLAYER_RE.match( self.video_page_url ) or self.EPISODE_GAMETRAILER_TV_RE.match( self.video_page_url ) ) : video_urls = self._getVideoUrl4( self.video_page_url ) # # Video page URL = /bonusround.php?ep=15 # elif (self.BONUSROUND_PHP_URL_RE.match( self.video_page_url ) ) : video_urls = self._getVideoUrl5( self.video_page_url ) # # Video page URL = player/usermovies/1.html # elif (self.USER_MOVIES_URL_RE.match( self.video_page_url ) ) : video_urls = self._getVideoUrl6( self.video_page_url ) # # Video page URL = /videos/1tx4bz/planetside-2-gc-2012--exclusive-beta-walkthrough--cam- # elif (self.VIDEOS_URL_RE.match( self.video_page_url ) or \ self.REVIEWS_URL_RE.match( self.video_page_url ) or \ self.FULL_EPISODES_URL_RE.match( self.video_page_url )) : video_urls = self._getVideoUrl7( self.video_page_url ) # # Check video URLs... # httpCommunicator = HTTPCommunicator() have_valid_url = False for video_url in video_urls : if httpCommunicator.exists( video_url ) : have_valid_url = True break # # Play video... # if have_valid_url : playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO ) playlist.clear() for video_url in video_urls : listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail ) listitem.setInfo( "video", { "Title": title, "Studio" : studio, "Plot" : plot, "Genre" : genre } ) playlist.add( video_url, listitem ) # Close wait dialog... dialogWait.close() del dialogWait # Play video... xbmcPlayer = xbmc.Player( self.video_players[ self.video_player ] ) xbmcPlayer.play( playlist ) # # Alert user... # else : xbmcgui.Dialog().ok( __language__(30000), __language__(30505) )
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