Skip to content

Commit 503dcae

Browse files
committed
Merge pull request selwin#14 from dpetzold/master
Fix: The SCH- check was erroneously setting Galaxy S phones to tablets.
2 parents 3dede6f + 8c8e638 commit 503dcae

4 files changed

Lines changed: 304 additions & 185 deletions

File tree

‎user_agents/compat.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
3+
PY3 = sys.version_info[0] == 3
4+
5+
if PY3:
6+
def iteritems(d, **kw):
7+
return iter(d.items(**kw))
8+
else:
9+
def iteritems(d, **kw):
10+
return iter(d.iteritems(**kw))

‎user_agents/devices.json‎

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
{
2+
"android_firefox_aurora": {
3+
"is_bot": false,
4+
"is_mobile": true,
5+
"is_pc": false,
6+
"is_tablet": false,
7+
"is_touch_capable": true,
8+
"ua_string": "Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0",
9+
"str": "Other / Android / Firefox Mobile 27"
10+
},
11+
"blackberry_bold": {
12+
"is_bot": false,
13+
"is_mobile": true,
14+
"is_pc": false,
15+
"is_tablet": false,
16+
"is_touch_capable": false,
17+
"ua_string": "BlackBerry9700/5.0.0.862 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/331 UNTRUSTED/1.0 3gpp-gba",
18+
"str": "BlackBerry 9700 / BlackBerry OS 5 / BlackBerry 9700"
19+
},
20+
"blackberry_bold_touch": {
21+
"is_bot": false,
22+
"is_mobile": true,
23+
"is_pc": false,
24+
"is_tablet": false,
25+
"is_touch_capable": false,
26+
"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+",
27+
"str": "BlackBerry 9930 / BlackBerry OS 7 / BlackBerry WebKit 7"
28+
},
29+
"blackberry_torch": {
30+
"is_bot": false,
31+
"is_mobile": true,
32+
"is_pc": false,
33+
"is_tablet": false,
34+
"is_touch_capable": false,
35+
"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+",
36+
"str": "BlackBerry 9800 / BlackBerry OS 6 / BlackBerry WebKit 6"
37+
},
38+
"galaxy_s3": {
39+
"is_bot": false,
40+
"is_mobile": true,
41+
"is_pc": false,
42+
"is_tablet": false,
43+
"is_touch_capable": true,
44+
"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",
45+
"str": "GT-I9300 / Android 4.0.4 / Android 4.0.4"
46+
},
47+
"galaxy_tab": {
48+
"is_bot": false,
49+
"is_mobile": true,
50+
"is_pc": false,
51+
"is_tablet": false,
52+
"is_touch_capable": true,
53+
"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",
54+
"str": "SCH-I800 / Android 2.2 / Android 2.2"
55+
},
56+
"google_bot": {
57+
"is_bot": true,
58+
"is_mobile": false,
59+
"is_pc": false,
60+
"is_tablet": false,
61+
"is_touch_capable": false,
62+
"ua_string": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
63+
"str": "Spider / Other / Googlebot 2.1"
64+
},
65+
"ie": {
66+
"is_bot": false,
67+
"is_mobile": false,
68+
"is_pc": true,
69+
"is_tablet": false,
70+
"is_touch_capable": false,
71+
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)",
72+
"str": "PC / Windows 8 / IE 10"
73+
},
74+
"ie_touch": {
75+
"is_bot": false,
76+
"is_mobile": false,
77+
"is_pc": true,
78+
"is_tablet": false,
79+
"is_touch_capable": true,
80+
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)",
81+
"str": "PC / Windows 8 / IE 10"
82+
},
83+
"ipad": {
84+
"is_bot": false,
85+
"is_mobile": false,
86+
"is_pc": false,
87+
"is_tablet": true,
88+
"is_touch_capable": true,
89+
"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",
90+
"str": "iPad / iOS 3.2 / Mobile Safari 4.0.4"
91+
},
92+
"iphone": {
93+
"is_bot": false,
94+
"is_mobile": true,
95+
"is_pc": false,
96+
"is_tablet": false,
97+
"is_touch_capable": true,
98+
"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",
99+
"str": "iPhone / iOS 5.1 / Mobile Safari 5.1"
100+
},
101+
"j2me_opera": {
102+
"is_bot": false,
103+
"is_mobile": true,
104+
"is_pc": false,
105+
"is_tablet": false,
106+
"is_touch_capable": false,
107+
"ua_string": "Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (J2ME/22.478; U; en) Presto/2.5.25 Version/10.54",
108+
"str": "Other / Other / Opera Mini 9.80"
109+
},
110+
"kindle_fire": {
111+
"is_bot": false,
112+
"is_mobile": false,
113+
"is_pc": false,
114+
"is_tablet": true,
115+
"is_touch_capable": true,
116+
"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",
117+
"str": "Kindle Fire / Android / Amazon Silk 1.1.0-80"
118+
},
119+
"mac_safari": {
120+
"is_bot": false,
121+
"is_mobile": false,
122+
"is_pc": true,
123+
"is_tablet": false,
124+
"is_touch_capable": false,
125+
"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",
126+
"str": "PC / Mac OS X 10.6.8 / WebKit Nightly 537.13"
127+
},
128+
"nexus_5": {
129+
"is_bot": false,
130+
"is_mobile": true,
131+
"is_pc": false,
132+
"is_tablet": false,
133+
"is_touch_capable": true,
134+
"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",
135+
"str": "Nexus 5 / Android 4.4.4 / Chrome Mobile 37.0.2062"
136+
},
137+
"nexus_7": {
138+
"is_bot": false,
139+
"is_mobile": false,
140+
"is_pc": false,
141+
"is_tablet": true,
142+
"is_touch_capable": true,
143+
"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",
144+
"str": "Nexus 7 / Android 4.1.1 / Chrome 18.0.1025"
145+
},
146+
"nokia_n97": {
147+
"is_bot": false,
148+
"is_mobile": true,
149+
"is_pc": false,
150+
"is_tablet": false,
151+
"is_touch_capable": false,
152+
"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",
153+
"str": "Nokia N97 / Symbian OS 9.4 / Nokia Browser 7.1.12344"
154+
},
155+
"playbook": {
156+
"is_bot": false,
157+
"is_mobile": false,
158+
"is_pc": false,
159+
"is_tablet": true,
160+
"is_touch_capable": true,
161+
"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+",
162+
"str": "BlackBerry Playbook / BlackBerry Tablet OS 2.0.1 / BlackBerry WebKit 2.0.1"
163+
},
164+
"playstation": {
165+
"is_bot": false,
166+
"is_mobile": false,
167+
"is_pc": false,
168+
"is_tablet": false,
169+
"is_touch_capable": false,
170+
"ua_string": "Mozilla/5.0 (PLAYSTATION 3 4.60) AppleWebKit/531.22.8 (KHTML, like Gecko)",
171+
"str": "PlayStation 3 / Other / NetFront NX"
172+
},
173+
"playstation_vita": {"is_bot": false,
174+
"is_mobile": true,
175+
"is_pc": false,
176+
"is_tablet": false,
177+
"is_touch_capable": false,
178+
"ua_string": "Mozilla/5.0 (PlayStation Vita 3.12) AppleWebKit/536.26 (KHTML, like Gecko) Silk/3.2",
179+
"str": "PlayStation Vita / Other / NetFront NX"
180+
},
181+
"samsung_galaxy_s": {
182+
"is_bot": false,
183+
"is_mobile": true,
184+
"is_pc": false,
185+
"is_tablet": false,
186+
"is_touch_capable": true,
187+
"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",
188+
"str": "SAMSUNG SCH-I545 / Android 4.4.2 / Chrome Mobile 28.0.1500"
189+
},
190+
"samsung_galaxy_s_iii_mini": {
191+
"is_bot": false,
192+
"is_mobile": true,
193+
"is_pc": false,
194+
"is_tablet": false,
195+
"is_touch_capable": true,
196+
"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",
197+
"str": "GT-I8190 / Android 4.1.2 / Chrome Mobile 37.0.2062"
198+
},
199+
"samsung_sm_galaxy_s5": {
200+
"is_bot": false,
201+
"is_mobile": true,
202+
"is_pc": false,
203+
"is_tablet": false,
204+
"is_touch_capable": true,
205+
"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",
206+
"str": "SAMSUNG SM-G900F / Android 4.4.2 / Chrome Mobile 28.0.1500"
207+
},
208+
"samsung_wave_ii": {
209+
"is_bot": false,
210+
"is_mobile": true,
211+
"is_pc": false,
212+
"is_tablet": false,
213+
"is_touch_capable": false,
214+
"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",
215+
"str": "Samsung GT-S8530 / Bada 2 / Dolfin 3"
216+
},
217+
"ubuntu_firefox": {
218+
"is_bot": false,
219+
"is_mobile": false,
220+
"is_pc": true,
221+
"is_tablet": false,
222+
"is_touch_capable": false,
223+
"ua_string": "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1",
224+
"str": "PC / Ubuntu / Firefox 15.0.1"
225+
},
226+
"windows_ie": {
227+
"is_bot": false,
228+
"is_mobile": false,
229+
"is_pc": true,
230+
"is_tablet": false,
231+
"is_touch_capable": false,
232+
"ua_string": "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
233+
"str": "PC / Windows 7 / IE 9"
234+
},
235+
"windows_phone": {
236+
"is_bot": false,
237+
"is_mobile": true,
238+
"is_pc": false,
239+
"is_tablet": false,
240+
"is_touch_capable": true,
241+
"ua_string": "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)",
242+
"str": "Samsung SGH-i917 / Windows Phone 7.5 / IE Mobile 9"
243+
},
244+
"windows_rt": {
245+
"is_bot": false,
246+
"is_mobile": false,
247+
"is_pc": true,
248+
"is_tablet": true,
249+
"is_touch_capable": true,
250+
"ua_string": "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
251+
"str": "PC / Windows RT / IE 10"
252+
}
253+
}
254+

‎user_agents/parsers.py‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,26 @@
1818
'iPod',
1919
'Generic Smartphone',
2020
'Generic Feature Phone',
21+
'PlayStation Vita',
2122
)
2223

2324
MOBILE_OS_FAMILIES = (
2425
'Windows Phone',
25-
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
26+
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
2627
'Symbian OS',
28+
'Bada',
2729
)
2830

2931
TABLET_DEVICE_FAMILIES = (
3032
'iPad',
3133
'BlackBerry Playbook',
32-
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" instead of "BlackBerry"
34+
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" instead of "BlackBerry"
3335
'Kindle',
3436
'Kindle Fire',
37+
'Kindle Fire HD',
38+
'Galaxy Tab',
39+
'Xoom',
40+
'Dell Streak',
3541
)
3642

3743
TOUCH_CAPABLE_OS_FAMILIES = (
@@ -121,18 +127,16 @@ def _is_android_tablet(self):
121127
if ('Mobile Safari' not in self.ua_string and
122128
self.browser.family != "Firefox Mobile"):
123129
return True
124-
if 'SCH-' in self.ua_string:
125-
return True
126130
return False
127131

128132
def _is_blackberry_touch_capable_device(self):
129133
# A helper to determine whether a BB phone has touch capabilities
130134
# Blackberry Bold Touch series begins with 99XX
131135
if 'Blackberry 99' in self.device.family:
132136
return True
133-
if 'Blackberry 95' in self.device.family: # BB Storm devices
137+
if 'Blackberry 95' in self.device.family: # BB Storm devices
134138
return True
135-
if 'Blackberry 95' in self.device.family: # BB Torch devices
139+
if 'Blackberry 95' in self.device.family: # BB Torch devices
136140
return True
137141
return False
138142

0 commit comments

Comments
 (0)