Skip to content

Commit

Permalink
feat: Update and expand Chromecast device families
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed May 8, 2024
1 parent a43d659 commit f2c7ff0
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
27 changes: 22 additions & 5 deletions src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
PREFIX_MOBILE = 'Mobile ',
SUFFIX_BROWSER = ' Browser',
CHROME = 'Chrome',
CHROMECAST = 'Chromecast',
EDGE = 'Edge',
FIREFOX = 'Firefox',
OPERA = 'Opera',
Expand Down Expand Up @@ -663,8 +664,14 @@
], [[VENDOR, LG], [TYPE, SMARTTV]], [
/(apple) ?tv/i // Apple TV
], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
/crkey/i // Google Chromecast
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/crkey.*devicetype\/chromecast/i // Google Chromecast Third Generation
], [[MODEL, CHROMECAST+' Third Generation'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/crkey.*devicetype\/([^/]*)/i // Google Chromecast with specific device type
], [[MODEL, /^/, 'Chromecast '], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/fuchsia.*crkey/i // Google Chromecast Nest Hub
], [[MODEL, CHROMECAST+' Nest Hub'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/crkey/i // Google Chromecast, Linux-based or unknown
], [[MODEL, CHROMECAST], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
/droid.+aft(\w+)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
Expand Down Expand Up @@ -777,6 +784,18 @@
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
], [[NAME, 'macOS'], [VERSION, /_/g, '.']], [

// Google Chromecast
/android ([\d\.]+).*crkey/i // Google Chromecast, Android-based
], [VERSION, [NAME, CHROMECAST + ' Android']], [
/fuchsia.*crkey\/([\d\.]+)/i // Google Chromecast, Fuchsia-based
], [VERSION, [NAME, CHROMECAST + ' Fuchsia']], [
/crkey\/([\d\.]+).*devicetype\/smartspeaker/i // Google Chromecast, Linux-based Smart Speaker
], [VERSION, [NAME, CHROMECAST + ' SmartSpeaker']], [
/linux.*crkey\/([\d\.]+)/i // Google Chromecast, Legacy Linux-based
], [VERSION, [NAME, CHROMECAST + ' Linux']], [
/crkey\/([\d\.]+)/i // Google Chromecast, unknown
], [VERSION, [NAME, CHROMECAST]], [

// Mobile OSes
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS
Expand All @@ -797,9 +816,7 @@
/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i // watchOS
], [VERSION, [NAME, 'watchOS']], [

// Google Chromecast
/crkey\/([\d\.]+)/i // Google Chromecast
], [VERSION, [NAME, CHROME+'cast']], [
// Google ChromeOS
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
], [[NAME, "Chrome OS"], VERSION],[

Expand Down
36 changes: 36 additions & 0 deletions test/specs/device-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -3014,6 +3014,42 @@
"type": "mobile"
}
},
{
"desc": "Google Chromecast with Google TV",
"ua": "Mozilla/5.0 (Linux; Android 12.0; Build/STTL.240206.002) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.0 Safari/537.36 CrKey/1.56.500000 DeviceType/AndroidTV",
"expect": {
"vendor": "Google",
"model": "Chromecast AndroidTV",
"type": "smarttv"
}
},
{
"desc": "Google Chromecast Mini Smart Speaker",
"ua": "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.225 Safari/537.36 CrKey/1.56.500000 DeviceType/SmartSpeaker",
"expect": {
"vendor": "Google",
"model": "Chromecast SmartSpeaker",
"type": "smarttv"
}
},
{
"desc": "Google Chromecast Third Generation",
"ua": "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.225 Safari/537.36 CrKey/1.56.500000 DeviceType/Chromecast",
"expect": {
"vendor": "Google",
"model": "Chromecast Third Generation",
"type": "smarttv"
}
},
{
"desc": "Google Chromecast Nest Hub",
"ua": "Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000",
"expect": {
"vendor": "Google",
"model": "Chromecast Nest Hub",
"type": "smarttv"
}
},
{
"desc": "Google Chromecast",
"ua": "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.84 Safari/537.36 CrKey/1.22.79313",
Expand Down
31 changes: 29 additions & 2 deletions test/specs/os-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,38 @@
}
},
{
"desc" : "Google Chromecast",
"desc" : "Google Chromecast with Google TV",
"ua" : "Mozilla/5.0 (Linux; Android 12.0; Build/STTL.240206.002) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.0 Safari/537.36 CrKey/1.56.500000 DeviceType/AndroidTV",
"expect" :
{
"name" : "Chromecast Android",
"version" : "12.0"
}
},
{
"desc" : "Google Chromecast Nest Hub",
"ua" : "Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000",
"expect" :
{
"name" : "Chromecast Fuchsia",
"version" : "1.56.500000"
}
},
{
"desc" : "Google Chromecast Mini Smart Speaker",
"ua" : "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.225 Safari/537.36 CrKey/1.56.500000 DeviceType/SmartSpeaker",
"expect" :
{
"name" : "Chromecast SmartSpeaker",
"version" : "1.56.500000"
}
},
{
"desc" : "Google Chromecast Legacy Linux-Based",
"ua" : "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.81 Safari/537.36 CrKey/1.42.183786",
"expect" :
{
"name" : "Chromecast",
"name" : "Chromecast Linux",
"version" : "1.42.183786"
}
},
Expand Down

0 comments on commit f2c7ff0

Please sign in to comment.