Skip to content
10 changes: 10 additions & 0 deletions user_agents/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys

PY3 = sys.version_info[0] == 3

if PY3:
def iteritems(d, **kw):
return iter(d.items(**kw))
else:
def iteritems(d, **kw):
return iter(d.iteritems(**kw))
254 changes: 254 additions & 0 deletions user_agents/devices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"android_firefox_aurora": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0",
"str": "Other / Android / Firefox Mobile 27"
},
"blackberry_bold": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "BlackBerry9700/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gba",
"str": "BlackBerry 9700 / BlackBerry OS 5 / BlackBerry 9700"
},
"blackberry_bold_touch": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (BlackBerry; U; BlackBerry 9930; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.241 Mobile Safari/534.11+",
"str": "BlackBerry 9930 / BlackBerry OS 7 / BlackBerry WebKit 7"
},
"blackberry_torch": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; zh-TW) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.448 Mobile Safari/534.8+",
"str": "BlackBerry 9800 / BlackBerry OS 6 / BlackBerry WebKit 6"
},
"galaxy_s3": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
"str": "GT-I9300 / Android 4.0.4 / Android 4.0.4"
},
"galaxy_tab": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
"str": "SCH-I800 / Android 2.2 / Android 2.2"
},
"google_bot": {
"is_bot": true,
"is_mobile": false,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
"str": "Spider / Other / Googlebot 2.1"
},
"ie": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)",
"str": "PC / Windows 8 / IE 10"
},
"ie_touch": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)",
"str": "PC / Windows 8 / IE 10"
},
"ipad": {
"is_bot": false,
"is_mobile": false,
"is_pc": false,
"is_tablet": true,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
"str": "iPad / iOS 3.2 / Mobile Safari 4.0.4"
},
"iphone": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3",
"str": "iPhone / iOS 5.1 / Mobile Safari 5.1"
},
"j2me_opera": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (J2ME/22.478; U; en) Presto/2.5.25 Version/10.54",
"str": "Other / Other / Opera Mini 9.80"
},
"kindle_fire": {
"is_bot": false,
"is_mobile": false,
"is_pc": false,
"is_tablet": true,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true",
"str": "Kindle Fire / Android / Amazon Silk 1.1.0-80"
},
"mac_safari": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"str": "PC / Mac OS X 10.6.8 / WebKit Nightly 537.13"
},
"nexus_5": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.117 Mobile Safari/537.36",
"str": "Nexus 5 / Android 4.4.4 / Chrome Mobile 37.0.2062"
},
"nexus_7": {
"is_bot": false,
"is_mobile": false,
"is_pc": false,
"is_tablet": true,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19",
"str": "Nexus 7 / Android 4.1.1 / Chrome 18.0.1025"
},
"nokia_n97": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344",
"str": "Nokia N97 / Symbian OS 9.4 / Nokia Browser 7.1.12344"
},
"playbook": {
"is_bot": false,
"is_mobile": false,
"is_pc": false,
"is_tablet": true,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.0.1; en-US) AppleWebKit/535.8+ (KHTML, like Gecko) Version/7.2.0.1 Safari/535.8+",
"str": "BlackBerry Playbook / BlackBerry Tablet OS 2.0.1 / BlackBerry WebKit 2.0.1"
},
"playstation": {
"is_bot": false,
"is_mobile": false,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (PLAYSTATION 3 4.60) AppleWebKit/531.22.8 (KHTML, like Gecko)",
"str": "PlayStation 3 / Other / NetFront NX"
},
"playstation_vita": {"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (PlayStation Vita 3.12) AppleWebKit/536.26 (KHTML, like Gecko) Silk/3.2",
"str": "PlayStation Vita / Other / NetFront NX"
},
"samsung_galaxy_s": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SCH-I545 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36",
"str": "SAMSUNG SCH-I545 / Android 4.4.2 / Chrome Mobile 28.0.1500"
},
"samsung_galaxy_s_iii_mini": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; Android 4.1.2; GT-I8190 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.117 Mobile Safari/537.36",
"str": "GT-I8190 / Android 4.1.2 / Chrome Mobile 37.0.2062"
},
"samsung_sm_galaxy_s5": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36",
"str": "SAMSUNG SM-G900F / Android 4.4.2 / Chrome Mobile 28.0.1500"
},
"samsung_wave_ii": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8530/S8530DDLC2; U; Bada/2.0; en-us) AppleWebKit/534.20 (KHTML, like Gecko) Dolfin/3.0 Mobile WVGA SMM-MMS/1.2.0 OPN-B",
"str": "Samsung GT-S8530 / Bada 2 / Dolfin 3"
},
"ubuntu_firefox": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1",
"str": "PC / Ubuntu / Firefox 15.0.1"
},
"windows_ie": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": false,
"is_touch_capable": false,
"ua_string": "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
"str": "PC / Windows 7 / IE 9"
},
"windows_phone": {
"is_bot": false,
"is_mobile": true,
"is_pc": false,
"is_tablet": false,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)",
"str": "Samsung SGH-i917 / Windows Phone 7.5 / IE Mobile 9"
},
"windows_rt": {
"is_bot": false,
"is_mobile": false,
"is_pc": true,
"is_tablet": true,
"is_touch_capable": true,
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
"str": "PC / Windows RT / IE 10"
}
}

16 changes: 10 additions & 6 deletions user_agents/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@
'iPod',
'Generic Smartphone',
'Generic Feature Phone',
'PlayStation Vita',
)

MOBILE_OS_FAMILIES = (
'Windows Phone',
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
'Symbian OS',
'Bada',
)

TABLET_DEVICE_FAMILIES = (
'iPad',
'BlackBerry Playbook',
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" instead of "BlackBerry"
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" instead of "BlackBerry"
'Kindle',
'Kindle Fire',
'Kindle Fire HD',
'Galaxy Tab',
'Xoom',
'Dell Streak',
)

TOUCH_CAPABLE_OS_FAMILIES = (
Expand Down Expand Up @@ -121,18 +127,16 @@ def _is_android_tablet(self):
if ('Mobile Safari' not in self.ua_string and
self.browser.family != "Firefox Mobile"):
return True
if 'SCH-' in self.ua_string:
return True
return False

def _is_blackberry_touch_capable_device(self):
# A helper to determine whether a BB phone has touch capabilities
# Blackberry Bold Touch series begins with 99XX
if 'Blackberry 99' in self.device.family:
return True
if 'Blackberry 95' in self.device.family: # BB Storm devices
if 'Blackberry 95' in self.device.family: # BB Storm devices
return True
if 'Blackberry 95' in self.device.family: # BB Torch devices
if 'Blackberry 95' in self.device.family: # BB Torch devices
return True
return False

Expand Down
Loading