summaryrefslogtreecommitdiffhomepage
path: root/youtube_dl/swfinterp.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <[email protected]>2014-11-17 01:27:15 +0100
committerPhilipp Hagemeister <[email protected]>2014-11-17 01:27:15 +0100
commitb7558d9881ae0dede7c13e1c082eaf89aefed27e (patch)
tree1ae1e1648f749237ae967292e4ac4adf86752d9f /youtube_dl/swfinterp.py
parenta0f59cdcb405b0556bff9884a7a82f3b808263dd (diff)
downloadyoutube-dl-b7558d9881ae0dede7c13e1c082eaf89aefed27e.tar.gz
youtube-dl-b7558d9881ae0dede7c13e1c082eaf89aefed27e.zip
[swfinterp] Allow function patching
Diffstat (limited to 'youtube_dl/swfinterp.py')
-rw-r--r--youtube_dl/swfinterp.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/swfinterp.py b/youtube_dl/swfinterp.py
index b63c65b20..e5deb2c14 100644
--- a/youtube_dl/swfinterp.py
+++ b/youtube_dl/swfinterp.py
@@ -150,6 +150,7 @@ def _read_byte(reader):
class SWFInterpreter(object):
def __init__(self, file_contents):
+ self._patched_functions = {}
code_tag = next(tag
for tag_code, tag in _extract_tags(file_contents)
if tag_code == 82)
@@ -354,6 +355,9 @@ class SWFInterpreter(object):
assert p + code_reader.tell() == len(code_tag)
+ def patch_function(self, avm_class, func_name, f):
+ self._patched_functions[(avm_class, func_name)] = f
+
def extract_class(self, class_name):
try:
return self._classes_by_name[class_name]
@@ -361,6 +365,9 @@ class SWFInterpreter(object):
raise ExtractorError('Class %r not found' % class_name)
def extract_function(self, avm_class, func_name):
+ p = self._patched_functions.get((avm_class, func_name))
+ if p:
+ return p
if func_name in avm_class.method_pyfunctions:
return avm_class.method_pyfunctions[func_name]
if func_name in self._classes_by_name: