From 59741c9cd07260edf389a1a6d9fd2967116875e9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 5 Nov 2010 13:00:19 +0100 Subject: [PATCH] vimeo --- ox/web/vimeo.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ox/web/vimeo.py diff --git a/ox/web/vimeo.py b/ox/web/vimeo.py new file mode 100644 index 0000000..66ded41 --- /dev/null +++ b/ox/web/vimeo.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=4:sts=4:ts=4 +import re +from StringIO import StringIO +import xml.etree.ElementTree as ET + +from ox.cache import readUrl, readUrlUnicode +from ox import findString, findRe + + +def getData(id): + url = 'http://www.vimeo.com/moogaloop/load/clip:%s' %id + xml = readUrl(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 + return data +