Improve geo bypass mechanism
[youtube-dl] / youtube_dl / utils.py
index 4e76b6b7be709e4d6274f65a8ef8175b436cddc2..17b83794a2becf272005305442094223cd054638 100644 (file)
@@ -3290,8 +3290,8 @@ class GeoUtils(object):
         addr, preflen = block.split('/')
         addr_min = compat_struct_unpack('!L', socket.inet_aton(addr))[0]
         addr_max = addr_min | (0xffffffff >> int(preflen))
-        return socket.inet_ntoa(
-            compat_struct_pack('!I', random.randint(addr_min, addr_max)))
+        return compat_str(socket.inet_ntoa(
+            compat_struct_pack('!L', random.randint(addr_min, addr_max))))
 
 
 class PerRequestProxyHandler(compat_urllib_request.ProxyHandler):