Skip to content

Commit

Permalink
TvOrConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
serg committed Sep 27, 2019
1 parent 7f9e557 commit 32f399f
Show file tree
Hide file tree
Showing 10 changed files with 980 additions and 255 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

[![Build status](https://img.shields.io/appveyor/ci/thyn/ua-parser-formfactor.svg)](https://ci.appveyor.com/project/thyn/ua-parser-formfactor) [![AppVeyor tests](https://img.shields.io/appveyor/tests/thyn/ua-parser-formfactor.svg)](https://ci.appveyor.com/project/thyn/ua-parser-formfactor/build/tests) [![NuGet](https://img.shields.io/nuget/vpre/UAParser.FormFactor.svg)](https://www.nuget.org/packages/UAParser.FormFactor/)

A .net wrapper for the ua-parser library with form factors (Mobile,Table,Desktop,Spider). No hidden references to System.Net.Http. Based on http://detectmobilebrowsers.com and https://github.com/ua-parser/uap-csharp
A .net wrapper for the ua-parser library with form factors (Mobile,Table,Desktop,Spider,TvAndConsole). No hidden references to System.Net.Http. Based on http://detectmobilebrowsers.com and https://github.com/ua-parser/uap-csharp

# Changes

2019.09.27 Update UAParser regexes.yaml. Add TvOrConsole form factor. Add regex for desktop. NOW DESKTOP IS NOT DEFAULT FORM FACTOR. Default is Unknown.

2018.07.04 Fork UAParser to support .net standart 2.0. Update yaml files. Fix forked tests to support new yaml test files. Remove hell with System.Net.http. Remove custom wrappers for old UAParser library. Supports .Net 4.6.1+, .net core

Expand All @@ -22,6 +23,7 @@ https://www.nuget.org/packages/UAParser.FormFactor/
2. Tablet
3. Desktop
4. Spider
5. TvOrConsole

# Usage

Expand All @@ -47,3 +49,35 @@ https://www.nuget.org/packages/UAParser.FormFactor/
Console.WriteLine(result.Device.FormFactor); // => Mobile
```

# Regexes used to define form factors

1. Mobile

```
(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino
```
then
```
1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-
```

2. Tablet

```
android|ipad|playbook|silk|tablet
```

3. TvOrConsole

```
smart[- ]?tv|apple ?tv|googletv|android tv|opera tv|dtvnetbrowser|sonycebrowser|bravia 4k|netflix|pov_tv-hdmi-200bt| dlnadoc\/|hbbtv|tv safari|roku\/dvp|nsz-gs7\/gx70|crkey| aftm | aftt | gtv100|nintendobrowser
```

4. Desktop

```
windows nt |windows;|firefox| chrome|netscape|iceweasel|seamonkey|icedove|iceowl|iceape|opera
```

5. Else Unknown
8 changes: 4 additions & 4 deletions UAParser.FormFactor.Tests/Resources/pgts_browser_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39415,9 +39415,9 @@ test_cases:
patch:

- user_agent_string: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0; 3COM U.S. Robotics)'
family: 'Robotics'
major:
minor:
family: 'IE'
major: '6'
minor: '0'
patch:

- user_agent_string: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0; ABN AMRO)'
Expand Down Expand Up @@ -63409,7 +63409,7 @@ test_cases:
patch:

- user_agent_string: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows XP Professional Bot v.5.)'
family: 'XP Professional Bot'
family: 'Windows XP Professional Bot'
major:
minor:
patch:
Expand Down
185 changes: 185 additions & 0 deletions UAParser.FormFactor.Tests/Resources/test_device.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
test_cases:

- user_agent_string: 'atc/1.0 watchOS/5.1.3 model/Watch3,4 hwp/t8004 build/16S535 (6; dt:156)'
family: 'Apple Watch'
brand: 'Apple'
model: 'Apple Watch 3,4'

- user_agent_string: 'atc/1.0 watchOS/5.2 model/Watch4,4 hwp/t8006 build/16T225 (6; dt:193)'
family: 'Apple Watch'
brand: 'Apple'
model: 'Apple Watch 4,4'

- user_agent_string: '(null)/(null) watchOS/5.1.1 model/Watch3,3 hwp/t8004 build/16R600 (6; dt:155)'
family: 'Apple Watch'
brand: 'Apple'
model: 'Apple Watch 3,3'

- user_agent_string: 'ALCATEL-OT510A/382 ObigoInternetBrowser/Q05A'
family: 'Alcatel OT510A'
brand: 'Alcatel'
Expand Down Expand Up @@ -650,6 +665,31 @@ test_cases:
brand: 'Spider'
model: 'Desktop'

- user_agent_string: 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko PTST/1.0'
family: 'Spider'
brand: 'Spider'
model:

- user_agent_string: 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.0 Safari/537.36 PTST/1.0'
family: 'Spider'
brand: 'Spider'
model:

- user_agent_string: 'Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4) Build/MPJ24.139-64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Mobile Safari/537.36 PTST/180521.140508'
family: 'Spider'
brand: 'Spider'
model:

- user_agent_string: 'Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4) Build/MPJ24.139-64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Mobile Safari/537.36 PTST/391'
family: 'Spider'
brand: 'Spider'
model:

- user_agent_string: 'Mozilla/5.0 (X11; Datanyze; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'
family: 'Spider'
brand: 'Spider'
model:

- user_agent_string: 'Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PingdomTMS/0.8.5 Safari/534.34'
family: 'Spider'
brand: 'Spider'
Expand Down Expand Up @@ -11445,6 +11485,56 @@ test_cases:
brand: 'Generic_Android'
model: 'S300'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 2.1-update1; Ar-kw; EQ U8110) AppleWebKit/530.17 (KHTML, Like Gecko) Version/4.0 Mobile Safari/530.17'
family: 'EQ U8110'
brand: 'Generic_Android'
model: 'EQ U8110'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 2.1-update1; Cs-cz; Zt180) AppleWebKit/530.17 (KHTML, Like Gecko) Version/4.0 Mobile Safari/530.17'
family: 'Zt180'
brand: 'Generic_Android'
model: 'Zt180'

- user_agent_string: 'Mozilla 5.0 (Linux; U; Android 2.2.1; zh-cn; 3GC101) UC AppleWebKit 534.31 (KHTML, like Gecko) Mobile Safari 534.31'
family: '3GC101'
brand: 'Generic_Android'
model: '3GC101'

- user_agent_string: 'Mozilla 5.0 (Linux; U; Android 2.3.1; zh-cn; Newpad-K97) UC AppleWebKit 534.31 (KHTML, like Gecko) Mobile Safari 534.31'
family: 'Newpad-K97'
brand: 'Generic_Android'
model: 'Newpad-K97'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 4.0.3; -; PP4MT-7) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30'
family: 'PP4MT-7'
brand: 'Generic_Android'
model: 'PP4MT-7'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 4.0.3; -; PP4MT-9) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
family: 'PP4MT-9'
brand: 'Generic_Android'
model: 'PP4MT-9'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 2.2.1; id; AD350) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1 UCBrowser/8.7.0.315 Ponsel'
family: 'AD350'
brand: 'Generic_Android'
model: 'AD350'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 2.2.1; -us; Ally) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
family: 'Ally'
brand: 'Generic_Android'
model: 'Ally'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 2.3.4; A9100) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.58 Mobile Safari/537.31 OPR/14.0.1074.57768'
family: 'A9100'
brand: 'Generic_Android'
model: 'A9100'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 2.3.3; S300) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.123 Mobile Safari/537.22 OPR/14.0.1025.53005'
family: 'S300'
brand: 'Generic_Android'
model: 'S300'

- user_agent_string: 'Mozilla/5.0 (DTV) NetFront/3.4 InettvBrowser/2.2 (08001F;DTV03VSFC;0002;0001)'
family: 'Inettv'
brand: 'Generic_Inettv'
Expand Down Expand Up @@ -58045,6 +58135,16 @@ test_cases:
brand: 'Samsung'
model: 'GT-S8600-ORANGE'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; SM-G9500) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Mobile Safari/537.36'
family: 'Samsung SM-G9500'
brand: 'Samsung'
model: 'SM-G9500'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; SAMSUNG SM-G9500 Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.3 Chrome/67.0.3396.87 Mobile Safari/537.36'
family: 'Samsung SM-G9500'
brand: 'Samsung'
model: 'SM-G9500'

- user_agent_string: 'UCWEB/2.0 (Symbian; U; S60 V5; Pt-BR; SamsungI8910) U2/1.0.0 UCBrowser/8.9.0.277 U2/1.0.0 Mobile'
family: 'Samsung I8910'
brand: 'Samsung'
Expand Down Expand Up @@ -77425,6 +77525,26 @@ test_cases:
brand: 'XiaoMi'
model: 'Redmi Note 2'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 8.0.0; zh-cn; MIX Build/OPR1.170623.032) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.1.1'
family: 'XiaoMi MIX'
brand: 'XiaoMi'
model: 'MIX'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 9; MIX 2S Build/PKQ1.180729.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.7.3'
family: 'XiaoMi MIX 2S'
brand: 'XiaoMi'
model: 'MIX 2S'

- user_agent_string: 'Mozilla/5.0 (Linux; U; Android 8.0.0; zh-cn; MIX 2 Build/OPR1.170623.027) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.1.1'
family: 'XiaoMi MIX 2'
brand: 'XiaoMi'
model: 'MIX 2'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 9; Mi A2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'XiaoMi Mi A2'
brand: 'XiaoMi'
model: 'Mi A2'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 4.1.1; XOLO A1000 Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19'
family: 'Xolo A1000'
brand: 'Xolo'
Expand Down Expand Up @@ -79955,6 +80075,11 @@ test_cases:
brand: 'OnePlus'
model: 'ONE E1003'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 9; ONEPLUS A5010) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.89 Mobile Safari/537.36'
family: 'OnePlus ONEPLUS A5010'
brand: 'OnePlus'
model: 'ONEPLUS A5010'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM1.171019.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36'
family: 'Pixel'
brand: 'Google'
Expand Down Expand Up @@ -79985,6 +80110,11 @@ test_cases:
brand: 'RCA'
model: 'G1'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 4.4.2; SC-01F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36'
family: 'Samsung SC-01F'
brand: 'Samsung'
model: 'SC-01F'

- user_agent_string: 'WhatsApp/2.17.70 W'
family: 'Spider'
brand: 'Spider'
Expand Down Expand Up @@ -80084,3 +80214,58 @@ test_cases:
family: 'Samsung SM-A520F'
brand: 'Samsung'
model: 'SM-A520F'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; ANE-LX1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei ANE-LX1'
brand: 'Huawei'
model: 'ANE-LX1'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; PRA-LX1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei PRA-LX1'
brand: 'Huawei'
model: 'PRA-LX1'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 6.0; ALE-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei ALE-L21'
brand: 'Huawei'
model: 'ALE-L21'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; LDN-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei LDN-L21'
brand: 'Huawei'
model: 'LDN-L21'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 6.0; CAM-L03) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei CAM-L03'
brand: 'Huawei'
model: 'CAM-L03'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; ATU-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei ATU-L21'
brand: 'Huawei'
model: 'ATU-L21'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 8.0.0; RNE-L21) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei RNE-L21'
brand: 'Huawei'
model: 'RNE-L21'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 7.0; EVA-L09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei EVA-L09'
brand: 'Huawei'
model: 'EVA-L09'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 6.0; DIG-L01) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Huawei DIG-L01'
brand: 'Huawei'
model: 'DIG-L01'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 7.1.1; SM-J510FN) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Samsung SM-J510FN'
brand: 'Samsung'
model: 'SM-J510FN'

- user_agent_string: 'Mozilla/5.0 (Linux; Android 7.0; ASUS_X018D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Mobile Safari/537.36'
family: 'Asus X018D'
brand: 'Asus'
model: 'X018D'
Loading

0 comments on commit 32f399f

Please sign in to comment.