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 authored and lbarthon committed May 31, 2024
1 parent 1f6353a commit ae4c16d
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 7 deletions.
62 changes: 56 additions & 6 deletions regexes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,29 @@ os_parsers:
# Special case for new ArcGIS Mobile products
- regex: 'ArcGISRuntime-(?:Android|iOS)\/\d+\.\d+(?:\.\d+|) \((Android|iOS) (\d+)(?:\.(\d+)(?:\.(\d+)|)|);'

##########
# Chromecast
##########
# Ex: 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
# These are the newer Android-based "Google TV" Chromecast devices.
# Google stopped updating the Chromecast firmware version in these, so they always say CrKey/1.56.500000. Therefore we extract the more useful Android version instead.
- regex: '(Android) (\d+)(?:\.(\d+)).*CrKey'
os_replacement: 'Chromecast Android'

# Ex: Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000
# These are some intermediate "Nest Hub" Chromecast devices running Fuchsia.
- regex: 'Fuchsia.*(CrKey)(?:[/](\d+)\.(\d+)(?:\.(\d+)|)|)'
os_replacement: 'Chromecast Fuchsia'

# Ex: 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
- regex: 'Linux.*(CrKey)(?:[/](\d+)\.(\d+)(?:\.(\d+)|)|).*DeviceType/SmartSpeaker'
os_replacement: 'Chromecast SmartSpeaker'

# Ex: 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
# These are the oldest Chromecast devices that ran Linux.
- regex: 'Linux.*(CrKey)(?:[/](\d+)\.(\d+)(?:\.(\d+)|)|)'
os_replacement: 'Chromecast Linux'

##########
# Android
# can actually detect rooted android os. do we care?
Expand Down Expand Up @@ -1826,12 +1849,6 @@ os_parsers:

- regex: '(WebTV)/(\d+).(\d+)'

##########
# Chromecast
##########
- regex: '(CrKey)(?:[/](\d+)\.(\d+)(?:\.(\d+)|)|)'
os_replacement: 'Chromecast'

##########
# Misc mobile
##########
Expand Down Expand Up @@ -2465,6 +2482,39 @@ device_parsers:
brand_replacement: 'ChangJia'
model_replacement: '$1'

##########
# Chromecast
# @ref: https://en.wikipedia.org/wiki/Chromecast#Hardware_and_design
##########
# Ex: 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
# Ex: 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
# Ex: 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
# These are the newer Chromecast devices, such as smart speakers, Google TVs, etc. that have an explicit device type.
- regex: 'CrKey.*DeviceType/([^/]*)'
brand_replacement: 'Google'
device_replacement: 'Chromecast'
model_replacement: '$1'

# Ex: Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000
# These are some intermediate "Nest Hub" Chromecast devices running Fuchsia.
- regex: 'Fuchsia.*CrKey'
brand_replacement: 'Google'
device_replacement: 'Chromecast'
model_replacement: 'Nest Hub'

# Ex: Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.47 Safari/537.36 CrKey/1.36.159268
# These are the first generation of Chromecast devices that ran Linux. They don't specify a device type.
- regex: 'Linux.*CrKey/1.36'
brand_replacement: 'Google'
device_replacement: 'Chromecast'
model_replacement: 'First Generation'

# We have no data on the user agent strings of other models, except that they all report CrKey/
- regex: 'CrKey/'
brand_replacement: 'Google'
device_replacement: 'Chromecast'
model_replacement: null

#########
# Cloudfone
# @ref: http://www.cloudfonemobile.com/
Expand Down
30 changes: 30 additions & 0 deletions tests/test_device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7735,6 +7735,36 @@ test_cases:
brand: 'ChangJia'
model: 'TPC97113'

- user_agent_string: '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'
family: 'Chromecast'
brand: 'Google'
model: 'AndroidTV'

- user_agent_string: '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'
family: 'Chromecast'
brand: 'Google'
model: 'SmartSpeaker'

- user_agent_string: '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'
family: 'Chromecast'
brand: 'Google'
model: 'Chromecast'

- user_agent_string: 'Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000'
family: 'Chromecast'
brand: 'Google'
model: 'Nest Hub'

- user_agent_string: 'Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.47 Safari/537.36 CrKey/1.36.159268'
family: 'Chromecast'
brand: 'Google'
model: 'First Generation'

- user_agent_string: 'Mozilla/5.0 (X11; Linux armv7l) CrKey/1'
family: 'Chromecast'
brand: 'Google'
model: null

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 2.3.5; En-gb; Cloudfone_Excite320e Build/GRJ90) AppleWebKit/533.1 (KHTML, Like Gecko) Version/4.0 Mobile Safari/533.1'
family: 'Cloudfone Excite 320e'
brand: 'Cloudfone'
Expand Down
35 changes: 34 additions & 1 deletion tests/test_os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2783,8 +2783,41 @@ test_cases:
patch: '1'
patch_minor:

# Android-based Chromecast (Google TV)
- user_agent_string: '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'
family: 'Chromecast Android'
major: '12'
minor: '0'
patch:
patch_minor:

# Fuchsia-based Chromecast (Nest Hub)
- user_agent_string: 'Mozilla/5.0 (Fuchsia) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 CrKey/1.56.500000'
family: 'Chromecast Fuchsia'
major: '1'
minor: '56'
patch: '500000'
patch_minor:

# Linux-based Chromecast smart speaker, different OS from other Linux-based Chromecasts
- user_agent_string: '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'
family: 'Chromecast SmartSpeaker'
major: '1'
minor: '56'
patch: '500000'
patch_minor:

# Latest hardware and firmware, Linux-based Chromecast
- user_agent_string: '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'
family: 'Chromecast Linux'
major: '1'
minor: '56'
patch: '500000'
patch_minor:

# Older hardware and firmware, Linux-based Chromecast
- user_agent_string: 'Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.84 Safari/537.36 CrKey/1.22.74257'
family: 'Chromecast'
family: 'Chromecast Linux'
major: '1'
minor: '22'
patch: '74257'
Expand Down

0 comments on commit ae4c16d

Please sign in to comment.