python-oxweb/oxweb/dailymotion.py

23 lines
832 B
Python
Raw Normal View History

2008-06-19 09:47:02 +00:00
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
2008-04-30 13:31:50 +00:00
import re
from urllib import unquote
from oxlib.cache import readUrl
2008-04-30 13:31:50 +00:00
2008-06-19 09:47:02 +00:00
2008-04-30 13:31:50 +00:00
def getVideoUrl(url):
2008-06-19 09:47:02 +00:00
'''
2008-07-05 13:35:46 +00:00
>>> getVideoUrl('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3opar_priere-pour-refuznik-1-jeanluc-goda_shortfilms').split('?key')[0]
'http://www.dailymotion.com/get/16/320x240/flv/6191379.flv'
2008-05-05 18:33:23 +00:00
2008-07-05 13:35:46 +00:00
>>> getVideoUrl('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3ou94_priere-pour-refuznik-2-jeanluc-goda_shortfilms').split('?key')[0]
'http://www.dailymotion.com/get/15/320x240/flv/6197800.flv'
2008-06-19 09:47:02 +00:00
'''
data = readUrl(url)
2008-06-19 09:47:02 +00:00
video = re.compile('''video", "(.*?)"''').findall(data)
for v in video:
v = unquote(v).split('@@')[0]
return "http://www.dailymotion.com" + v
return ''
2008-04-30 13:31:50 +00:00