Python Youtube API: Download function not working

I want to create an application that allows the user to upload videos to Youtube. Here is the code I tried (adapted from http://code.google.com/p/gdata-python-client/source/browse/tests/gdata_tests/youtube/service_test.py ):

my_media_group = gdata.media.Group(
                                       title = gdata.media.Title(text=title),
                                       description = gdata.media.Description(description_type='plain',
                                                                             text=description),
                                       keywords = gdata.media.Keywords(text= tags),
                                       category = gdata.media.Category(
                                                                       text='Autos',
                                                                       scheme='http://gdata.youtube.com/schemas/2007/categories.cat',
                                                                       label='Autos'),
                                       player=None
    )
    # Set Geo location to 37,-122 lat, long
    where = gdata.geo.Where()
    where.set_location((37.0,-122.0))
    video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group, geo=where)
    print "Creating a video entry: done."
    print "Uploading video"
    new_entry = self.client.InsertVideoEntry(video_entry, filepath)
    print "Done uploading video."

It always gets stuck in the second last line:

new_entry = self.client.InsertVideoEntry(video_entry, filepath)

So what happened? Is there any requirement for a file path (for example, is the path "C: \ video.avi" valid?)

In fact, I just need a download method, so please suggest any possible solution.

Edit: 1. I tried to turn on the Youtube download widget, but it doesn’t work: (there is only one option to download from a webcam, and this also does not work.)

<iframe id="widget" type="text/html" width="640" height="390"
  src="https://www.youtube.com/upload_embed" frameborder="0"></iframe>
  1. QWebview Youtube, Youtube . QWebview: Youtube

2:

:

def getYtSession(self, email = '', password =''):
    # if we do not want to reuse our session.
    if email != '' and password != '':
        yt_service = gdata.youtube.service.YouTubeService()
        yt_service.email = email
        yt_service.password = password

        #login.
        try:
            print yt_service.ProgrammaticLogin()
            self.email = email
            self.password = password
            self.logged_in = True
            self.emit(QtCore.SIGNAL('doneLogin(QString)'), QtCore.QString(email + " " + password))
            return yt_service
        except:
            #Display a warning dialog.
            self.logged_in = False
            self.emit(QtCore.SIGNAL('failedLogin()'))
            return None      
    elif self.yt_service: # we want to reuse the session.
        return self.yt_service
    else:
        return gdata.youtube.service.YouTubeService()

:

self.yt_service = self.getYtSession(self.email, self.password)
    try:
        new_entry = self.yt_service.InsertVideoEntry(video_entry, filepath)
        print "Done uploading video."
        self.emit(QtCore.SIGNAL('doneUpload(QString)'), QtCore.QString('Title: ' + title + '\nPath: ' + filepath))
    except:
        print "Stack trace:"
        traceback.print_stack()

- . : :

Stack trace:Login successfully.

"D:\workplace\simple-media-player\trunk\MyPlayer\src\QtThread.py", 19,   self.function(* self.args, ** self.kwargs) "D:\workplace\simple-media-player\trunk\MyPlayer\src\videoplayer.py", 490, doRealUpload   traceback.print_stack()

( " ." ) , doneLogin (QString).

new_entry = self.yt_service.InsertVideoEntry(video_entry, filepath)
        print "Done uploading video."
        self.emit(QtCore.SIGNAL('doneUpload(QString)'), QtCore.QString('Title: ' + title + '\nPath: ' + filepath))

try-except, .

: : : C:/Users/huynh/Desktop/REcord1.wmv : ' ' : 'test, youtube' : fafafa

0

Source: https://habr.com/ru/post/1536842/


All Articles