Add a list of regions to Vimeo using PyVimeo in django

372 Views Asked by At

I have a django app in which i am using PyVimeo module to connect and upload videos etc., to Vimeo

The actual vimeo api to post the region data was here

For example i have the following data [{u'country_name': u'CA'}, {u'country_name': u'US'}] to send a PUT request to the url https://api.vimeo.com/ondemand/pages/47753/regions

From code i was trying to send PUT request as below

import vimeo

token = XXXXXXXXXXXXXXXXXX
VIMEO_KEY = XXXXXXXXXXXXXXXXXX
VIMEO_SECRET = XXXXXXXXXXXXXXXXXX
client = vimeo.VimeoClient(key=VIMEO_KEY, secret=VIMEO_SECRET, token=token)

url = https://api.vimeo.com/ondemand/pages/47753/regions
regions_data = [{u'country_name': u'CA'}, {u'country_name': u'US'}]

result_data = client.put(url, regions_data)

Response was 400 Bad request

When tried in the below way as indicated in the Vimeo API docs

client.put(url + 'CA')

Response

HTTP/1.1 201
Location: Array
Host: api.vimeo.com

But it was not reflecting in the Distribution section of the video setting and being as Worldwide by default

So how actually to set a list of regions to a on demand page VOD ?

1

There are 1 best solutions below

0
Joe Cabrera On

Try setting country_code instead of country_name

v = vimeo.VimeoClient(key=YOUR_VIMEO_KEY,
                      secret=YOUR_VIMEO_SECRET,
                      token=YOUR_VIMEO_TOKEN)

regions_data = [{'country_code': 'CA'}, {'country_code': 'US'}]

output = v.put('/ondemand/pages/mytestvod/regions', data=regions_data)

This should restrict distribution to only Canada and the US.