Skip to content

Instantly share code, notes, and snippets.

@milanpanchal
Created June 4, 2020 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milanpanchal/4603204987bb58548c2bc57b9f03fc3e to your computer and use it in GitHub Desktop.
Save milanpanchal/4603204987bb58548c2bc57b9f03fc3e to your computer and use it in GitHub Desktop.
Check which countries an app is available in on AppStore
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
import json
import sys
countrydict = {
'AE': 'United Arab Emirates',
'AG': 'Antigua and Barbuda',
'AI': 'Anguilla',
'AL': 'Albania',
'AM': 'Armenia',
'AO': 'Angola',
'AR': 'Argentina',
'AT': 'Austria',
'AU': 'Australia',
'AZ': 'Azerbaijan',
'BB': 'Barbados',
'BE': 'Belgium',
'BF': 'Burkina Faso',
'BG': 'Bulgaria',
'BH': 'Bahrain',
'BJ': 'Benin',
'BM': 'Bermuda',
'BN': 'Brunei',
'BO': 'Bolivia',
'BR': 'Brazil',
'BS': 'Bahamas',
'BT': 'Bhutan',
'BW': 'Botswana',
'BY': 'Belarus',
'BZ': 'Belize',
'CA': 'Canada',
'CG': 'Republic Of Congo',
'CH': 'Switzerland',
'CL': 'Chile',
'CN': 'China',
'CO': 'Colombia',
'CR': 'Costa Rica',
'CV': 'Cape Verde',
'CY': 'Cyprus',
'CZ': 'Czech Republic',
'DE': 'Germany',
'DK': 'Denmark',
'DM': 'Dominica',
'DO': 'Dominican Republic',
'DZ': 'Algeria',
'EC': 'Ecuador',
'EE': 'Estonia',
'EG': 'Egypt',
'ES': 'Spain',
'FI': 'Finland',
'FJ': 'Fiji',
'FM': 'Federated States Of Micronesia',
'FR': 'France',
'GB': 'United Kingdom',
'GD': 'Grenada',
'GH': 'Ghana',
'GM': 'Gambia',
'GR': 'Greece',
'GT': 'Guatemala',
'GW': 'Guinea-Bissau',
'GY': 'Guyana',
'HK': 'Hong Kong',
'HN': 'Honduras',
'HR': 'Croatia',
'HU': 'Hungary',
'ID': 'Indonesia',
'IE': 'Ireland',
'IL': 'Israel',
'IN': 'India',
'IS': 'Iceland',
'IT': 'Italy',
'JM': 'Jamaica',
'JO': 'Jordan',
'JP': 'Japan',
'KE': 'Kenya',
'KG': 'Kyrgyzstan',
'KH': 'Cambodia',
'KN': 'St. Kitts and Nevis',
'KR': 'Republic Of Korea',
'KW': 'Kuwait',
'KY': 'Cayman Islands',
'KZ': 'Kazakstan',
'LA': 'Lao People’s Democratic Republic',
'LB': 'Lebanon',
'LC': 'St. Lucia',
'LK': 'Sri Lanka',
'LR': 'Liberia',
'LT': 'Lithuania',
'LU': 'Luxembourg',
'LV': 'Latvia',
'MD': 'Republic Of Moldova',
'MG': 'Madagascar',
'MK': 'Macedonia',
'ML': 'Mali',
'MN': 'Mongolia',
'MO': 'Macau',
'MR': 'Mauritania',
'MS': 'Montserrat',
'MT': 'Malta',
'MU': 'Mauritius',
'MW': 'Malawi',
'MX': 'Mexico',
'MY': 'Malaysia',
'MZ': 'Mozambique',
'NA': 'Namibia',
'NE': 'Niger',
'NG': 'Nigeria',
'NI': 'Nicaragua',
'NL': 'Netherlands',
'NO': 'Norway',
'NP': 'Nepal',
'NZ': 'New Zealand',
'OM': 'Oman',
'PA': 'Panama',
'PE': 'Peru',
'PG': 'Papua New Guinea',
'PH': 'Philippines',
'PK': 'Pakistan',
'PL': 'Poland',
'PT': 'Portugal',
'PW': 'Palau',
'PY': 'Paraguay',
'QA': 'Qatar',
'RO': 'Romania',
'RU': 'Russia',
'SA': 'Saudi Arabia',
'SB': 'Solomon Islands',
'SC': 'Seychelles',
'SE': 'Sweden',
'SG': 'Singapore',
'SI': 'Slovenia',
'SK': 'Slovakia',
'SL': 'Sierra Leone',
'SN': 'Senegal',
'SR': 'Suriname',
'ST': 'Sao Tome and Principe',
'SV': 'El Salvador',
'SZ': 'Swaziland',
'TC': 'Turks and Caicos',
'TD': 'Chad',
'TH': 'Thailand',
'TJ': 'Tajikistan',
'TM': 'Turkmenistan',
'TN': 'Tunisia',
'TR': 'Turkey',
'TT': 'Trinidad and Tobago',
'TW': 'Taiwan',
'TZ': 'Tanzania',
'UA': 'Ukraine',
'UG': 'Uganda',
'US': 'United States',
'UY': 'Uruguay',
'UZ': 'Uzbekistan',
'VC': 'St. Vincent and The Grenadines',
'VE': 'Venezuela',
'VG': 'British Virgin Islands',
'VN': 'Vietnam',
'YE': 'Yemen',
'ZA': 'South Africa',
'ZW': 'Zimbabwe'
}
def fetch(appids):
availablelist = []
for key in countrydict:
url = "https://itunes.apple.com/{0}/lookup?id={1}".format(key.lower(), appids)
response = urllib2.urlopen(url);
try:
data = json.load(response)
except ValueError, e:
continue
if data.get('resultCount', 0) > 0:
availablelist.append(countrydict[key])
if len(availablelist) > 0:
print "Available in " + ", ".join(availablelist)
else:
print "not availabel"
if __name__ == '__main__':
appids = sys.argv[1:]
if len(appids) == 0:
print "Please enter atleast one app id"
else:
appids = ",".join(appids)
fetch(appids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment