Bill Davis commited on
Commit
3640c7f
·
1 Parent(s): 2bf6c7d

Add default for age_restricted in extract.get_ytplayer_config and extract.js_url

Browse files
pytube/__main__.py CHANGED
@@ -109,7 +109,7 @@ class YouTube(object):
109
  self.player_config_args = self.vid_info
110
  else:
111
  self.player_config_args = extract.get_ytplayer_config(
112
- self.watch_html, self.age_restricted
113
  )['args']
114
 
115
  # https://github.com/nficano/pytube/issues/165
 
109
  self.player_config_args = self.vid_info
110
  else:
111
  self.player_config_args = extract.get_ytplayer_config(
112
+ self.watch_html
113
  )['args']
114
 
115
  # https://github.com/nficano/pytube/issues/165
pytube/extract.py CHANGED
@@ -111,7 +111,7 @@ def video_info_url(
111
  return 'https://youtube.com/get_video_info?' + urlencode(params)
112
 
113
 
114
- def js_url(html, age_restricted):
115
  """Get the base JavaScript url.
116
 
117
  Construct the base JavaScript url, which contains the decipher
@@ -119,6 +119,8 @@ def js_url(html, age_restricted):
119
 
120
  :param str watch_html:
121
  The html contents of the watch page.
 
 
122
 
123
  """
124
  ytplayer_config = get_ytplayer_config(html, age_restricted)
@@ -150,7 +152,7 @@ def mime_type_codec(mime_type_codec):
150
  return mime_type, [c.strip() for c in codecs.split(',')]
151
 
152
 
153
- def get_ytplayer_config(html, age_restricted):
154
  """Get the YouTube player configuration data from the watch html.
155
 
156
  Extract the ``ytplayer_config``, which is json data embedded within the
@@ -159,6 +161,8 @@ def get_ytplayer_config(html, age_restricted):
159
 
160
  :param str watch_html:
161
  The html contents of the watch page.
 
 
162
  :rtype: str
163
  :returns:
164
  Substring of the html containing the encoded manifest data.
 
111
  return 'https://youtube.com/get_video_info?' + urlencode(params)
112
 
113
 
114
+ def js_url(html, age_restricted=False):
115
  """Get the base JavaScript url.
116
 
117
  Construct the base JavaScript url, which contains the decipher
 
119
 
120
  :param str watch_html:
121
  The html contents of the watch page.
122
+ :param bool age_restricted:
123
+ Is video age restricted.
124
 
125
  """
126
  ytplayer_config = get_ytplayer_config(html, age_restricted)
 
152
  return mime_type, [c.strip() for c in codecs.split(',')]
153
 
154
 
155
+ def get_ytplayer_config(html, age_restricted=False):
156
  """Get the YouTube player configuration data from the watch html.
157
 
158
  Extract the ``ytplayer_config``, which is json data embedded within the
 
161
 
162
  :param str watch_html:
163
  The html contents of the watch page.
164
+ :param bool age_restricted:
165
+ Is video age restricted.
166
  :rtype: str
167
  :returns:
168
  Substring of the html containing the encoded manifest data.
tests/test_extract.py CHANGED
@@ -33,7 +33,7 @@ def test_info_url(cipher_signature):
33
 
34
  def test_js_url(cipher_signature):
35
  expected = 'https://youtube.com/yts/jsbin/player-vflOdyxa4/en_US/base.js'
36
- result = extract.js_url(cipher_signature.watch_html, False)
37
  assert expected == result
38
 
39
 
 
33
 
34
  def test_js_url(cipher_signature):
35
  expected = 'https://youtube.com/yts/jsbin/player-vflOdyxa4/en_US/base.js'
36
+ result = extract.js_url(cipher_signature.watch_html)
37
  assert expected == result
38
 
39