2013-05-13 105 views
0

對不起,如果這是一個愚蠢的問題,我瀏覽了YouTube python API,我似乎無法找到任何東西。Youtube API:你如何獲得我剛剛上傳的視頻的網址?

基本上我想要做的就是上傳視頻,然後在視頻ID完成上傳後獲取視頻ID。

有沒有一種簡單的方法來做到這一點在python中?

使用API​​的V2。

回答

0

有一個great example in YouTube API Samples project。 舉例來說,它會返回video id,因此對於youtube網站,完整網址爲www.youtube.com/watch?v={videoId}。您可以爲其他人使用嵌入網址,只需要此視頻ID即可。

+0

這看起來像是使用V3 API我想知道在V2中是否有可能? – George 2013-05-14 10:58:25

0

我設法找到了一個非常乏味的方式。

最後我得到了我的YouTube帳戶的上傳,然後有一些gacking得到我最近上傳的視頻。

這裏是我的代碼:

def YouTubeUpload(Loacation): 

    # Video upload code here: 

    uri = 'https://gdata.youtube.com/feeds/api/users/default/uploads' 
    GetAndPrintVideoFeed(uri) 

def GetAndPrintVideoFeed (Uri): 
    yt_service = gdata.youtube.service.YouTubeService() 
    feed = yt_service.GetYouTubeVideoFeed(uri) 
    num = 0 

    for entry in feed.entry: 
    num += 1 
    PrintEntryDetails(entry) 
    if (num==1): 
     break 

def PrintEntryDetails(entry): 
    global theurl 
    theurl = entry.media.player.url 
    print 'Video url: %s' % entry.media.player.url 

Probally沒有這樣做的最大的方式,但它的作品,我猜。我希望這可以幫助任何面臨同樣問題的人。

相關問題