認証済みユーザーの YouTube から履歴フィードを Python で取得しようとしています。これは私のコードです:
yt_service = gdata.youtube.service.YouTubeService()
def LogIn():
login_name = raw_input('Email:')
login_pass = getpass.getpass()
try:
yt_service.email = login_name
yt_service.password = login_pass
yt_service.ProgrammaticLogin()
except:
print 'False username or password. Unable to authenticate.'
exit();
def GetHistoryFeed():
uri = 'https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2'
feed = yt_service.GetYouTubeVideoFeed(uri)
#PrintVideoFeed(yt_service.GetYouTubeVideoFeed(uri),'history')
LogIn()
GetHistoryFeed()
gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'} と表示されます。認証された Get request を作成する必要があることはわかっていますが、方法がわかりません。私は何を間違っていますか?
編集
私は大きな問題に直面しています。prog は上記と同じですが、yt_service.developer_key = DEVELOPER_KEY
パスワード行の下に と が追加されて いますuri = 'https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2&key=%s'%DEVELOPER_KEY
。4 台の PC でテストしたところ、1 台だけでエラーなく動作しました。このエラーが発生します:
File "/usr/local/lib/python2.6/dist-packages/gdata/youtube/service.py", line 186, in
return self.Get(uri, converter=gdata.youtube.YouTubeVideoFeedFromString)
File "/usr/local/lib/python2.6/dist-packages/gdata/service.py", line 1108, in Get
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid request URI', 'reason': 'Bad Request'}
私は python 2.7 と gdata python 2.0 を使用しています。なぜ 1 台の PC がそれを実行し、残りの PC は実行しないのでしょうか? 修正するにはどうすればよいですか? 助けてください!