1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 08:34:32 +01:00

[utils] Add urshift()

Used in IqiyiIE and LeIE
This commit is contained in:
Yen Chi Hsuan 2016-06-26 15:16:49 +08:00
parent 7d52c052ef
commit 1143535d76
No known key found for this signature in database
GPG Key ID: 3FDDD575826C5C30
2 changed files with 9 additions and 0 deletions

View File

@ -66,6 +66,7 @@ from youtube_dl.utils import (
lowercase_escape, lowercase_escape,
url_basename, url_basename,
urlencode_postdata, urlencode_postdata,
urshift,
update_url_query, update_url_query,
version_tuple, version_tuple,
xpath_with_ns, xpath_with_ns,
@ -980,5 +981,9 @@ The first line
self.assertRaises(ValueError, encode_base_n, 0, 70) self.assertRaises(ValueError, encode_base_n, 0, 70)
self.assertRaises(ValueError, encode_base_n, 0, 60, custom_table) self.assertRaises(ValueError, encode_base_n, 0, 60, custom_table)
def test_urshift(self):
self.assertEqual(urshift(3, 1), 1)
self.assertEqual(urshift(-3, 1), 2147483646)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -2899,3 +2899,7 @@ def parse_m3u8_attributes(attrib):
val = val[1:-1] val = val[1:-1]
info[key] = val info[key] = val
return info return info
def urshift(val, n):
return val >> n if val >= 0 else (val + 0x100000000) >> n