aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-07-21 13:55:47 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-07-21 13:55:47 +0200
commitf1f725c6a0e567283704046fc21614f4826e77fd (patch)
treedf06e0c709dfd25b31af517836ce0a774f8c9a03 /youtube_dl
parent06c155420fda2a922a7219dd6758f42b868e6d96 (diff)
downloadyoutube-dl-f1f725c6a0e567283704046fc21614f4826e77fd.tar.xz
[dropbox] Fix title encoding on Python 2
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/dropbox.py4
-rw-r--r--youtube_dl/utils.py21
2 files changed, 16 insertions, 9 deletions
diff --git a/youtube_dl/extractor/dropbox.py b/youtube_dl/extractor/dropbox.py
index 1711f0263..9f569aa93 100644
--- a/youtube_dl/extractor/dropbox.py
+++ b/youtube_dl/extractor/dropbox.py
@@ -5,7 +5,7 @@ import os.path
import re
from .common import InfoExtractor
-from ..utils import compat_urllib_parse
+from ..utils import compat_urllib_parse_unquote
class DropboxIE(InfoExtractor):
@@ -23,7 +23,7 @@ class DropboxIE(InfoExtractor):
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
- fn = compat_urllib_parse.unquote(mobj.group('title'))
+ fn = compat_urllib_parse_unquote(mobj.group('title'))
title = os.path.splitext(fn)[0]
video_url = url + '?dl=1'
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index bf4d1112f..3ecd798d7 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -91,11 +91,9 @@ except ImportError:
compat_subprocess_get_DEVNULL = lambda: open(os.path.devnull, 'w')
try:
- from urllib.parse import parse_qs as compat_parse_qs
-except ImportError: # Python 2
- # HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
- # Python 2's version is apparently totally broken
- def _unquote(string, encoding='utf-8', errors='replace'):
+ from urllib.parse import unquote as compat_urllib_parse_unquote
+except ImportError:
+ def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
if string == '':
return string
res = string.split('%')
@@ -130,6 +128,13 @@ except ImportError: # Python 2
string += pct_sequence.decode(encoding, errors)
return string
+
+try:
+ from urllib.parse import parse_qs as compat_parse_qs
+except ImportError: # Python 2
+ # HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
+ # Python 2's version is apparently totally broken
+
def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace'):
qs, _coerce_result = qs, unicode
@@ -149,10 +154,12 @@ except ImportError: # Python 2
continue
if len(nv[1]) or keep_blank_values:
name = nv[0].replace('+', ' ')
- name = _unquote(name, encoding=encoding, errors=errors)
+ name = compat_urllib_parse_unquote(
+ name, encoding=encoding, errors=errors)
name = _coerce_result(name)
value = nv[1].replace('+', ' ')
- value = _unquote(value, encoding=encoding, errors=errors)
+ value = compat_urllib_parse_unquote(
+ value, encoding=encoding, errors=errors)
value = _coerce_result(value)
r.append((name, value))
return r