more python3 cleanups
This commit is contained in:
parent
4b8aad5b38
commit
37dfed3143
9 changed files with 20 additions and 30 deletions
|
|
@ -1,27 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import re
|
||||
from StringIO import StringIO
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import json
|
||||
|
||||
from ox.cache import read_url
|
||||
from ox import find_string, find_re
|
||||
|
||||
|
||||
def get_data(id):
|
||||
url = 'http://www.vimeo.com/moogaloop/load/clip:%s' %id
|
||||
xml = read_url(url)
|
||||
tree = ET.parse(StringIO(xml))
|
||||
request_signature = tree.find('request_signature').text
|
||||
request_signature_expires = tree.find('request_signature_expires').text
|
||||
|
||||
data = {}
|
||||
video_url = "http://www.vimeo.com/moogaloop/play/clip:%s/%s/%s/?q=" % \
|
||||
(id, request_signature, request_signature_expires)
|
||||
data['video_sd'] = video_url + 'sd'
|
||||
data['video_hd'] = video_url + 'hd'
|
||||
video = tree.find('video')
|
||||
for key in ('caption', 'width', 'height', 'duration', 'thumbnail'):
|
||||
data[key] = video.find(key).text
|
||||
url = 'http://vimeo.com/api/v2/video/%s.json' % id
|
||||
data = json.loads(read_url(url).decode('utf-8'))[0]
|
||||
|
||||
url = 'http://player.vimeo.com/video/%s/config?autoplay=0&byline=0&bypass_privacy=1&context=clip.main&default_to_hd=1&portrait=0' % id
|
||||
info = json.loads(read_url(url).decode('utf-8'))
|
||||
data['video'] = info['request']['files']['h264']
|
||||
return data
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue