aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/youtube.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-03-26 01:46:57 +0600
committerSergey M․ <dstftw@gmail.com>2016-03-26 01:46:57 +0600
commit15707c7e024f1f29e7abd8ddaa362196ef2d4af6 (patch)
tree25f149d9df1cf58a171ecf765dd3cd5d0a20f87b /youtube_dl/extractor/youtube.py
parent2156f16ca7babde4c5fa813dbe4e7ac1a2f758d1 (diff)
[compat] Add compat_urllib_parse_urlencode and eliminate encode_dict
encode_dict functionality has been improved and moved directly into compat_urllib_parse_urlencode All occurrences of compat_urllib_parse.urlencode throughout the codebase have been replaced by compat_urllib_parse_urlencode Closes #8974
Diffstat (limited to 'youtube_dl/extractor/youtube.py')
-rw-r--r--youtube_dl/extractor/youtube.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 96fa3b5aa..83b5840f7 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -17,16 +17,15 @@ from ..swfinterp import SWFInterpreter
from ..compat import (
compat_chr,
compat_parse_qs,
- compat_urllib_parse,
compat_urllib_parse_unquote,
compat_urllib_parse_unquote_plus,
+ compat_urllib_parse_urlencode,
compat_urllib_parse_urlparse,
compat_urlparse,
compat_str,
)
from ..utils import (
clean_html,
- encode_dict,
error_to_compat_str,
ExtractorError,
float_or_none,
@@ -116,7 +115,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'hl': 'en_US',
}
- login_data = compat_urllib_parse.urlencode(encode_dict(login_form_strs)).encode('ascii')
+ login_data = compat_urllib_parse_urlencode(login_form_strs).encode('ascii')
req = sanitized_Request(self._LOGIN_URL, login_data)
login_results = self._download_webpage(
@@ -149,7 +148,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
'TrustDevice': 'on',
})
- tfa_data = compat_urllib_parse.urlencode(encode_dict(tfa_form_strs)).encode('ascii')
+ tfa_data = compat_urllib_parse_urlencode(tfa_form_strs).encode('ascii')
tfa_req = sanitized_Request(self._TWOFACTOR_URL, tfa_data)
tfa_results = self._download_webpage(
@@ -1007,7 +1006,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
continue
sub_formats = []
for ext in self._SUBTITLE_FORMATS:
- params = compat_urllib_parse.urlencode({
+ params = compat_urllib_parse_urlencode({
'lang': lang,
'v': video_id,
'fmt': ext,
@@ -1056,7 +1055,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if caption_url:
timestamp = args['timestamp']
# We get the available subtitles
- list_params = compat_urllib_parse.urlencode({
+ list_params = compat_urllib_parse_urlencode({
'type': 'list',
'tlangs': 1,
'asrs': 1,
@@ -1075,7 +1074,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
sub_lang = lang_node.attrib['lang_code']
sub_formats = []
for ext in self._SUBTITLE_FORMATS:
- params = compat_urllib_parse.urlencode({
+ params = compat_urllib_parse_urlencode({
'lang': original_lang,
'tlang': sub_lang,
'fmt': ext,
@@ -1094,7 +1093,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
caption_tracks = args['caption_tracks']
caption_translation_languages = args['caption_translation_languages']
caption_url = compat_parse_qs(caption_tracks.split(',')[0])['u'][0]
- parsed_caption_url = compat_urlparse.urlparse(caption_url)
+ parsed_caption_url = compat_urllib_parse_urlparse(caption_url)
caption_qs = compat_parse_qs(parsed_caption_url.query)
sub_lang_list = {}
@@ -1110,7 +1109,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'fmt': [ext],
})
sub_url = compat_urlparse.urlunparse(parsed_caption_url._replace(
- query=compat_urllib_parse.urlencode(caption_qs, True)))
+ query=compat_urllib_parse_urlencode(caption_qs, True)))
sub_formats.append({
'url': sub_url,
'ext': ext,
@@ -1140,7 +1139,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'cpn': [cpn],
})
playback_url = compat_urlparse.urlunparse(
- parsed_playback_url._replace(query=compat_urllib_parse.urlencode(qs, True)))
+ parsed_playback_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
self._download_webpage(
playback_url, video_id, 'Marking watched',
@@ -1225,7 +1224,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
# this can be viewed without login into Youtube
url = proto + '://www.youtube.com/embed/%s' % video_id
embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage')
- data = compat_urllib_parse.urlencode({
+ data = compat_urllib_parse_urlencode({
'video_id': video_id,
'eurl': 'https://youtube.googleapis.com/v/' + video_id,
'sts': self._search_regex(
@@ -2085,7 +2084,7 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubePlaylistIE):
'spf': 'navigate',
}
url_query.update(self._EXTRA_QUERY_ARGS)
- result_url = 'https://www.youtube.com/results?' + compat_urllib_parse.urlencode(url_query)
+ result_url = 'https://www.youtube.com/results?' + compat_urllib_parse_urlencode(url_query)
data = self._download_json(
result_url, video_id='query "%s"' % query,
note='Downloading page %s' % pagenum,