示例#1
0
 def _download_video( self ):
     try:
         # Youtube client
         client = YoutubeClient()
         # construct the video url with session id and get video details
         url, self.g_title, self.g_director, self.g_genre, self.g_rating, self.g_runtime, self.g_count, self.g_date, self.g_thumbnail, self.g_plotoutline, video_id = client.construct_video_url( self.args.video_url, ( 0, 6, 18, )[ int( xbmcplugin.getSetting( "quality" ) ) ] )
         # create our temp save path
         tmp_path = xbmc.translatePath( "Z:\\%s.flv" % ( video_id, ) )
         # get a valid filepath
         if ( self.settings[ "use_title" ] ):
             # add extension to video title
             title = self.g_title + ".flv"
         else:
             # we use the urls trailer name
             title = video_id + ".flv"
         # make the path legal for the users platform
         self.filepath = self._make_legal_filepath( title )
         # get the filesystem the trailer will be saved to
         filesystem = self._get_filesystem()
         # win32 requires encoding to work proper
         if ( self._get_filesystem() == "win32" ):
             filepath = self.filepath.encode( "utf-8" )
         else:
             filepath = self.filepath
         # only download if the trailer doesn't exist
         if ( not os.path.isfile( tmp_path ) ):
             # fetch the video
             urllib.urlretrieve( url, tmp_path, self._report_hook )
         ok = True
         # finalize
         if ( not os.path.isfile( filepath ) ):
             # copy to final location
             ok = self._finalize_download( tmp_path )
             # if the copy failed raise an error
             if ( not ok ): raise
     except:
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         # filepath is not always released immediately, we may need to try more than one attempt, sleeping between
         urllib.urlcleanup()
         remove_tries = 3
         while remove_tries and os.path.isfile( tmp_path ):
             try:
                 os.remove( tmp_path )
             except:
                 remove_tries -= 1
                 xbmc.sleep( 1000 )
         pDialog.close()
         self.filepath = ""
示例#2
0
 def _download_video( self ):
     try:
         # Youtube client
         client = YoutubeClient( authkey=xbmcplugin.getSetting( "authkey" ) )
         # construct the video url with session id and get video details
         url, self.g_title, self.g_director, self.g_genre, self.g_rating, self.g_runtime, self.g_count, self.g_date, self.g_thumbnail, self.g_plotoutline, video_id = client.construct_video_url( self.args.video_url, ( 18, 22, )[ xbmcplugin.getSetting( "hd_videos" ) == "true" ] )
         # create our temp save path
         tmp_path = xbmc.translatePath( "special://temp/%s.flv" % ( video_id, ) )
         # get a valid filepath
         if ( self.settings[ "use_title" ] ):
             # add extension to video title
             title = self.g_title + ".flv"
         else:
             # we use the urls trailer name
             title = video_id + ".flv"
         # make the path legal for the users platform
         self.filepath = self._make_legal_filepath( title )
         # get the filesystem the trailer will be saved to
         filesystem = self._get_filesystem()
         # win32 requires encoding to work proper
         if ( self._get_filesystem() == "win32" ):
             filepath = self.filepath.encode( "UTF-8" )
         else:
             filepath = self.filepath
         # only download if the trailer doesn't exist
         if ( not os.path.isfile( tmp_path ) and not os.path.isfile( self.filepath ) ):
             # fetch the video
             urllib.urlretrieve( url, tmp_path, self._report_hook )
         ok = True
         # finalize
         if ( not os.path.isfile( filepath ) ):
             # copy to final location
             ok = self._finalize_download( tmp_path )
         # if the copy failed raise an error
         if ( not ok ): raise
     except:
         print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], )
         # filepath is not always released immediately, we may need to try more than one attempt, sleeping between
         urllib.urlcleanup()
         remove_tries = 3
         while remove_tries and os.path.isfile( tmp_path ):
             try:
                 os.remove( tmp_path )
             except:
                 remove_tries -= 1
                 xbmc.sleep( 1000 )
         pDialog.close()
         self.filepath = ""
示例#3
0
 def _play_video(self):
     # Youtube client
     client = YoutubeClient(authkey=xbmcplugin.getSetting("authkey"))
     # construct the video url with session id and get video details
     url, title, director, genre, rating, runtime, count, date, thumbnail, plotoutline, video_id = client.construct_video_url(
         self.args.video_url, (
             18,
             22,
         )[xbmcplugin.getSetting("hd_videos") == "true"])
     # get cached thumbnail, no need to redownload
     thumbnail = xbmc.getCacheThumbName(sys.argv[0] + sys.argv[2])
     thumbnail = os.path.join(xbmc.translatePath("special://profile"),
                              "Thumbnails", "Video", thumbnail[0],
                              thumbnail)
     # construct our listitem
     listitem = xbmcgui.ListItem(title, thumbnailImage=thumbnail, path=url)
     # set the key information
     listitem.setInfo(
         "video", {
             "Title": title,
             "Plotoutline": plotoutline,
             "Plot": plotoutline,
             "Director": director,
             "Genre": genre,
             "Rating": rating,
             "Date": date
         })
     # Resolve url
     xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
 def play_video( self, video_id ):
     # Youtube client
     client = YoutubeClient( authkey=xbmcplugin.getSetting( "authkey" ) )
     # construct the video url
     video_url = client.BASE_ID_URL % ( video_id, )
     # fetch video information
     url, title, author, genre, rating, runtime, count, date, thumbnail_url, plot, video_id = client.construct_video_url( video_url, ( 18, 22, )[ xbmcplugin.getSetting( "hd_videos" ) == "true" ] )
     # get cached thumbnail, no need to redownload
     thumbnail = xbmc.getCacheThumbName( sys.argv[ 0 ] + sys.argv[ 2 ] + video_id )
     thumbnail = os.path.join( xbmc.translatePath( "special://profile" ), "Thumbnails", "Video", thumbnail[ 0 ], thumbnail )
     # if thumb not found download it
     if ( not os.path.isfile( thumbnail ) ):
         xbmc.executehttpapi( "FileCopy(%s,%s)" % ( thumbnail_url, thumbnail.encode( "UTF-8" ), ) )
     # construct our listitem
     listitem = xbmcgui.ListItem( title, runtime, thumbnailImage=thumbnail )
     # set the key information
     listitem.setInfo( "video", { "Title": title, "Director": author, "Genre": genre, "Rating": rating, "Duration": runtime, "Count": count, "Date": date, "PlotOutline": plot, "Plot": plot } )
     # Play video with the proper core
     xbmc.Player().play( url, listitem )
 def play_video(self, video_id):
     # Youtube client
     client = YoutubeClient(authkey=xbmcplugin.getSetting("authkey"))
     # construct the video url
     video_url = client.BASE_ID_URL % (video_id, )
     # fetch video information
     url, title, author, genre, rating, runtime, count, date, thumbnail_url, plot, video_id = client.construct_video_url(
         video_url, (
             18,
             22,
         )[xbmcplugin.getSetting("hd_videos") == "true"])
     # get cached thumbnail, no need to redownload
     thumbnail = xbmc.getCacheThumbName(sys.argv[0] + sys.argv[2] +
                                        video_id)
     thumbnail = os.path.join(xbmc.translatePath("special://profile"),
                              "Thumbnails", "Video", thumbnail[0],
                              thumbnail)
     # if thumb not found download it
     if (not os.path.isfile(thumbnail)):
         xbmc.executehttpapi("FileCopy(%s,%s)" % (
             thumbnail_url,
             thumbnail.encode("utf-8"),
         ))
     # construct our listitem
     listitem = xbmcgui.ListItem(title, runtime, thumbnailImage=thumbnail)
     # set the key information
     listitem.setInfo(
         "video", {
             "Title": title,
             "Director": author,
             "Genre": genre,
             "Rating": rating,
             "Duration": runtime,
             "Count": count,
             "Date": date,
             "PlotOutline": plot,
             "Plot": plot
         })
     # Play video with the proper core
     xbmc.Player().play(url, listitem)
示例#6
0
 def _play_video( self ):
     # Youtube client
     client = YoutubeClient( authkey=xbmcplugin.getSetting( "authkey" ) )
     # construct the video url with session id and get video details
     url, title, director, genre, rating, runtime, count, date, thumbnail, plotoutline, video_id = client.construct_video_url( self.args.video_url, ( 18, 22, )[ xbmcplugin.getSetting( "hd_videos" ) == "true" ] )
     # get cached thumbnail, no need to redownload
     thumbnail = xbmc.getCacheThumbName( sys.argv[ 0 ] + sys.argv[ 2 ] )
     thumbnail = os.path.join( xbmc.translatePath( "special://profile" ), "Thumbnails", "Video", thumbnail[ 0 ], thumbnail )
     # construct our listitem
     listitem = xbmcgui.ListItem( title, thumbnailImage=thumbnail, path=url )
     # set the key information
     listitem.setInfo( "video", { "Title": title, "Plotoutline": plotoutline, "Plot": plotoutline, "Director": director, "Genre": genre, "Rating": rating, "Date": date } )
     # Resolve url
     xbmcplugin.setResolvedUrl( int( sys.argv[ 1 ] ), True, listitem )
 def _play_video( self ):
     # Youtube client
     client = YoutubeClient()
     # construct the video url with session id and get video details
     url, g_title, g_director, g_genre, g_rating, g_runtime, g_count, g_date, g_thumbnail, g_plotoutline, video_id = client.construct_video_url( self.args.video_url, ( 0, 6, 18, )[ int( xbmcplugin.getSetting( "quality" ) ) ] )
     # close the dialog
     pDialog.close()
     if ( not pDialog.iscanceled() ):
         # get cached thumbnail, no need to redownload
         g_thumbnail = xbmc.getCacheThumbName( sys.argv[ 0 ] + sys.argv[ 2 ] )
         g_thumbnail = os.path.join( xbmc.translatePath( "p:\\Thumbnails" ), "Video", g_thumbnail[ 0 ], g_thumbnail )
         # construct our listitem
         listitem = xbmcgui.ListItem( g_title, thumbnailImage=g_thumbnail )
         # set the key information
         listitem.setInfo( "video", { "Title": g_title, "Plotoutline": g_plotoutline, "Plot": g_plotoutline, "Director": g_director, "Genre": g_genre, "Rating": g_rating, "Date": g_date } )
         # set special property
         listitem.setProperty( "isVideo", "1" )
         listitem.setProperty( "RecommendLink", sys.argv[ 0 ] + sys.argv[ 2 ] )
         # Play video with the proper core
         xbmc.Player( self.player_core ).play( url, listitem )
示例#8
0
 def play_video(self, video_id):
     # Youtube client
     client = YoutubeClient()
     # construct the video url with session id
     video_url = client.BASE_ID_URL % (video_id, )
     # fetch video information
     url, title, author, genre, rating, runtime, count, date, thumbnail_url, plot, video_id = client.construct_video_url(
         video_url, (
             0,
             6,
             18,
         )[int(xbmcplugin.getSetting("quality"))])
     pDialog.close()
     if (not pDialog.iscanceled()):
         listitem = xbmcgui.ListItem(title,
                                     runtime,
                                     thumbnailImage=thumbnail_url)
         # set the key information
         listitem.setInfo(
             "video", {
                 "Title": title,
                 "Director": author,
                 "Genre": genre,
                 "Rating": rating,
                 "Duration": runtime,
                 "Count": count,
                 "Date": date,
                 "PlotOutline": plot,
                 "Plot": plot
             })
         # Play video with the proper core
         xbmc.Player(self.player_core).play(url, listitem)
示例#9
0
 def _play_video(self):
     # Youtube client
     client = YoutubeClient()
     # construct the video url with session id and get video details
     url, g_title, g_director, g_genre, g_rating, g_runtime, g_count, g_date, g_thumbnail, g_plotoutline, video_id = client.construct_video_url(
         self.args.video_url, (
             0,
             6,
             18,
         )[int(xbmcplugin.getSetting("quality"))])
     # close the dialog
     pDialog.close()
     if (not pDialog.iscanceled()):
         # get cached thumbnail, no need to redownload
         g_thumbnail = xbmc.getCacheThumbName(sys.argv[0] + sys.argv[2])
         g_thumbnail = os.path.join(xbmc.translatePath("p:\\Thumbnails"),
                                    "Video", g_thumbnail[0], g_thumbnail)
         # construct our listitem
         listitem = xbmcgui.ListItem(g_title, thumbnailImage=g_thumbnail)
         # set the key information
         listitem.setInfo(
             "video", {
                 "Title": g_title,
                 "Plotoutline": g_plotoutline,
                 "Plot": g_plotoutline,
                 "Director": g_director,
                 "Genre": g_genre,
                 "Rating": g_rating,
                 "Date": g_date
             })
         # set special property
         listitem.setProperty("isVideo", "1")
         listitem.setProperty("RecommendLink", sys.argv[0] + sys.argv[2])
         # Play video with the proper core
         xbmc.Player(self.player_core).play(url, listitem)