1 |
#!/usr/bin/env python |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
3 |
|
|
4 |
__author__ = ( |
__authors__ = ( |
5 |
'Ricardo Garcia Gonzalez', |
'Ricardo Garcia Gonzalez', |
6 |
'Danny Colligan', |
'Danny Colligan', |
7 |
'Benjamin Johnson', |
'Benjamin Johnson', |
18 |
) |
) |
19 |
|
|
20 |
__license__ = 'Public Domain' |
__license__ = 'Public Domain' |
21 |
__version__ = '2011.12.18' |
__version__ = '2012.01.05' |
22 |
|
|
23 |
UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl' |
UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl' |
24 |
|
|
290 |
res.append(el) |
res.append(el) |
291 |
return res |
return res |
292 |
|
|
293 |
|
def _unescapeHTML(s): |
294 |
|
""" |
295 |
|
@param s a string (of type unicode) |
296 |
|
""" |
297 |
|
assert type(s) == type(u'') |
298 |
|
|
299 |
|
htmlParser = HTMLParser.HTMLParser() |
300 |
|
return htmlParser.unescape(s) |
301 |
|
|
302 |
class DownloadError(Exception): |
class DownloadError(Exception): |
303 |
"""Download Error exception. |
"""Download Error exception. |
304 |
|
|
1599 |
self._downloader.to_screen(u'[dailymotion] %s: Extracting information' % video_id) |
self._downloader.to_screen(u'[dailymotion] %s: Extracting information' % video_id) |
1600 |
|
|
1601 |
def _real_extract(self, url): |
def _real_extract(self, url): |
|
htmlParser = HTMLParser.HTMLParser() |
|
|
|
|
1602 |
# Extract id and simplified title from URL |
# Extract id and simplified title from URL |
1603 |
mobj = re.match(self._VALID_URL, url) |
mobj = re.match(self._VALID_URL, url) |
1604 |
if mobj is None: |
if mobj is None: |
1642 |
if mobj is None: |
if mobj is None: |
1643 |
self._downloader.trouble(u'ERROR: unable to extract title') |
self._downloader.trouble(u'ERROR: unable to extract title') |
1644 |
return |
return |
1645 |
video_title = htmlParser.unescape(mobj.group('title')).decode('utf-8') |
video_title = _unescapeHTML(mobj.group('title').decode('utf-8')) |
1646 |
video_title = sanitize_title(video_title) |
video_title = sanitize_title(video_title) |
1647 |
simple_title = _simplify_title(video_title) |
simple_title = _simplify_title(video_title) |
1648 |
|
|
3158 |
return |
return |
3159 |
epTitle = mobj.group('episode') |
epTitle = mobj.group('episode') |
3160 |
|
|
3161 |
mMovieParams = re.findall('<param name="movie" value="(http://media.mtvnservices.com/([^"]*episode.*?:.*?))"/>', html) |
mMovieParams = re.findall('(?:<param name="movie" value="|var url = ")(http://media.mtvnservices.com/([^"]*episode.*?:.*?))"', html) |
3162 |
if len(mMovieParams) == 0: |
if len(mMovieParams) == 0: |
3163 |
self._downloader.trouble(u'ERROR: unable to find Flash URL in webpage ' + url) |
self._downloader.trouble(u'ERROR: unable to find Flash URL in webpage ' + url) |
3164 |
return |
return |