aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/__init__.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-01-05 10:46:21 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2012-01-05 10:46:21 +0100
commit1413cd87ebe7297aa48fae43bce9c92a751641fb (patch)
tree43f08602c937d48059eb9a1fe118e0310a31556f /youtube_dl/__init__.py
parentc92e184f751a3b58b5a6fbf090f4882932e5bd4b (diff)
Correct distinction between unicode and bytes (Closes: #257)
Diffstat (limited to 'youtube_dl/__init__.py')
-rwxr-xr-xyoutube_dl/__init__.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 2404e2359..fef2afe17 100755
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -290,6 +290,15 @@ def _orderedSet(iterable):
res.append(el)
return res
+def _unescapeHTML(s):
+ """
+ @param s a string (of type unicode)
+ """
+ assert type(s) == type(u'')
+
+ htmlParser = HTMLParser.HTMLParser()
+ return htmlParser.unescape(s)
+
class DownloadError(Exception):
"""Download Error exception.
@@ -1590,8 +1599,6 @@ class DailymotionIE(InfoExtractor):
self._downloader.to_screen(u'[dailymotion] %s: Extracting information' % video_id)
def _real_extract(self, url):
- htmlParser = HTMLParser.HTMLParser()
-
# Extract id and simplified title from URL
mobj = re.match(self._VALID_URL, url)
if mobj is None:
@@ -1635,7 +1642,7 @@ class DailymotionIE(InfoExtractor):
if mobj is None:
self._downloader.trouble(u'ERROR: unable to extract title')
return
- video_title = htmlParser.unescape(mobj.group('title')).decode('utf-8')
+ video_title = _unescapeHTML(mobj.group('title').decode('utf-8'))
video_title = sanitize_title(video_title)
simple_title = _simplify_title(video_title)