Last active
June 25, 2020 16:47
-
-
Save VMuliadi/cbd910e92fd019925535e5886b51fc30 to your computer and use it in GitHub Desktop.
pip install --user requests beautifulsoup4; sudo python netflix_route.py (GATEWAY_IP)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import requests | |
| import socket | |
| import json | |
| from sys import argv, exit | |
| from bs4 import BeautifulSoup | |
| from subprocess import check_output | |
| print("Add these to your hosts file in /etc/hosts") | |
| for ip in json.loads(requests.get("https://dns.google.com/resolve?name=netflix.com&type=A").text)["Answer"]: | |
| print("{}\tnetflix.com www.netflix.com".format(ip["data"])) | |
| try: | |
| gateway = argv[1] | |
| # AS2906 Netflix Streaming Services Inc. | |
| bsoup = BeautifulSoup(requests.get("https://ipinfo.io/AS2906").text, "html.parser") | |
| for ip in bsoup.find("table", {"id": "block-table"}).findAll("tbody")[0].findAll("tr"): | |
| stream_address = ip.findAll("td")[0].text.rsplit()[0] | |
| print("Adding route to {} via {}".format(stream_address, gateway)) | |
| check_output("sudo ip route add {} via {}".format(stream_address, gateway), shell=True) | |
| # Uncomment these lines if you're in Indonesia. ISP as Netflix CDN | |
| # Read more about Open Connect (https://openconnect.netflix.com/en/) | |
| """# AS17451 BIZNET NETWORKS - Indonesian local provider for Netflix | |
| bsoup = BeautifulSoup(requests.get("https://ipinfo.io/AS17451").text, "html.parser") | |
| for ip in bsoup.find("table", {"id": "block-table"}).findAll("tbody")[0].findAll("tr"): | |
| stream_address = ip.findAll("td")[0].text.rsplit()[0] | |
| print("Adding route to {} via {}".format(stream_address, gateway)) | |
| check_output("sudo ip route add {} via {}".format(stream_address, gateway), shell=True)""" | |
| except IndexError: | |
| print("Please put the gateway in the argument") | |
| print("example: python route.py 192.168.100.1") | |
| exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment