python-ox/ox/web/dailymotion.py

22 lines
925 B
Python
Raw Normal View History

2010-07-07 23:25:57 +00:00
# -*- coding: utf-8 -*-
2010-09-03 21:19:19 +00:00
# vi:si:et:sw=4:sts=4:ts=4
import re
from urllib import unquote
from ox.cache import read_url
2010-09-03 21:19:19 +00:00
2012-08-15 15:15:40 +00:00
def get_video_url(url):
2010-09-03 21:19:19 +00:00
'''
2012-09-09 17:28:11 +00:00
>>> get_video_url('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3opar_priere-pour-refuznik-1-jeanluc-goda_shortfilms').split('?auth')[0]
2010-09-03 21:19:19 +00:00
'http://www.dailymotion.com/cdn/FLV-320x240/video/x3opar_priere-pour-refuznik-1-jean-luc-god_shortfilms.flv'
2012-09-09 17:28:11 +00:00
>>> get_video_url('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3ou94_priere-pour-refuznik-2-jeanluc-goda_shortfilms').split('?auth')[0]
2010-09-03 21:19:19 +00:00
'http://www.dailymotion.com/cdn/FLV-320x240/video/x3ou94_priere-pour-refuznik-2-jean-luc-god_shortfilms.flv'
'''
data = read_url(url)
2010-09-03 21:19:19 +00:00
video = re.compile('''video", "(.*?)"''').findall(data)
for v in video:
v = unquote(v).split('@@')[0]
return v
return ''