python-3.xvimeo-apipyvimeo

Trouble getting Vimeo filename from API using PyVimeo


I have an script using Python and PyVimeo that I am working on to use the "GEThttps://api.vimeo.com/videos/{video_id}" so I can get the file name. When I try to run my app, I am getting an error {'error': "The requested video couldn't be found."}. However, when I use this same video ID under the Try it out section (https://developer.vimeo.com/api/reference/videos#get_video), it works fine.

I am assuming there is something wrong with my code, but if I use the demo from the github example (about_me = v.get('/me')), it works fine and that needs authentication as well.

Is there something simple I am missing? Thank you so much.

import vimeo

v = vimeo.VimeoClient(
token= 'VimeoToken',
key= 'VimeoKey',
secret= 'VimeoSecret'
)

class Vimeo:
def get_vimeo_data(video_file):
uri = 'https://api.vimeo.com/videos/{video_file}'
# uri = 'https://api.vimeo.com/me/videos' - This response works
response = v.get(uri)

data = response.json()
print(data)

Vimeo.get_vimeo_data(55555)

Solution

  • You forgot to add an f before your f-string.

    class Vimeo:
        def get_vimeo_data(video_file):
            # THIS f
            uri = f"https://api.vimeo.com/videos/{video_file}"
            # uri = 'https://api.vimeo.com/me/videos' - This response works
            response = v.get(uri)
    
            data = response.json()
            print(data)