Skip to content

Commit

Permalink
Merge pull request #618 from garritfra/smarttv
Browse files Browse the repository at this point in the history
Support for various smart tvs
  • Loading branch information
faisalman authored Jan 26, 2023
2 parents 68447d8 + 2033eb4 commit bf4fb91
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 29 deletions.
76 changes: 47 additions & 29 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
LG = 'LG',
MICROSOFT = 'Microsoft',
MOTOROLA = 'Motorola',
NETRANGE= 'Netrange',
NETTV = 'NetTV',
OPERA = 'Opera',
PANASONIC = 'Panasonic',
SAMSUNG = 'Samsung',
SHARP = 'Sharp',
SONY = 'Sony',
VIERA = 'Viera',
XIAOMI = 'Xiaomi',
ZEBRA = 'Zebra',
FACEBOOK = 'Facebook';
Expand Down Expand Up @@ -298,6 +302,8 @@

/ wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
], [[NAME, CHROME+' WebView'], VERSION], [
/Panasonic;(VIERA)/i // Panasonic Viera
], [[NAME, VIERA]], [

/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
], [VERSION, [NAME, 'Android '+BROWSER]], [
Expand Down Expand Up @@ -373,6 +379,37 @@

device : [[

///////////////////
// SMARTTVS
///////////////////

/smart-tv.+(samsung)/i // Samsung
], [VENDOR, [TYPE, SMARTTV]], [
/hbbtv.+maple;(\d+)/i
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
], [[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]], [
/droid.+aft(\w)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
/(bravia[\w ]+)( bui|\))/i // Sony
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
/Hbbtv.*(technisat) (.*);/i // TechniSAT
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
], [[TYPE, SMARTTV]], [

//////////////////////////
// MOBILES & TABLETS
/////////////////////////
Expand Down Expand Up @@ -608,35 +645,6 @@
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [

///////////////////
// SMARTTVS
///////////////////

/smart-tv.+(samsung)/i // Samsung
], [VENDOR, [TYPE, SMARTTV]], [
/hbbtv.+maple;(\d+)/i
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
], [[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]], [
/droid.+aft(\w)( bui|\))/i // Fire TV
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
/(bravia[\w ]+)( bui|\))/i // Sony
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
/(mitv-\w{5}) bui/i // Xiaomi
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i // HbbTV devices
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
], [[TYPE, SMARTTV]], [

///////////////////
// WEARABLES
///////////////////
Expand Down Expand Up @@ -736,10 +744,20 @@
/(cros) [\w]+ ([\w\.]+\w)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[

// Smart TVs
/Panasonic;VIERA/i // Panasonic Viera
], [[NAME, VIERA]], [
/NETRANGEMMH/i // Netrange
], [[NAME, NETRANGE]], [
/nettv\/(\d\.\d.\d)/i // NetTV
], [VERSION, [NAME, NETTV]], [


// Console
/(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
/(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)


// Other
/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
/(mint)[\/\(\) ]?(\w*)/i, // Mint
Expand Down
10 changes: 10 additions & 0 deletions test/browser-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,16 @@
"major" : "1"
}
},
{
"desc" : "Viera",
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect" :
{
"name" : "Viera",
"version" : "undefined",
"major" : "undefined"
}
},
{
"desc" : "Yandex",
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.5 (KHTML, like Gecko) YaBrowser/1.0.1084.5402 Chrome/19.0.1084.5402 Safari/536.5",
Expand Down
119 changes: 119 additions & 0 deletions test/device-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,24 @@
"type": "mobile"
}
},
{
"desc": "JVC LT-43V55LFA Smart TV",
"ua": "Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 OPR/40.0.2207.0 OMI/4.9.0.237.DOM3-OPT.245 Model/Vestel-MB211 VSTVB MB200 HbbTV/1.2.1 (; JVC; MB211; 3.19.4.2; _TV_NT72563_2017 SmartTvA/3.0.0",
"expect": {
"vendor": "JVC",
"model": "MB211",
"type": "smarttv"
}
},
{
"desc": "JVC LT-43V65LUA Smart TV",
"ua": "Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 OPR/40.0.2207.0 OMI/4.9.0.237.DOM3-OPT.245 Model/Vestel-MB130 VSTVB MB100 HbbTV/1.2.1 (; JVC; MB130; 5.7.20.0; _TV_G10_2017;) SmartTvA/3.0.0",
"expect": {
"vendor": "JVC",
"model": "MB130",
"type": "smarttv"
}
},
{
"desc": "Lenovo Tab 2",
"ua": "Mozilla/5.0 (Linux; Android 5.0.1; Lenovo TAB 2 A7-30HC Build/LRX21M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.157 Safari/537.36",
Expand Down Expand Up @@ -979,6 +997,15 @@
"type": "smarttv"
}
},
{
"desc": "Loewe Smart TV",
"ua": "Mozilla/5.0 (Linux; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 OPR/46.0.2207.0 LOEWE-SL410/5.2.0.0 HbbTV/1.4.1 (; LOEWE; SL410; LOH/5.2.0.0;;) FVC/3.0 (LOEWE; SL410;) CE-HTML/1.0 Config (L:deu,CC:DEU) NETRANGEMMH",
"expect": {
"vendor": "LOEWE",
"model": "SL410",
"type": "smarttv"
}
},
{
"desc": "Meizu M5 Note",
"ua": "Mozilla/5.0 (Linux; Android 6.0; M5 Note Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043024 Safari/537.36 MicroMessenger/6.5.7.1040 NetType/WIFI Language/zh_CN",
Expand Down Expand Up @@ -1449,6 +1476,42 @@
"type": "mobile"
}
},
{
"desc": "Panasonic TX-32CSW514 SmartTV",
"ua": "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect": {
"vendor": "Panasonic",
"model": "VIERA 2015",
"type": "smarttv"
}
},
{
"desc": "Panasonic TX-40FXW724 SmartTV",
"ua": "HbbTV/1.4.1 (+DRM;Panasonic;SmartTV2018mid;3.024;4301-0003 0002-0000;SmartTV2018;)",
"expect": {
"vendor": "Panasonic",
"model": "SmartTV2018mid",
"type": "smarttv"
}
},
{
"desc": "Panasonic TX-43HXW904 SmartTV",
"ua": "HbbTV/1.5.1 (+DRM;Panasonic;SmartTV2020mid;3.326;4301-0003 0008-0000;com.panasonic.SmartTV2020mid;)",
"expect": {
"vendor": "Panasonic",
"model": "SmartTV2020mid",
"type": "smarttv"
}
},
{
"desc": "Panasonic DMR-HST130 SAT receiver",
"ua": "HbbTV/1.1.1 (+PVR;Panasonic;DIGA WebKit M8658;3.420;;)",
"expect": {
"vendor": "Panasonic",
"model": "DIGA WebKit M8658",
"type": "smarttv"
}
},
{
"desc": "Philips SmartTV",
"ua": "Opera/9.80 HbbTV/1.1.1 (; Philips; ; ; ; ) NETTV/4.0.2; en) Version/11.60",
Expand All @@ -1458,6 +1521,33 @@
"type": "smarttv"
}
},
{
"desc": "Philips 32PFL6606K/02 SmartTV (2011)",
"ua": "Opera/9.80 (Linux mips ; U; HbbTV/1.1.1 (; Philips; ; ; ; ) CE-HTML/1.0 NETTV/3.1.0; en) Presto/2.6.33 Version/10.70",
"expect": {
"vendor": "Philips",
"model": "",
"type": "smarttv"
}
},
{
"desc": "Philips 32PFL6606K/02 SmartTV (2013)",
"ua": "Opera/9.80 (Linux mips ; U; HbbTV/1.1.1 (; Philips; ; ; ; ) CE-HTML/1.0 NETTV/3.1.0; en) Presto/2.6.33 Version/10.70",
"expect": {
"vendor": "Philips",
"model": "",
"type": "smarttv"
}
},
{
"desc": "Philips 32PHS5301/12 SmartTV (2016)",
"ua": "Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36 OPR/29.0.1803.0 OMI/4.5.23.37.MOT2.13 HbbTV/1.2.1 (;Philips;32PHS5301/12;;_TV_MT5800;) Firmware/TPM161E_012.002.045.001 en",
"expect": {
"vendor": "Philips",
"model": "32PHS5301/12",
"type": "smarttv"
}
},
{
"desc": "Roku",
"ua": "Mozilla/5.0 (Roku) AppleWebKit/537.36 (KHTML, like Gecko) Web/1.1 Safari/537.36",
Expand Down Expand Up @@ -1746,6 +1836,15 @@
"type": "smarttv"
}
},
{
"desc": "Samsung SmartTV HBBTV",
"ua": "HbbTV/1.5.1 (+DRM;Samsung;SmartTV2021:UAU7000;T-KSU2EDEUC-1506.0;KantSU2e;urn:samsungtv:familyname:21_KANTSU2E_UHD_BASIC:2021;) Tizen/6.0 (+TVPLUS+SmartHubLink) Chrome/76 LaTivu_1.0.1_2021 RVID/17",
"expect": {
"vendor": "Samsung",
"model": "SmartTV2021:UAU7000",
"type": "smarttv"
}
},
{
"desc": "Sharp AQUOS-TVX19B",
"ua": "Mozilla/5.0 (Linux; Android 9; AQUOS-TVX19B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36",
Expand Down Expand Up @@ -1982,6 +2081,26 @@
"type": "embedded"
}
},
{
"desc" : "TechniSAT Digit ISIO S SAT receiver",
"ua" : "Opera/9.80 (Linux sh4; U; HbbTV/1.1.1 (;;;;;); CE-HTML; TechniSat Digit ISIO S; de) Presto/2.9.167 Version/11.50",
"expect" :
{
"vendor": "TechniSat",
"model": "Digit ISIO S",
"type": "smarttv"
}
},
{
"desc" : "TechniSAT MultyVision SmartTV",
"ua" : "Opera/9.80 (Linux i686; U; HbbTV/1.1.1 (;;;;;); CE-HTML; TechniSat MultyVision ISIO; de) Presto/2.9.167 Version/11.50",
"expect" :
{
"vendor": "TechniSat",
"model": "MultyVision ISIO",
"type": "smarttv"
}
},
{
"desc": "Xiaomi 2013023",
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.2; en-US; 2013023 Build/HM2013023) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/10.0.1.512 U3/0.8.0 Mobile Safari/533.1",
Expand Down
36 changes: 36 additions & 0 deletions test/os-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@
"version" : "2.3"
}
},
{
"desc" : "Tizen 6.0",
"ua" : "HbbTV/1.5.1 (+DRM;Samsung;SmartTV2021:UAU7000;T-KSU2EDEUC-1506.0;KantSU2e;urn:samsungtv:familyname:21_KANTSU2E_UHD_BASIC:2021;) Tizen/6.0 (+TVPLUS+SmartHubLink) Chrome/76 LaTivu_1.0.1_2021 RVID/17",
"expect" :
{
"name" : "Tizen",
"version" : "6.0"
}
},
{
"desc" : "Android",
"ua" : "Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; VM670 Build/FRG83G) AppleWebKit/533.1 (KHTML, like Gecko)",
Expand Down Expand Up @@ -1043,6 +1052,33 @@
"version" : "undefined"
}
},
{
"desc" : "Panasonic Viera",
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
"expect" :
{
"name" : "Viera",
"version" : "undefined"
}
},
{
"desc" : "Netrange Smart TV",
"ua" : "Mozilla/5.0 (Linux; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 OPR/46.0.2207.0 LOEWE-SL410/5.2.0.0 HbbTV/1.4.1 (; LOEWE; SL410; LOH/5.2.0.0;;) FVC/3.0 (LOEWE; SL410;) CE-HTML/1.0 Config (L:deu,CC:DEU) NETRANGEMMH",
"expect" :
{
"name" : "Netrange",
"version" : "undefined"
}
},
{
"desc" : "NetTV 3.2.1",
"ua" : "Opera/9.80 (Linux mips ; U; HbbTV/1.1.1 (; Philips; ; ; ; ) CE-HTML/1.0 NETTV/3.2.1; en) Presto/2.6.33 Version/10.70",
"expect" :
{
"name" : "NetTV",
"version" : "3.2.1"
}
},
{
"desc" : "HP-UX",
"ua" : "Mozilla/5.0 (X11; U; HP-UX 9000/785; es-ES; rv:1.0.1) Gecko/20020827 Netscape/7.0",
Expand Down

0 comments on commit bf4fb91

Please sign in to comment.