diff options
author | Sergey M. <dstftw@gmail.com> | 2015-03-30 01:28:30 +0600 |
---|---|---|
committer | Sergey M. <dstftw@gmail.com> | 2015-03-30 01:28:30 +0600 |
commit | 72b249bf1fa73b5e72d6573f3587a775a6c1c820 (patch) | |
tree | bb5342f8cf6c46f4ce6dee16566dc150004e40e4 /youtube_dl/extractor/xuite.py | |
parent | ad320e9b8376221a3eda935a358886b6e7ab7bf6 (diff) | |
parent | 9b4774b21bb26eea9eb8042b2ff248a176595c5a (diff) |
Merge pull request #5313 from yan12125/fix_xuite_python32
[Xuite] Fix extraction on python 3.2
Diffstat (limited to 'youtube_dl/extractor/xuite.py')
-rw-r--r-- | youtube_dl/extractor/xuite.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/youtube_dl/extractor/xuite.py b/youtube_dl/extractor/xuite.py index 4971965f9..81d885fdc 100644 --- a/youtube_dl/extractor/xuite.py +++ b/youtube_dl/extractor/xuite.py @@ -69,18 +69,26 @@ class XuiteIE(InfoExtractor): 'only_matching': True, }] + @staticmethod + def base64_decode_utf8(data): + return base64.b64decode(data.encode('utf-8')).decode('utf-8') + + @staticmethod + def base64_encode_utf8(data): + return base64.b64encode(data.encode('utf-8')).decode('utf-8') + def _extract_flv_config(self, media_id): - base64_media_id = base64.b64encode(media_id.encode('utf-8')).decode('utf-8') + base64_media_id = self.base64_encode_utf8(media_id) flv_config = self._download_xml( 'http://vlog.xuite.net/flash/player?media=%s' % base64_media_id, 'flv config') prop_dict = {} for prop in flv_config.findall('./property'): - prop_id = base64.b64decode(prop.attrib['id']).decode('utf-8') + prop_id = self.base64_decode_utf8(prop.attrib['id']) # CDATA may be empty in flv config if not prop.text: continue - encoded_content = base64.b64decode(prop.text).decode('utf-8') + encoded_content = self.base64_decode_utf8(prop.text) prop_dict[prop_id] = compat_urllib_parse_unquote(encoded_content) return prop_dict |