Skip to content

Commit 89ca040

Browse files
committed
Better mobile device detenction.
1 parent dc87652 commit 89ca040

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

‎MANIFEST‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# file GENERATED by distutils, do NOT edit
2+
LICENSE.txt
3+
README.rst
4+
setup.py
5+
user_agents/__init__.py
6+
user_agents/compat.py
7+
user_agents/parsers.py
8+
user_agents/tests.py

‎user_agents/devices.json‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,42 @@
258258
"is_touch_capable": false,
259259
"ua_string": "Mozilla/5.0 (iPhone; U; CPU iPhone OS) (compatible; Googlebot-Mobile/2.1; http://www.google.com/bot.html)",
260260
"str": "Spider / Other / Mobile Safari"
261+
},
262+
"windows_ce": {
263+
"is_bot": false,
264+
"is_mobile": true,
265+
"is_pc": false,
266+
"is_tablet": false,
267+
"is_touch_capable": true,
268+
"ua_string": "SAMSUNG-SGH-I617/UCHJ1 Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11)",
269+
"str": "Samsung SGH-I617 / Windows CE / IE Mobile 7.11"
270+
},
271+
"windows_mobile": {
272+
"is_bot": false,
273+
"is_mobile": true,
274+
"is_pc": false,
275+
"is_tablet": false,
276+
"is_touch_capable": true,
277+
"ua_string": "Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 8.12; MSIEMobile 6.0) 320x240; VZW; UTStar-XV6175.1; Windows Mobile 6.5 Standard;",
278+
"str": "Other / Windows Mobile / IE Mobile 8.12"
279+
},
280+
"opera_mobile": {
281+
"is_bot": false,
282+
"is_mobile": true,
283+
"is_pc": false,
284+
"is_tablet": true,
285+
"is_touch_capable": true,
286+
"ua_string": "Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1202011015; U; en) Presto/2.9.201 Version/11.50",
287+
"str": "Opera / Android 2.3.3 / Opera Mobile 11.50"
288+
},
289+
"opera_mini": {
290+
"is_bot": false,
291+
"is_mobile": true,
292+
"is_pc": false,
293+
"is_tablet": false,
294+
"is_touch_capable": false,
295+
"ua_string": "Opera/9.80 (BREW; Opera Mini/5.0/27.2370; U; en) Presto/2.8.119 240X320 Samsung SCH-U380",
296+
"str": "Opera / Android 2.3.3 / Opera Mobile 11.50"
261297
}
262298
}
263299

‎user_agents/parsers.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
2727
'Symbian OS',
2828
'Bada',
29+
'Windows CE',
30+
'Windows Mobile',
31+
)
32+
33+
MOBILE_BROWSER_FAMILIES = (
34+
'Opera Mobile',
35+
'Opera Mini',
2936
)
3037

3138
TABLET_DEVICE_FAMILIES = (
@@ -46,6 +53,8 @@
4653
'Windows Phone',
4754
'Windows Phone OS',
4855
'Windows RT',
56+
'Windows CE',
57+
'Windows Mobile',
4958
)
5059

5160
TOUCH_CAPABLE_DEVICE_FAMILIES = (
@@ -152,9 +161,11 @@ def is_tablet(self):
152161

153162
@property
154163
def is_mobile(self):
155-
# First check for mobile device families
164+
# First check for mobile device and mobile browser families
156165
if self.device.family in MOBILE_DEVICE_FAMILIES:
157166
return True
167+
if self.browser.family in MOBILE_BROWSER_FAMILIES:
168+
return True
158169
# Device is considered Mobile OS is Android and not tablet
159170
# This is not fool proof but would have to suffice for now
160171
if self.os.family == 'Android' and not self.is_tablet:

0 commit comments

Comments
 (0)