1 802 B

123456789101112131415161718
  1. #youtube_dl/extractor/youtube.py: The js/swf sig parsers
  2. #ln=\z
  3. def _parse_sig_js(self, jscode):
  4. funcname = self._search_regex(
  5. (r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
  6. r'\.sig\|\|(?P<sig>[a-zA-Z0-9$]+)\('),
  7. jscode, 'Initial JS player signature function name', group='sig')
  8. jsi = JSInterpreter(jscode)
  9. initial_function = jsi.extract_function(funcname)
  10. return lambda s: initial_function([s])
  11. def _parse_sig_swf(self, file_contents):
  12. swfi = SWFInterpreter(file_contents)
  13. TARGET_CLASSNAME = 'SignatureDecipher'
  14. searched_class = swfi.extract_class(TARGET_CLASSNAME)
  15. initial_function = swfi.extract_function(searched_class, 'decipher')
  16. return lambda s: initial_function([s])