Try Live
Add Docs
Rankings
Pricing
Enterprise
Docs
Install
Install
Docs
Pricing
Enterprise
More...
More...
Try Live
Rankings
Add Docs
Region Restriction Check
https://github.com/lmc999/regionrestrictioncheck
Admin
A pure bash script designed to check streaming media region restrictions and unlock status across
...
Tokens:
5,052
Snippets:
48
Trust Score:
8.3
Update:
6 months ago
Context
Skills
Chat
Benchmark
74.4
Suggestions
Latest
Show doc for...
Code
Info
Show Results
Context Summary (auto-generated)
Raw
Copy
Link
# RegionRestrictionCheck ## Introduction RegionRestrictionCheck is a comprehensive bash-based streaming media and gaming service geo-restriction testing tool. It validates whether your current network location (IP address) can access various streaming platforms, gaming services, and web applications across different geographic regions. The script performs automated checks against 100+ services including Netflix, Disney+, Hulu, YouTube Premium, BBC iPlayer, Steam, and region-specific platforms across North America, Europe, Asia-Pacific, and other territories. The tool operates entirely in bash shell with minimal dependencies (curl, openssl, ca-certificates), making it portable across Unix-like systems including Linux, macOS, FreeBSD, Android (Termux), iOS (iSH), and Windows (Cygwin/MinGW). It supports both IPv4 and IPv6 testing, proxy configuration, network interface selection, and multiple language outputs. Results indicate service availability with region detection, helping users verify VPN/proxy effectiveness, troubleshoot geo-blocking issues, or assess network accessibility for streaming content. ## Usage ### Basic Usage - Test All Services ```bash # Run the script directly from GitHub bash <(curl -L -s check.unlock.media) # Expected Output: # ** Your Network Provider: Example ISP (192.168.*.*) # # ---Global Test--- # Netflix: Yes (Region: US) # Disney+: Yes (Region: US) # YouTube Premium: Yes # Amazon Prime Video: Yes (Region: US) # ... ``` ### IPv4-Only Testing ```bash # Test only IPv4 connectivity bash <(curl -L -s check.unlock.media) -M 4 # Expected Output: # ** Checking Results Under IPv4 # ** Your Network Provider: Cloudflare (1.1.*.*) # # Netflix: Yes (Region: SG) # Hulu: No ``` ### IPv6-Only Testing ```bash # Test only IPv6 connectivity bash <(curl -L -s check.unlock.media) -M 6 # Expected Output: # ** Checking Results Under IPv6 # ** Your Network Provider: Google Fiber (2001:4860:*:*) # # Netflix: Yes (Region: US) ``` ### Specify Network Interface ```bash # Test using specific network interface bash <(curl -L -s check.unlock.media) -I eth0 # This passes --interface eth0 to all curl commands # Useful for multi-NIC systems or specific routing requirements ``` ### Test Specific Region ```bash # Test North America region services only (Region ID: 0) bash <(curl -L -s check.unlock.media) -R 0 # Region IDs: # 0 = North America # 1 = Europe # 2 = Hong Kong # 3 = Taiwan # 4 = Japan # 5 = South Korea # 6 = Southeast Asia # 7 = South America # 8 = Oceania # 9 = Africa # 10 = India # 11 = Global # 66 = Sports Services # 88 = AI/Tech Services # 99 = Games # Expected Output: # ---North America Test--- # Netflix: Yes (Region: US) # Hulu: Yes # HBO Max: Yes # Disney+: Yes (Region: US) # ... ``` ### English Language Mode ```bash # Display output in English bash <(curl -L -s check.unlock.media) -E en # Default is Chinese (zh) ``` ### Proxy Testing ```bash # Test through SOCKS5 proxy bash <(curl -L -s check.unlock.media) -P socks5://127.0.0.1:1080 # Test through HTTP proxy bash <(curl -L -s check.unlock.media) -P http://proxy.example.com:8080 # Test through authenticated proxy bash <(curl -L -s check.unlock.media) -P socks5://user:pass@127.0.0.1:1080 # Expected Output: # ** Checking Results Under Proxy # ** Your Network Provider: Proxy ISP (10.20.*.*) # # Netflix: Yes (Region: JP) ``` ### Docker Usage ```bash # Run via Docker (supports ARM and x86_64) docker run --rm -ti --net=host lmc999/regioncheck && docker rmi lmc999/regioncheck > /dev/null 2>&1 # Docker container uses Alpine Linux base with all required dependencies # --net=host ensures container uses host network stack for accurate testing # Container auto-removes after execution ``` ## Key Functions ### Netflix Region Detection ```bash # Function: MediaUnlockTest_Netflix # Tests Netflix availability and region using two test titles # - LEGO Ninjago (81280792): Available in most regions # - Breaking Bad (70143836): Regional restrictions vary function MediaUnlockTest_Netflix() { local tmpresult1=$(curl ${CURL_DEFAULT_OPTS} -fsL 'https://www.netflix.com/title/81280792' \ -b 'nfvdid=BQFmAAEBEMZa4XMY...' \ --user-agent "${UA_BROWSER}") local tmpresult2=$(curl ${CURL_DEFAULT_OPTS} -fsL 'https://www.netflix.com/title/70143836' \ -b 'nfvdid=BQFmAAEBEMZa4XMY...' \ --user-agent "${UA_BROWSER}") local result1=$(echo ${tmpresult1} | grep 'Oh no!') local result2=$(echo ${tmpresult2} | grep 'Oh no!') if [ -n "${result1}" ] && [ -n "${result2}" ]; then echo "Netflix: Originals Only" # Can only watch Netflix Originals elif [ -z "${result1}" ] || [ -z "${result2}" ]; then local region=$(echo "$tmpresult1" | grep -o 'data-country="[A-Z]*"' | sed 's/.*="\([A-Z]*\)"/\1/') echo "Netflix: Yes (Region: ${region})" # Full catalog access fi } # Usage Output Examples: # Netflix: Yes (Region: US) # Netflix: Originals Only # Netflix: No # Netflix: Failed (Network Connection) ``` ### Disney+ Authentication and Region Check ```bash # Function: MediaUnlockTest_DisneyPlus # Multi-step authentication process: # 1. Register device and obtain assertion token # 2. Exchange assertion for refresh token # 3. Query user location and service availability function MediaUnlockTest_DisneyPlus() { # Step 1: Device registration local tempresult=$(curl ${CURL_DEFAULT_OPTS} -s 'https://disney.api.edge.bamgrid.com/devices' \ -X POST \ -H "authorization: Bearer ZGlzbmV5JmJyb3dzZXImMS4wLjA..." \ -d '{"deviceFamily":"browser","applicationRuntime":"chrome","deviceProfile":"windows"}') local assertion=$(echo "$tempresult" | grep -woP '"assertion"\s{0,}:\s{0,}"\K[^"]+') # Step 2: Token exchange local disneyCookie="grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&subject_token=${assertion}..." local tokenContent=$(curl ${CURL_DEFAULT_OPTS} -s 'https://disney.api.edge.bamgrid.com/token' \ -X POST \ -H "authorization: Bearer ZGlzbmV5JmJyb3dzZXImMS4wLjA..." \ -d "${disneyCookie}") local refreshToken=$(echo "$tokenContent" | grep -woP '"refresh_token"\s{0,}:\s{0,}"\K[^"]+') # Step 3: Region query local tmpresult=$(curl ${CURL_DEFAULT_OPTS} -sL 'https://disney.api.edge.bamgrid.com/graph/v1/device/graphql' \ -X POST \ -d "{\"query\":\"mutation{refreshToken(refreshToken:\\\"${refreshToken}\\\"){activeSession{location{countryCode}}}}\"}") local region=$(echo "$tmpresult" | grep -woP '"countryCode"\s{0,}:\s{0,}"\K[^"]+') echo "Disney+: Yes (Region: ${region})" } # Usage Output Examples: # Disney+: Yes (Region: JP) # Disney+: No (IP Banned By Disney+) # Disney+: Available For [Disney+ SG] Soon ``` ### Steam Currency Region Detection ```bash # Function: GameTest_Steam # Determines Steam store region by checking currency code # Uses Sekiro: Shadows Die Twice (App ID: 814380) as test title function GameTest_Steam() { local tmpresult=$(curl ${CURL_DEFAULT_OPTS} -sL 'https://store.steampowered.com/app/761830' \ --user-agent "${UA_BROWSER}") local result=$(echo "$tmpresult" | grep 'priceCurrency' | cut -d '"' -f4) echo "Steam Currency: ${result}" # USD, JPY, EUR, CNY, etc. } # Usage Output Examples: # Steam Currency: USD # Steam Currency: JPY # Steam Currency: EUR # Steam Currency: CNY ``` ### BiliBili China Mainland Content Access ```bash # Function: MediaUnlockTest_BilibiliChinaMainland # Tests access to mainland China exclusive content # Uses specific anime episode restricted to mainland China function MediaUnlockTest_BilibiliChinaMainland() { local randsession=$(gen_uuid | md5sum | head -c 32) local tmpresult=$(curl ${CURL_DEFAULT_OPTS} -fsL \ "https://api.bilibili.com/pgc/player/web/playurl?avid=82846771&ep_id=307247&session=${randsession}" \ --user-agent "${UA_BROWSER}") local result=$(echo "$tmpresult" | grep -woP '"code"\s{0,}:\s{0,}\K[-\d]+') case "$result" in '0') echo "BiliBili China Mainland Only: Yes" ;; '-10403') echo "BiliBili China Mainland Only: No" ;; *) echo "BiliBili China Mainland Only: Failed (Error: ${result})" ;; esac } # Usage Output Examples: # BiliBili China Mainland Only: Yes # BiliBili China Mainland Only: No ``` ### YouTube Premium Detection ```bash # Function: MediaUnlockTest_YouTube_Premium # Checks YouTube Premium availability via playback info API # Tests age-restricted content access without authentication function MediaUnlockTest_YouTube_Premium() { local tmpresult=$(curl ${CURL_DEFAULT_OPTS} -sL \ 'https://www.youtube.com/premium' \ --user-agent "${UA_BROWSER}") local isCN=$(echo "$tmpresult" | grep 'www.google.cn') local isNotAvailable=$(echo "$tmpresult" | grep 'Premium is not available in your country') if [ -n "$isCN" ]; then echo "YouTube Premium: No (China)" elif [ -n "$isNotAvailable" ]; then echo "YouTube Premium: No" else echo "YouTube Premium: Yes" fi } # Usage Output Examples: # YouTube Premium: Yes # YouTube Premium: No # YouTube Premium: No (China) ``` ### OpenAI API Access Check ```bash # Function: WebTest_OpenAI # Tests OpenAI API and ChatGPT web access from current location # Checks both API endpoint and web interface availability function WebTest_OpenAI() { local tmpresult=$(curl ${CURL_DEFAULT_OPTS} -fsL \ 'https://api.openai.com/v1/models' \ -w '%{http_code}' -o /dev/null \ -H 'Authorization: Bearer invalid_token_test' \ --user-agent "${UA_BROWSER}") # 401 = API accessible (invalid auth expected) # 403 = Geo-blocked # 000 = Network error case "$tmpresult" in '401') echo "OpenAI API: Yes" ;; '403') echo "OpenAI API: No (Region Restricted)" ;; '000') echo "OpenAI API: Failed (Network Connection)" ;; *) echo "OpenAI API: Unknown (${tmpresult})" ;; esac } # Usage Output Examples: # OpenAI API: Yes # OpenAI API: No (Region Restricted) ``` ### Proxy Validation and Connectivity Check ```bash # Function: validate_proxy # Validates proxy URL format and connectivity # Supports SOCKS4/5, HTTP/HTTPS proxies with optional authentication validate_proxy() { local proxy="$1" # Validate format: protocol://[user:pass@]host:port local tmpresult=$(echo "$proxy" | grep -P '^(socks|socks4|socks5|http)://([^:]+:[^@]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|(\[[0-9a-fA-F:]+\])):(0|[1-9][0-9]{0,4})$') if [ -z "$tmpresult" ]; then echo "Proxy IP invalid." exit 1 fi local port=$(echo "$proxy" | grep -woP ':\K[0-9]+$') if [ "$port" -ge 65535 ]; then echo "Proxy Port invalid." exit 1 fi } # Test proxy connectivity check_proxy_connectivity() { local result1=$(curl $USE_PROXY -s 'https://ip.sb' --user-agent "${UA_BROWSER}") local result2=$(curl $USE_PROXY -s 'https://1.0.0.1/cdn-cgi/trace' --user-agent "${UA_BROWSER}") if [ -n "$result1" ] && [ -n "$result2" ]; then return 0 # Proxy working fi return 1 # Proxy failed } # Usage Examples: # Valid: socks5://127.0.0.1:1080 # Valid: http://user:pass@proxy.example.com:8080 # Valid: socks5://[2001:db8::1]:1080 # Invalid: socks5://invalid_host:port ``` ### IP Address Detection and Masking ```bash # Function: get_ip_info # Retrieves public IP address and ISP information # Masks IP for privacy display (shows first 2 IPv4 octets or 3 IPv6 groups) get_ip_info() { local local_ip=$(curl ${CURL_DEFAULT_OPTS} -s https://api64.ipify.org \ --user-agent "${UA_BROWSER}") local get_local_isp=$(curl ${CURL_DEFAULT_OPTS} -s \ "https://api.ip.sb/geoip/${local_ip}" \ --user-agent "${UA_BROWSER}") validate_ip_address "$local_ip" local resp="$?" if [ "$resp" == 4 ]; then # IPv4: 192.168.1.1 -> 192.168.*.* LOCAL_IP_ASTERISK=$(awk -F"." '{print $1"."$2".*.*"}' <<<"${local_ip}") fi if [ "$resp" == 6 ]; then # IPv6: 2001:db8:85a3::1 -> 2001:db8:85a3:*:* LOCAL_IP_ASTERISK=$(awk -F":" '{print $1":"$2":"$3":*:*"}' <<<"${local_ip}") fi LOCAL_ISP=$(echo "$get_local_isp" | sed -n 's/.*"organization":"\([^"]*\)".*/\1/p') } # Usage Output Examples: # ** Your Network Provider: Cloudflare (1.1.*.*) # ** Your Network Provider: Google Fiber (2001:4860:4860:*:*) # ** 您的网络为: China Telecom (202.101.*.*) ``` ### DNS Resolution with Fallback Methods ```bash # Function: resolve_ip_address # Resolves domain to IP using nslookup, dig, or ping as fallback # Supports both A (IPv4) and AAAA (IPv6) record queries resolve_ip_address() { local domain="$1" local recordType="$2" # A or AAAA # Method 1: nslookup (preferred on most Unix systems) if command_exists nslookup && [ "$OS_WINDOWS" != 1 ]; then if [ "$recordType" == 'AAAA' ]; then local result=$(nslookup -q=AAAA "${domain}" | grep -woP "Address: \K[\d:a-f]+") else local result=$(nslookup -q=A "${domain}" | grep -woP "Address: \K[\d.]+") fi echo "${result}" return fi # Method 2: dig (better parsing) if command_exists dig; then local result=$(dig +short "${domain}" ${recordType}) echo "${result}" return fi # Method 3: ping fallback (when DNS tools unavailable) if [ "$recordType" == 'AAAA' ]; then local result=$(ping6 -6 -c 1 -w 1 "${domain}" 2>/dev/null | head -n 1 | grep -woP '\s\(\K[\d:a-f]+') else local result=$(ping -4 -c 1 -w 1 "${domain}" 2>/dev/null | head -n 1 | grep -woP '\s\(\K[\d.]+') fi echo "${result}" } # Usage Examples: # resolve_ip_address "netflix.com" "A" # Output: 54.86.40.117 # # resolve_ip_address "netflix.com" "AAAA" # Output: 2600:1f18:2419:5500:f0f5:6945:68f7:34cf ``` ### Network Connectivity Detection ```bash # Function: check_net_connctivity # Tests IPv4 or IPv6 connectivity to internet # Returns 0 if connected, 1 if no connectivity check_net_connctivity() { local ipVersion="$1" # 4 or 6 if [ "$ipVersion" == 4 ]; then local result=$(curl -4 ${CURL_OPTS} -fs 'https://www.google.com' \ -o /dev/null -s -w '%{http_code}\n') if [ "$result" != '000' ]; then return 0 # IPv4 working fi fi if [ "$ipVersion" == 6 ]; then local result=$(curl -6 ${CURL_OPTS} -fs 'https://www.google.com' \ -o /dev/null -s -w '%{http_code}\n') if [ "$result" != '000' ]; then return 0 # IPv6 working fi fi return 1 # No connectivity } # Usage in script: if check_net_connctivity 4; then echo "IPv4: Available" # Run IPv4 tests fi if check_net_connctivity 6; then echo "IPv6: Available" # Run IPv6 tests fi ``` ## Integration and Use Cases RegionRestrictionCheck serves multiple practical scenarios in network diagnostics and geo-restriction testing. VPN and proxy service providers integrate the script into their validation pipelines to verify that their exit nodes correctly unlock streaming services in target regions, running automated tests after server deployments to ensure Netflix US, BBC iPlayer UK, and other region-specific content remains accessible. System administrators use the tool to troubleshoot user reports of blocked streaming services, quickly identifying whether issues stem from ISP-level blocking, misconfigured DNS, or actual geo-restrictions. Content creators and digital nomads rely on RegionRestrictionCheck before subscribing to streaming services, validating that their current location or VPN setup can access desired content libraries. The script's comprehensive coverage of 100+ platforms across 11 geographic regions eliminates trial-and-error subscription purchases. DevOps teams incorporate the tool into CI/CD pipelines for network-dependent applications, running automated smoke tests that verify outbound connectivity to essential services isn't blocked by corporate firewalls or cloud provider egress policies. The Docker container format enables easy integration into Kubernetes clusters for periodic availability monitoring, with exit codes indicating test pass/fail status for alerting systems.