Skip to content

Commit bf4fb91

Browse files
authored
Merge pull request #618 from garritfra/smarttv
Support for various smart tvs
2 parents 68447d8 + 2033eb4 commit bf4fb91

File tree

4 files changed

+212
-29
lines changed

4 files changed

+212
-29
lines changed

src/ua-parser.js

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
5252
LG = 'LG',
5353
MICROSOFT = 'Microsoft',
5454
MOTOROLA = 'Motorola',
55+
NETRANGE= 'Netrange',
56+
NETTV = 'NetTV',
5557
OPERA = 'Opera',
58+
PANASONIC = 'Panasonic',
5659
SAMSUNG = 'Samsung',
5760
SHARP = 'Sharp',
5861
SONY = 'Sony',
62+
VIERA = 'Viera',
5963
XIAOMI = 'Xiaomi',
6064
ZEBRA = 'Zebra',
6165
FACEBOOK = 'Facebook';
@@ -298,6 +302,8 @@
298302

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

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

374380
device : [[
375381

382+
///////////////////
383+
// SMARTTVS
384+
///////////////////
385+
386+
/smart-tv.+(samsung)/i // Samsung
387+
], [VENDOR, [TYPE, SMARTTV]], [
388+
/hbbtv.+maple;(\d+)/i
389+
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
390+
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
391+
], [[VENDOR, LG], [TYPE, SMARTTV]], [
392+
/(apple) ?tv/i // Apple TV
393+
], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
394+
/crkey/i // Google Chromecast
395+
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
396+
/droid.+aft(\w)( bui|\))/i // Fire TV
397+
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
398+
/\(dtv[\);].+(aquos)/i,
399+
/(aquos-tv[\w ]+)\)/i // Sharp
400+
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
401+
/(bravia[\w ]+)( bui|\))/i // Sony
402+
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
403+
/(mitv-\w{5}) bui/i // Xiaomi
404+
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
405+
/Hbbtv.*(technisat) (.*);/i // TechniSAT
406+
], [VENDOR, MODEL, [TYPE, SMARTTV]], [
407+
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
408+
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
409+
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
410+
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
411+
], [[TYPE, SMARTTV]], [
412+
376413
//////////////////////////
377414
// MOBILES & TABLETS
378415
/////////////////////////
@@ -608,35 +645,6 @@
608645
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
609646
], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [
610647

611-
///////////////////
612-
// SMARTTVS
613-
///////////////////
614-
615-
/smart-tv.+(samsung)/i // Samsung
616-
], [VENDOR, [TYPE, SMARTTV]], [
617-
/hbbtv.+maple;(\d+)/i
618-
], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
619-
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
620-
], [[VENDOR, LG], [TYPE, SMARTTV]], [
621-
/(apple) ?tv/i // Apple TV
622-
], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
623-
/crkey/i // Google Chromecast
624-
], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
625-
/droid.+aft(\w)( bui|\))/i // Fire TV
626-
], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
627-
/\(dtv[\);].+(aquos)/i,
628-
/(aquos-tv[\w ]+)\)/i // Sharp
629-
], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
630-
/(bravia[\w ]+)( bui|\))/i // Sony
631-
], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
632-
/(mitv-\w{5}) bui/i // Xiaomi
633-
], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
634-
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
635-
/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i // HbbTV devices
636-
], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
637-
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
638-
], [[TYPE, SMARTTV]], [
639-
640648
///////////////////
641649
// WEARABLES
642650
///////////////////
@@ -736,10 +744,20 @@
736744
/(cros) [\w]+ ([\w\.]+\w)/i // Chromium OS
737745
], [[NAME, 'Chromium OS'], VERSION],[
738746

747+
// Smart TVs
748+
/Panasonic;VIERA/i // Panasonic Viera
749+
], [[NAME, VIERA]], [
750+
/NETRANGEMMH/i // Netrange
751+
], [[NAME, NETRANGE]], [
752+
/nettv\/(\d\.\d.\d)/i // NetTV
753+
], [VERSION, [NAME, NETTV]], [
754+
755+
739756
// Console
740757
/(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
741758
/(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
742759

760+
743761
// Other
744762
/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
745763
/(mint)[\/\(\) ]?(\w*)/i, // Mint

test/browser-test.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,16 @@
12781278
"major" : "1"
12791279
}
12801280
},
1281+
{
1282+
"desc" : "Viera",
1283+
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
1284+
"expect" :
1285+
{
1286+
"name" : "Viera",
1287+
"version" : "undefined",
1288+
"major" : "undefined"
1289+
}
1290+
},
12811291
{
12821292
"desc" : "Yandex",
12831293
"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",

test/device-test.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,24 @@
799799
"type": "mobile"
800800
}
801801
},
802+
{
803+
"desc": "JVC LT-43V55LFA Smart TV",
804+
"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",
805+
"expect": {
806+
"vendor": "JVC",
807+
"model": "MB211",
808+
"type": "smarttv"
809+
}
810+
},
811+
{
812+
"desc": "JVC LT-43V65LUA Smart TV",
813+
"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",
814+
"expect": {
815+
"vendor": "JVC",
816+
"model": "MB130",
817+
"type": "smarttv"
818+
}
819+
},
802820
{
803821
"desc": "Lenovo Tab 2",
804822
"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",
@@ -979,6 +997,15 @@
979997
"type": "smarttv"
980998
}
981999
},
1000+
{
1001+
"desc": "Loewe Smart TV",
1002+
"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",
1003+
"expect": {
1004+
"vendor": "LOEWE",
1005+
"model": "SL410",
1006+
"type": "smarttv"
1007+
}
1008+
},
9821009
{
9831010
"desc": "Meizu M5 Note",
9841011
"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",
@@ -1449,6 +1476,42 @@
14491476
"type": "mobile"
14501477
}
14511478
},
1479+
{
1480+
"desc": "Panasonic TX-32CSW514 SmartTV",
1481+
"ua": "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
1482+
"expect": {
1483+
"vendor": "Panasonic",
1484+
"model": "VIERA 2015",
1485+
"type": "smarttv"
1486+
}
1487+
},
1488+
{
1489+
"desc": "Panasonic TX-40FXW724 SmartTV",
1490+
"ua": "HbbTV/1.4.1 (+DRM;Panasonic;SmartTV2018mid;3.024;4301-0003 0002-0000;SmartTV2018;)",
1491+
"expect": {
1492+
"vendor": "Panasonic",
1493+
"model": "SmartTV2018mid",
1494+
"type": "smarttv"
1495+
}
1496+
},
1497+
{
1498+
"desc": "Panasonic TX-43HXW904 SmartTV",
1499+
"ua": "HbbTV/1.5.1 (+DRM;Panasonic;SmartTV2020mid;3.326;4301-0003 0008-0000;com.panasonic.SmartTV2020mid;)",
1500+
"expect": {
1501+
"vendor": "Panasonic",
1502+
"model": "SmartTV2020mid",
1503+
"type": "smarttv"
1504+
}
1505+
},
1506+
{
1507+
"desc": "Panasonic DMR-HST130 SAT receiver",
1508+
"ua": "HbbTV/1.1.1 (+PVR;Panasonic;DIGA WebKit M8658;3.420;;)",
1509+
"expect": {
1510+
"vendor": "Panasonic",
1511+
"model": "DIGA WebKit M8658",
1512+
"type": "smarttv"
1513+
}
1514+
},
14521515
{
14531516
"desc": "Philips SmartTV",
14541517
"ua": "Opera/9.80 HbbTV/1.1.1 (; Philips; ; ; ; ) NETTV/4.0.2; en) Version/11.60",
@@ -1458,6 +1521,33 @@
14581521
"type": "smarttv"
14591522
}
14601523
},
1524+
{
1525+
"desc": "Philips 32PFL6606K/02 SmartTV (2011)",
1526+
"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",
1527+
"expect": {
1528+
"vendor": "Philips",
1529+
"model": "",
1530+
"type": "smarttv"
1531+
}
1532+
},
1533+
{
1534+
"desc": "Philips 32PFL6606K/02 SmartTV (2013)",
1535+
"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",
1536+
"expect": {
1537+
"vendor": "Philips",
1538+
"model": "",
1539+
"type": "smarttv"
1540+
}
1541+
},
1542+
{
1543+
"desc": "Philips 32PHS5301/12 SmartTV (2016)",
1544+
"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",
1545+
"expect": {
1546+
"vendor": "Philips",
1547+
"model": "32PHS5301/12",
1548+
"type": "smarttv"
1549+
}
1550+
},
14611551
{
14621552
"desc": "Roku",
14631553
"ua": "Mozilla/5.0 (Roku) AppleWebKit/537.36 (KHTML, like Gecko) Web/1.1 Safari/537.36",
@@ -1746,6 +1836,15 @@
17461836
"type": "smarttv"
17471837
}
17481838
},
1839+
{
1840+
"desc": "Samsung SmartTV HBBTV",
1841+
"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",
1842+
"expect": {
1843+
"vendor": "Samsung",
1844+
"model": "SmartTV2021:UAU7000",
1845+
"type": "smarttv"
1846+
}
1847+
},
17491848
{
17501849
"desc": "Sharp AQUOS-TVX19B",
17511850
"ua": "Mozilla/5.0 (Linux; Android 9; AQUOS-TVX19B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36",
@@ -1982,6 +2081,26 @@
19822081
"type": "embedded"
19832082
}
19842083
},
2084+
{
2085+
"desc" : "TechniSAT Digit ISIO S SAT receiver",
2086+
"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",
2087+
"expect" :
2088+
{
2089+
"vendor": "TechniSat",
2090+
"model": "Digit ISIO S",
2091+
"type": "smarttv"
2092+
}
2093+
},
2094+
{
2095+
"desc" : "TechniSAT MultyVision SmartTV",
2096+
"ua" : "Opera/9.80 (Linux i686; U; HbbTV/1.1.1 (;;;;;); CE-HTML; TechniSat MultyVision ISIO; de) Presto/2.9.167 Version/11.50",
2097+
"expect" :
2098+
{
2099+
"vendor": "TechniSat",
2100+
"model": "MultyVision ISIO",
2101+
"type": "smarttv"
2102+
}
2103+
},
19852104
{
19862105
"desc": "Xiaomi 2013023",
19872106
"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",

test/os-test.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@
197197
"version" : "2.3"
198198
}
199199
},
200+
{
201+
"desc" : "Tizen 6.0",
202+
"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",
203+
"expect" :
204+
{
205+
"name" : "Tizen",
206+
"version" : "6.0"
207+
}
208+
},
200209
{
201210
"desc" : "Android",
202211
"ua" : "Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; VM670 Build/FRG83G) AppleWebKit/533.1 (KHTML, like Gecko)",
@@ -1043,6 +1052,33 @@
10431052
"version" : "undefined"
10441053
}
10451054
},
1055+
{
1056+
"desc" : "Panasonic Viera",
1057+
"ua" : "HbbTV/1.2.1 (;Panasonic;VIERA 2015;3.014;a001-003 4000-0000;)",
1058+
"expect" :
1059+
{
1060+
"name" : "Viera",
1061+
"version" : "undefined"
1062+
}
1063+
},
1064+
{
1065+
"desc" : "Netrange Smart TV",
1066+
"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",
1067+
"expect" :
1068+
{
1069+
"name" : "Netrange",
1070+
"version" : "undefined"
1071+
}
1072+
},
1073+
{
1074+
"desc" : "NetTV 3.2.1",
1075+
"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",
1076+
"expect" :
1077+
{
1078+
"name" : "NetTV",
1079+
"version" : "3.2.1"
1080+
}
1081+
},
10461082
{
10471083
"desc" : "HP-UX",
10481084
"ua" : "Mozilla/5.0 (X11; U; HP-UX 9000/785; es-ES; rv:1.0.1) Gecko/20020827 Netscape/7.0",

0 commit comments

Comments
 (0)