diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2017-03-26 21:51:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-26 21:51:09 +0800 |
commit | cc63259d18fcb2940402d35139c40077481e5a22 (patch) | |
tree | 773585377b689a156a5e95292f08cd68712c3d7e /youtube_dl/extractor/common.py | |
parent | 2bfaf89b6cc6dd07ed6ca32086c72a98b67c20ba (diff) | |
parent | 4f06c1c9fcbfbc74b81b5fa89a616914b5ce5aad (diff) |
Merge pull request #12307 from rndusr/fix/str-item-assignment
Fix "'str' object does not support item assignment"
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r-- | youtube_dl/extractor/common.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 0852b8e8c..6c3c095f7 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -2169,18 +2169,24 @@ class InfoExtractor(object): }) return formats - @staticmethod - def _find_jwplayer_data(webpage): + def _find_jwplayer_data(self, webpage, video_id=None, transform_source=js_to_json): mobj = re.search( r'jwplayer\((?P<quote>[\'"])[^\'" ]+(?P=quote)\)\.setup\s*\((?P<options>[^)]+)\)', webpage) if mobj: - return mobj.group('options') + try: + jwplayer_data = self._parse_json(mobj.group('options'), + video_id=video_id, + transform_source=transform_source) + except ExtractorError: + pass + else: + if isinstance(jwplayer_data, dict): + return jwplayer_data def _extract_jwplayer_data(self, webpage, video_id, *args, **kwargs): - jwplayer_data = self._parse_json( - self._find_jwplayer_data(webpage), video_id, - transform_source=js_to_json) + jwplayer_data = self._find_jwplayer_data( + webpage, video_id, transform_source=js_to_json) return self._parse_jwplayer_data( jwplayer_data, video_id, *args, **kwargs) |