pythongoogle-app-enginegdata-python-client

Python YouTube Gdata Api: DeletePlaylist


I have correctly initialized YouTubeService. I can move/delete/rename playlist entries, but when I try to delete playlist I get unhelpfull exception:

_service = None

def get_service():
    global _service

    if _service is None:
        _service = YouTubeService()
        gdata.alt.appengine.run_on_appengine(_service)
        _service.developer_key = settings.YTMANAGER_DEVELOPER_KEY

        if 'token' in get_request().session:
            _service.SetAuthSubToken(get_request().session['token'])

    return _service

def test(request):
    get_service().DeletePlaylist('http://gdata.youtube.com/feeds/api/playlists/921AC6352FE6931F')
    return HttpResponse('ok')

Exception:

Exception Type:  RequestError
Exception Value: {'status': 400, 'body': 'Invalid request URI', 'reason': ''}
Exception Location: \gdata\service.py in Delete, line 1454

Solution

  • Documentation (http://code.google.com/apis/youtube/1.0/developers_guide_python.html#DeletePlaylists) is outdated or this is bug, but DeletePlaylist requires "full" link:

    http://gdata.youtube.com/feeds/api/users/username/playlists/921AC6352FE6931F
    

    since GetYouTubePlaylistVideoFeed method requires "short" link in order to use max-results parameter:

    http://gdata.youtube.com/feeds/api/playlists/921AC6352FE6931F