Skip to content

Commit 125734d

Browse files
committed
Better PC device detection.
1 parent ec2a0d3 commit 125734d

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎user_agents/devices.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,24 @@
303303
"is_touch_capable": false,
304304
"ua_string": "Opera/9.80 (BREW; Opera Mini/5.0/27.2370; U; en) Presto/2.8.119 240X320 Samsung SCH-U380",
305305
"str": "Opera / Android 2.3.3 / Opera Mobile 11.50"
306+
},
307+
"windows_95": {
308+
"is_bot": false,
309+
"is_mobile": false,
310+
"is_pc": true,
311+
"is_tablet": false,
312+
"is_touch_capable": false,
313+
"ua_string": "Mozilla/5.0 (Windows; U; Win 9x 4.90; en-GB; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1",
314+
"str": "Other / Windows ME / Firefox 2"
315+
},
316+
"solaris": {
317+
"is_bot": false,
318+
"is_mobile": false,
319+
"is_pc": true,
320+
"is_tablet": false,
321+
"is_touch_capable": false,
322+
"ua_string": "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.6) Gecko/20040503",
323+
"str": "Other / Solaris / Other"
306324
}
307325
}
308326

‎user_agents/parsers.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
'PlayStation Vita',
2222
)
2323

24+
PC_OS_FAMILIES = (
25+
'Windows 95',
26+
'Windows 98',
27+
'Windows ME',
28+
'Solaris',
29+
)
30+
2431
MOBILE_OS_FAMILIES = (
2532
'Windows Phone',
2633
'Windows Phone OS', # Earlier versions of ua-parser returns Windows Phone OS
@@ -201,7 +208,7 @@ def is_touch_capable(self):
201208
@property
202209
def is_pc(self):
203210
# Returns True for "PC" devices (Windows, Mac and Linux)
204-
if 'Windows NT' in self.ua_string:
211+
if 'Windows NT' in self.ua_string or self.os.family in PC_OS_FAMILIES:
205212
return True
206213
# TODO: remove after https://github.com/tobie/ua-parser/issues/127 is closed
207214
if self.os.family == 'Mac OS X' and 'Silk' not in self.ua_string:

0 commit comments

Comments
 (0)