Sean
Sean

Reputation: 69

How can I retrieve the URL of a video I have just uploaded?

I have a Python script that pushes a video file to our Vimeo page via the api, which works perfectly. I'm just having trouble retrieving the link for the video we just uploaded. I found a snippet in the example documentation but it doesnt seem to work.

import vimeo
import sys

client = vimeo.VimeoClient(
  token="xxxxx",
  key="xxxxx",
  secret="xxxxx"
)

# Make the request to the server for the "/me" endpoint.
about_me = client.get("/me")

# Make sure we got back a successful response.
assert about_me.status_code == 200

# Load the body"s JSON data. WORKS UP TO THIS LINE ENABLE BELOW
print (about_me.json())
#sys.exit(0)

# Path to upload file
path_to_file = r"C:\Users\mydocs\Documents\SS19xGEN.mp4"

print('Uploading: %s' % path_to_file)

# Push file with credentials
client.upload(path_to_file, data={'name': 'TEST', 'description': 'test'})

# Return the uri
print("The uri for the video is %s" % (client))

video_data = client.get(client + 'fields=link').json()
print(('"%s" has been uploaded to %s' % (path_to_file, video_data['link'])))

The script works well up until the last two lines, which is my attempt at retrieving the URL of the video I just uploaded in the script, but that gives me the error = "Exception has occurred: TypeError unsupported operand type(s) for +: 'VimeoClient' and 'str'"

I have poured through the documentation and can't find any examples of how to do this, apologies for the beginner question!

Upvotes: 0

Views: 1245

Answers (2)

Viktor Ilienko
Viktor Ilienko

Reputation: 895

Other way is to receive list of videos using parameters sort and per_page=1

video_data = client.get('https://api.vimeo.com/me/videos?sort=date&per_page=1').json()    

Add fields you need in the end of url

Upvotes: 0

Mike Scotty
Mike Scotty

Reputation: 10782

According to the docs, the upload method should return the uri:

# Push file with credentials
video_uri = client.upload(path_to_file, data={'name': 'TEST', 'description': 'test'})

# Return the uri
print("The uri for the video is %s" % (video_uri))

Upvotes: 3

Related Questions