2011-12-12 63 views
3

我無法獲取包含鏈接rel =「edit」的視頻條目。我需要這樣一個條目才能打電話給DeleteVideoEntry(...)使用Python GData API無法獲取可編輯的視頻條目

我正在使用GetYouTubeVideoEntry(youtube_id=XXXXXXX)檢索視頻。我的yt_service使用用戶名,密碼和開發人員密鑰進行初始化。我使用ProgrammaticLogin。這部分似乎工作正常。我使用相同的yt_service來上傳視頻。另外,如果我將開發人員密鑰更改爲錯誤(在調試期間)並嘗試進行身份驗證,則會出現403錯誤。這使我相信身份驗證工作正常。

無需贅言,通過GetYouTubeVideoEntry(youtube_id=XXXXXXX)檢索到的視頻條目不包含編輯鏈接,我無法使用DeleteVideoEntry(...)調用中的條目。

是否有一些特殊的方式來獲取視頻條目,其中將包含鏈接元素與rel =「edit」?任何人都可以建議一些方法來解決我的問題?這可能是一個錯誤?

更新:

對於記錄,當我試圖讓我的所有上傳的飼料,然後通過視頻條目循環,視頻條目確實有一個編輯聯繫。因此,使用這個工程:

uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads' % username 
feed = yt_service.GetYouTubeVideoFeed(uri) 
for entry in feed.entry: 
    yt_service.DeleteVideoEntry(entry) 

但這並不:

entry = yt_service.GetYouTubeVideoEntry(video_id = video.youtube_id) 
yt_service.DeleteVideoEntry(entry) 

使用相同的yt_service。

+0

我很高興我能幫助。 –

回答

6

我使用GDATA和ProgrammaticLogin()

下面是一些步驟來重現剛刪除YouTube視頻因爲GetYouTubeVideoFeed不檢查uri,只是調用self.Get(uri, ...)但原來,我認爲,它預計'https://gdata.youtube.com/feeds/api/videos' uri。

反之亦然yt_service.GetYouTubeVideoEntry()使用YOUTUBE_VIDEO_URI = 'https://gdata.youtube.com/feeds/api/videos'但該項不包含rel="edit"

希望幫助你出來

1

您可以通過將調試標誌設置爲true來查看生成的請求的HTTP標頭。這是簡單的:

import gdata.youtube.service 
yt_service = gdata.youtube.service.YouTubeService() 

yt_service.developer_key = 'developer_key' 
yt_service.email = 'email' 
yt_service.password = 'password' 
yt_service.ProgrammaticLogin() 


# video_id should looks like 'iu6Gq-tUsTc' 
uri = 'https://gdata.youtube.com/feeds/api/users/%s/uploads/%s' % (username, video_id) 
entry = yt_service.GetYouTubeUserEntry(uri=uri) 
response = yt_service.DeleteVideoEntry(entry) 
print response # True 

yt_service.GetYouTubeVideoFeed(uri)

yt_service = gdata.youtube.service.YouTubeService() 
yt_service.debug = True 

You can read about this in the documentation here.