aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/swfinterp.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-11-17 04:25:04 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-11-17 04:25:10 +0100
commit3cbcff8a2dacf6d4f10f00af36b9761ef833e6ea (patch)
tree0bbf17a25e321d1d0502d94ae31995a8a7456a31 /youtube_dl/swfinterp.py
parente983cf52775e493b7deedbe48d2f50f598c9da4e (diff)
downloadyoutube-dl-3cbcff8a2dacf6d4f10f00af36b9761ef833e6ea.tar.xz
[swfinterp] Implement String basics
Diffstat (limited to 'youtube_dl/swfinterp.py')
-rw-r--r--youtube_dl/swfinterp.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/youtube_dl/swfinterp.py b/youtube_dl/swfinterp.py
index 85efde592..0ce8474ca 100644
--- a/youtube_dl/swfinterp.py
+++ b/youtube_dl/swfinterp.py
@@ -148,6 +148,9 @@ def _read_byte(reader):
return res
+StringClass = _AVMClass('(no name idx)', 'String')
+
+
class SWFInterpreter(object):
def __init__(self, file_contents):
self._patched_functions = {}
@@ -483,6 +486,17 @@ class SWFInterpreter(object):
res = args[0].join(obj)
stack.append(res)
continue
+ elif obj == StringClass:
+ if mname == 'String':
+ assert len(args) == 1
+ assert isinstance(args[0], (int, compat_str))
+ res = compat_str(args[0])
+ stack.append(res)
+ continue
+ else:
+ raise NotImplementedError(
+ 'Function String.%s is not yet implemented'
+ % mname)
raise NotImplementedError(
'Unsupported property %r on %r'
% (mname, obj))
@@ -532,7 +546,10 @@ class SWFInterpreter(object):
break
else:
res = scopes[0]
- stack.append(res[mname])
+ if mname not in res and mname == 'String':
+ stack.append(StringClass)
+ else:
+ stack.append(res[mname])
elif opcode == 94: # findproperty
index = u30()
mname = self.multinames[index]
@@ -576,7 +593,7 @@ class SWFInterpreter(object):
pname = self.multinames[index]
if pname == 'length':
obj = stack.pop()
- assert isinstance(obj, list)
+ assert isinstance(obj, (compat_str, list))
stack.append(len(obj))
elif isinstance(pname, compat_str): # Member access
obj = stack.pop()