diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-02-27 00:57:35 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2016-02-27 00:58:03 +0800 |
commit | 2ebd2eac880e21e0fe9751e6cef28ac009f69d79 (patch) | |
tree | e47b69afab60639fd47d1ab1b39559d3be7fc3c2 /youtube_dl | |
parent | b78b292f0c51323edaf3e18ae4f45927a55e9198 (diff) |
[letv] Speedup M3U8 decryption
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/letv.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/youtube_dl/extractor/letv.py b/youtube_dl/extractor/letv.py index 9665ece89..9fd494c29 100644 --- a/youtube_dl/extractor/letv.py +++ b/youtube_dl/extractor/letv.py @@ -94,17 +94,16 @@ class LetvIE(InfoExtractor): return encrypted_data encrypted_data = encrypted_data[5:] - _loc4_ = bytearray() - while encrypted_data: - b = compat_ord(encrypted_data[0]) - _loc4_.extend([b // 16, b & 0x0f]) - encrypted_data = encrypted_data[1:] + _loc4_ = bytearray(2 * len(encrypted_data)) + for idx, val in enumerate(encrypted_data): + b = compat_ord(val) + _loc4_[2 * idx] = b // 16 + _loc4_[2 * idx + 1] = b % 16 idx = len(_loc4_) - 11 _loc4_ = _loc4_[idx:] + _loc4_[:idx] - _loc7_ = bytearray() - while _loc4_: - _loc7_.append(_loc4_[0] * 16 + _loc4_[1]) - _loc4_ = _loc4_[2:] + _loc7_ = bytearray(len(encrypted_data)) + for i in range(len(encrypted_data)): + _loc7_[i] = _loc4_[2 * i] * 16 + _loc4_[2 * i + 1] return bytes(_loc7_) |