Skip to content

Commit

Permalink
Hotfix for cipher regex detection update
Browse files Browse the repository at this point in the history
This is a backport for our older version of pytube, until we actually
get the newest version merged in (from the asyncio branch)
  • Loading branch information
glubsy committed Apr 15, 2022
1 parent 822f741 commit 5567e82
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions livestream_saver/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# logger.setLevel(logging.DEBUG)

# Temporary backport from pytube 11.0.1
# and also https://github.com/pytube/pytube/issues/1281
def get_throttling_function_name(js: str) -> str:
"""Extract the name of the function that computes the throttling parameter.
Expand All @@ -52,7 +53,7 @@ def get_throttling_function_name(js: str) -> str:
# Bpa.length || iha("")) }};
# In the above case, `iha` is the relevant function name
r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&\s*'
r'\([a-z]\s*=\s*([a-zA-Z0-9$]{3})(\[\d+\])?\([a-z]\)'
r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)'
]
# print('Finding throttling function name')
for pattern in function_patterns:
Expand All @@ -67,7 +68,7 @@ def get_throttling_function_name(js: str) -> str:
idx = idx.strip("[]")
array = re.search(
r'var {nfunc}\s*=\s*(\[.+?\]);'.format(
nfunc=function_match.group(1)),
nfunc=re.escape(function_match.group(1))),
js
)
if array:
Expand Down

0 comments on commit 5567e82

Please sign in to comment.