nficano commited on
Commit
79e3d84
·
1 Parent(s): 2501220
Files changed (1) hide show
  1. pytube/api.py +4 -4
pytube/api.py CHANGED
@@ -170,7 +170,7 @@ class YouTube(object):
170
 
171
  # For each video url, identify the quality profile and add it to list
172
  # of available videos.
173
- for idx, url in enumerate(video_urls):
174
  log.debug("attempting to get quality profile from url: %s", url)
175
  try:
176
  itag, quality_profile = self._get_quality_profile_from_url(url)
@@ -186,7 +186,7 @@ class YouTube(object):
186
  if "signature=" not in url:
187
  log.debug("signature not in url, attempting to resolve the "
188
  "cipher.")
189
- signature = self._get_cipher(stream_map["s"][idx], js_url)
190
  url = "{0}&signature={1}".format(url, signature)
191
  self._add_video(url, self.filename, **quality_profile)
192
  # Clear the cached js. Make sure to keep this at the end of
@@ -336,7 +336,7 @@ class YouTube(object):
336
  """
337
  unmatched_brackets_num = 0
338
  index = 1
339
- for idx, ch in enumerate(html):
340
  if isinstance(ch, int):
341
  ch = chr(ch)
342
  if ch == "{":
@@ -347,7 +347,7 @@ class YouTube(object):
347
  break
348
  else:
349
  raise PytubeError("Unable to determine json offset.")
350
- return index + idx
351
 
352
  def _get_cipher(self, signature, url):
353
  """Gets the signature using the cipher.
 
170
 
171
  # For each video url, identify the quality profile and add it to list
172
  # of available videos.
173
+ for i, url in enumerate(video_urls):
174
  log.debug("attempting to get quality profile from url: %s", url)
175
  try:
176
  itag, quality_profile = self._get_quality_profile_from_url(url)
 
186
  if "signature=" not in url:
187
  log.debug("signature not in url, attempting to resolve the "
188
  "cipher.")
189
+ signature = self._get_cipher(stream_map["s"][i], js_url)
190
  url = "{0}&signature={1}".format(url, signature)
191
  self._add_video(url, self.filename, **quality_profile)
192
  # Clear the cached js. Make sure to keep this at the end of
 
336
  """
337
  unmatched_brackets_num = 0
338
  index = 1
339
+ for i, ch in enumerate(html):
340
  if isinstance(ch, int):
341
  ch = chr(ch)
342
  if ch == "{":
 
347
  break
348
  else:
349
  raise PytubeError("Unable to determine json offset.")
350
+ return index + i
351
 
352
  def _get_cipher(self, signature, url):
353
  """Gets the signature using the cipher.