Television.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. <?php
  2. namespace WhichBrowser\Analyser\Header\Useragent\Device;
  3. use WhichBrowser\Constants;
  4. use WhichBrowser\Data;
  5. trait Television
  6. {
  7. private function detectTelevision($ua)
  8. {
  9. /* Detect the type based on some common markers */
  10. $this->detectGenericTelevision($ua);
  11. /* Try to parse some generic methods to store device information */
  12. $this->detectGenericTelevisionModels($ua);
  13. $this->detectGenericInettvBrowser($ua);
  14. $this->detectGenericHbbTV($ua);
  15. /* Look for specific manufacturers and models */
  16. $this->detectPanasonicTelevision($ua);
  17. $this->detectSharpTelevision($ua);
  18. $this->detectSamsungTelevision($ua);
  19. $this->detectSonyTelevision($ua);
  20. $this->detectPhilipsTelevision($ua);
  21. $this->detectLgTelevision($ua);
  22. $this->detectToshibaTelevision($ua);
  23. $this->detectSanyoTelevision($ua);
  24. /* Try to detect set top boxes from various manufacturers */
  25. $this->detectSettopboxes($ua);
  26. /* Improve model names */
  27. $this->improveModelsOnDeviceTypeTelevision();
  28. }
  29. /* Generic markers */
  30. private function detectGenericTelevision($ua)
  31. {
  32. if (preg_match('/CE-HTML/u', $ua)) {
  33. $this->data->device->type = Constants\DeviceType::TELEVISION;
  34. }
  35. if (preg_match('/SmartTvA\//u', $ua)) {
  36. $this->data->device->type = Constants\DeviceType::TELEVISION;
  37. }
  38. if (preg_match('/NETRANGEMMH/u', $ua)) {
  39. $this->data->device->type = Constants\DeviceType::TELEVISION;
  40. }
  41. }
  42. /* Toshiba */
  43. private function detectToshibaTelevision($ua)
  44. {
  45. if (preg_match('/Toshiba_?TP\//u', $ua) || preg_match('/TSBNetTV ?\//u', $ua)) {
  46. $this->data->device->manufacturer = 'Toshiba';
  47. $this->data->device->series = 'Smart TV';
  48. $this->data->device->type = Constants\DeviceType::TELEVISION;
  49. $this->data->device->identified |= Constants\Id::MATCH_UA;
  50. }
  51. if (preg_match('/TOSHIBA;[^;]+;([A-Z]+[0-9]+[A-Z]+);/u', $ua, $match)) {
  52. $this->data->device->manufacturer = 'Toshiba';
  53. $this->data->device->model = $match[1];
  54. $this->data->device->series = 'Smart TV';
  55. $this->data->device->type = Constants\DeviceType::TELEVISION;
  56. $this->data->device->identified |= Constants\Id::MATCH_UA;
  57. }
  58. }
  59. /* LG */
  60. private function detectLgTelevision($ua)
  61. {
  62. if (preg_match('/(LGSmartTV|LG smartTV)/u', $ua)) {
  63. $this->data->device->manufacturer = 'LG';
  64. $this->data->device->series = 'Smart TV';
  65. $this->data->device->type = Constants\DeviceType::TELEVISION;
  66. $this->data->device->identified |= Constants\Id::MATCH_UA;
  67. }
  68. if (preg_match('/UPLUSTVBROWSER/u', $ua)) {
  69. $this->data->device->manufacturer = 'LG';
  70. $this->data->device->series = 'U+ tv';
  71. $this->data->device->type = Constants\DeviceType::TELEVISION;
  72. $this->data->device->identified |= Constants\Id::MATCH_UA;
  73. }
  74. /* NetCast */
  75. if (preg_match('/LG NetCast\.(TV|Media)-([0-9]*)/u', $ua, $match)) {
  76. $this->data->device->manufacturer = 'LG';
  77. $this->data->device->series = 'NetCast ' . $match[1] . ' ' . $match[2];
  78. $this->data->device->type = Constants\DeviceType::TELEVISION;
  79. $this->data->device->identified |= Constants\Id::MATCH_UA;
  80. if (preg_match('/LG Browser\/[0-9.]+\([^;]+; LGE; ([^;]+);/u', $ua, $match)) {
  81. if (substr($match[1], 0, 6) != 'GLOBAL' && substr($match[1], 0, 7) != 'NETCAST') {
  82. $this->data->device->model = $match[1];
  83. }
  84. }
  85. }
  86. /* NetCast */
  87. if ($ua == "Mozilla/5.0 (X11; Linux; ko-KR) AppleWebKit/534.26+ (KHTML, like Gecko) Version/5.0 Safari/534.26+" ||
  88. $ua == "Mozilla/5.0 (DirectFB; Linux; ko-KR) AppleWebKit/534.26 (KHTML, like Gecko) Version/5.0 Safari/534.26" ||
  89. $ua == "Mozilla/5.0 (DirectFB; Linux; ko-KR) AppleWebKit/534.26+ (KHTML, like Gecko) Version/5.0 Safari/534.26+") {
  90. $this->data->device->manufacturer = 'LG';
  91. $this->data->device->series = 'NetCast TV 2012';
  92. $this->data->device->type = Constants\DeviceType::TELEVISION;
  93. $this->data->device->identified |= Constants\Id::MATCH_UA;
  94. }
  95. /* NetCast or WebOS */
  96. if (preg_match('/NetCast/u', $ua) && preg_match('/SmartTV\/([0-9])/u', $ua, $match)) {
  97. $this->data->device->manufacturer = 'LG';
  98. $this->data->device->type = Constants\DeviceType::TELEVISION;
  99. $this->data->device->identified |= Constants\Id::MATCH_UA;
  100. if (intval($match[1]) < 5) {
  101. $this->data->device->series = 'NetCast TV';
  102. } else {
  103. $this->data->device->series = 'webOS TV';
  104. $this->data->os->reset([
  105. 'name' => 'webOS',
  106. 'hidden' => true
  107. ]);
  108. }
  109. }
  110. /* WebOS */
  111. if (preg_match('/Web[O0]S/u', $ua) && preg_match('/Large Screen/u', $ua)) {
  112. $this->data->device->manufacturer = 'LG';
  113. $this->data->device->series = 'webOS TV';
  114. $this->data->device->type = Constants\DeviceType::TELEVISION;
  115. $this->data->device->identified |= Constants\Id::MATCH_UA;
  116. $this->data->os->reset([
  117. 'name' => 'webOS',
  118. 'hidden' => true
  119. ]);
  120. }
  121. if (preg_match('/Web[O0]S; Linux\/SmartTV/u', $ua)) {
  122. $this->data->device->manufacturer = 'LG';
  123. $this->data->device->series = 'webOS TV';
  124. $this->data->device->type = Constants\DeviceType::TELEVISION;
  125. $this->data->device->identified |= Constants\Id::MATCH_UA;
  126. $this->data->os->reset([
  127. 'name' => 'webOS',
  128. 'hidden' => true
  129. ]);
  130. }
  131. if (preg_match('/webOS\.TV-([0-9]+)/u', $ua, $match)) {
  132. $this->data->device->manufacturer = 'LG';
  133. $this->data->device->series = 'webOS TV';
  134. $this->data->device->type = Constants\DeviceType::TELEVISION;
  135. $this->data->device->identified |= Constants\Id::MATCH_UA;
  136. if (preg_match('/LG Browser\/[0-9.]+\(LGE; ([^;]+);/u', $ua, $match)) {
  137. if (strtoupper(substr($match[1], 0, 5)) != 'WEBOS') {
  138. $this->data->device->model = $match[1];
  139. }
  140. }
  141. $this->data->os->reset([
  142. 'name' => 'webOS',
  143. 'hidden' => true
  144. ]);
  145. }
  146. if (preg_match('/PBRM\//u', $ua)) {
  147. $this->data->browser->name = "Pro:Centric";
  148. $this->data->browser->version = null;
  149. $this->data->device->manufacturer = 'LG';
  150. $this->data->device->series = 'webOS TV';
  151. $this->data->device->type = Constants\DeviceType::TELEVISION;
  152. $this->data->device->identified |= Constants\Id::MATCH_UA;
  153. if (preg_match('/PBRM\/[0-9.]+ \( ;LGE ;([^;]+) ;/u', $ua, $match)) {
  154. if (strtoupper(substr($match[1], 0, 5)) != 'WEBOS') {
  155. $this->data->device->model = $match[1];
  156. }
  157. }
  158. $this->data->os->reset([
  159. 'name' => 'webOS',
  160. 'hidden' => true
  161. ]);
  162. }
  163. }
  164. /* Philips */
  165. private function detectPhilipsTelevision($ua)
  166. {
  167. if (preg_match('/NETTV\//u', $ua)) {
  168. $this->data->device->manufacturer = 'Philips';
  169. $this->data->device->series = 'Net TV';
  170. $this->data->device->type = Constants\DeviceType::TELEVISION;
  171. $this->data->device->identified |= Constants\Id::MATCH_UA;
  172. if (preg_match('/AquosTV/u', $ua)) {
  173. $this->data->device->manufacturer = 'Sharp';
  174. $this->data->device->series = 'Aquos TV';
  175. }
  176. if (preg_match('/BANGOLUFSEN/u', $ua)) {
  177. $this->data->device->manufacturer = 'Bang & Olufsen';
  178. $this->data->device->series = 'Smart TV';
  179. }
  180. if (preg_match('/PHILIPS-AVM/u', $ua)) {
  181. $this->data->device->series = 'Blu-ray Player';
  182. }
  183. }
  184. if (preg_match('/PHILIPS_OLS_20[0-9]+/u', $ua)) {
  185. $this->data->device->manufacturer = 'Philips';
  186. $this->data->device->series = 'Net TV';
  187. $this->data->device->type = Constants\DeviceType::TELEVISION;
  188. $this->data->device->identified |= Constants\Id::MATCH_UA;
  189. }
  190. }
  191. /* Sony */
  192. private function detectSonyTelevision($ua)
  193. {
  194. if (preg_match('/SonyCEBrowser/u', $ua)) {
  195. $this->data->device->manufacturer = 'Sony';
  196. $this->data->device->series = 'Smart TV';
  197. $this->data->device->type = Constants\DeviceType::TELEVISION;
  198. $this->data->device->identified |= Constants\Id::MATCH_UA;
  199. if (preg_match('/SonyCEBrowser\/[0-9.]+ \((?:BDPlayer; |DTV[0-9]+\/)?([^;_]+)/u', $ua, $match)) {
  200. if ($match[1] != 'ModelName') {
  201. $this->data->device->model = $match[1];
  202. }
  203. }
  204. }
  205. if (preg_match('/SonyDTV/u', $ua)) {
  206. $this->data->device->manufacturer = 'Sony';
  207. $this->data->device->series = 'Smart TV';
  208. $this->data->device->type = Constants\DeviceType::TELEVISION;
  209. $this->data->device->identified |= Constants\Id::MATCH_UA;
  210. if (preg_match('/(KDL-?[0-9]+[A-Z]+[0-9]+)/u', $ua, $match)) {
  211. $this->data->device->model = $match[1];
  212. $this->data->device->generic = false;
  213. }
  214. if (preg_match('/(XBR-?[0-9]+[A-Z]+[0-9]+)/u', $ua, $match)) {
  215. $this->data->device->model = $match[1];
  216. $this->data->device->generic = false;
  217. }
  218. }
  219. if (preg_match('/SonyBDP/u', $ua)) {
  220. $this->data->device->manufacturer = 'Sony';
  221. $this->data->device->series = "Blu-ray Player";
  222. $this->data->device->type = Constants\DeviceType::TELEVISION;
  223. $this->data->device->identified |= Constants\Id::MATCH_UA;
  224. }
  225. if (preg_match('/SmartBD/u', $ua) && preg_match('/(BDP-[A-Z][0-9]+)/u', $ua, $match)) {
  226. $this->data->device->manufacturer = 'Sony';
  227. $this->data->device->model = $match[1];
  228. $this->data->device->series = 'Blu-ray Player';
  229. $this->data->device->type = Constants\DeviceType::TELEVISION;
  230. $this->data->device->identified |= Constants\Id::MATCH_UA;
  231. }
  232. if (preg_match('/\s+([0-9]+)BRAVIA/u', $ua, $match)) {
  233. $this->data->device->manufacturer = 'Sony';
  234. $this->data->device->model = 'Bravia';
  235. $this->data->device->series = 'Smart TV';
  236. $this->data->device->type = Constants\DeviceType::TELEVISION;
  237. $this->data->device->identified |= Constants\Id::MATCH_UA;
  238. }
  239. }
  240. /* Samsung */
  241. private function detectSamsungTelevision($ua)
  242. {
  243. if (preg_match('/(SMART-TV|SmartHub)/u', $ua)) {
  244. $this->data->device->manufacturer = 'Samsung';
  245. $this->data->device->series = 'Smart TV';
  246. $this->data->device->type = Constants\DeviceType::TELEVISION;
  247. $this->data->device->identified |= Constants\Id::MATCH_UA;
  248. if (preg_match('/Linux\/SmartTV\+([0-9]*)/u', $ua, $match)) {
  249. $this->data->device->series = 'Smart TV ' . $match[1];
  250. } elseif (preg_match('/Maple([0-9]*)/u', $ua, $match)) {
  251. $this->data->device->series = 'Smart TV ' . $match[1];
  252. }
  253. }
  254. if (preg_match('/Maple_?([0-9][0-9][0-9][0-9])/u', $ua, $match)) {
  255. $this->data->device->manufacturer = 'Samsung';
  256. $this->data->device->series = 'Smart TV ' . $match[1];
  257. $this->data->device->type = Constants\DeviceType::TELEVISION;
  258. $this->data->device->identified |= Constants\Id::MATCH_UA;
  259. if (preg_match('/Linux\/(?:SmartTV)?\+([0-9]{4,4})/u', $ua, $match)) {
  260. $this->data->device->series = 'Smart TV ' . $match[1];
  261. }
  262. }
  263. if (preg_match('/Maple ([0-9]+\.[0-9]+)\.[0-9]+/u', $ua, $match)) {
  264. $this->data->device->manufacturer = 'Samsung';
  265. $this->data->device->series = 'Smart TV';
  266. $this->data->device->type = Constants\DeviceType::TELEVISION;
  267. $this->data->device->identified |= Constants\Id::MATCH_UA;
  268. switch ($match[1]) {
  269. case '5.0':
  270. $this->data->device->series = 'Smart TV 2009';
  271. break;
  272. case '5.1':
  273. $this->data->device->series = 'Smart TV 2010';
  274. break;
  275. case '6.0':
  276. $this->data->device->series = 'Smart TV 2011';
  277. break;
  278. }
  279. }
  280. if (preg_match('/Model\/Samsung-(BD-[A-Z][0-9]+)/u', $ua, $match)) {
  281. $this->data->device->manufacturer = 'Samsung';
  282. $this->data->device->model = $match[1];
  283. $this->data->device->series = 'Blu-ray Player';
  284. $this->data->device->type = Constants\DeviceType::TELEVISION;
  285. $this->data->device->identified |= Constants\Id::MATCH_UA;
  286. }
  287. if (preg_match('/olleh tv;/u', $ua)) {
  288. $this->data->device->manufacturer = 'Samsung';
  289. $this->data->device->model = null;
  290. $this->data->device->series = null;
  291. $this->data->device->type = Constants\DeviceType::TELEVISION;
  292. $this->data->device->identified |= Constants\Id::MATCH_UA;
  293. if (preg_match('/(SMT-[A-Z0-9]+)/u', $ua, $match)) {
  294. $this->data->device->model = $match[1];
  295. $this->data->device->identifier = $match[1];
  296. $this->data->device->generic = false;
  297. }
  298. if ($this->data->device->model == "SMT-E5015") {
  299. $this->data->device->model = 'Olleh SkyLife Smart Settopbox';
  300. }
  301. }
  302. }
  303. /* Sanyo */
  304. private function detectSanyoTelevision($ua)
  305. {
  306. if (preg_match('/Aplix_SANYO_browser/u', $ua)) {
  307. $this->data->device->manufacturer = 'Sanyo';
  308. $this->data->device->series = 'Internet TV';
  309. $this->data->device->type = Constants\DeviceType::TELEVISION;
  310. $this->data->device->identified |= Constants\Id::MATCH_UA;
  311. }
  312. }
  313. /* Sharp */
  314. private function detectSharpTelevision($ua)
  315. {
  316. if (preg_match('/(AQUOSBrowser|AQUOS-(AS|DMP))/u', $ua)) {
  317. $this->data->device->manufacturer = 'Sharp';
  318. $this->data->device->series = 'Aquos TV';
  319. $this->data->device->type = Constants\DeviceType::TELEVISION;
  320. $this->data->device->identified |= Constants\Id::MATCH_UA;
  321. if (preg_match('/LC\-([0-9]+[A-Z]+[0-9]+[A-Z]+)/u', $ua, $match)) {
  322. $this->data->device->model = $match[1];
  323. $this->data->device->generic = false;
  324. }
  325. }
  326. }
  327. /* Panasonic */
  328. private function detectPanasonicTelevision($ua)
  329. {
  330. if (preg_match('/Viera/u', $ua)) {
  331. $this->data->device->manufacturer = 'Panasonic';
  332. $this->data->device->series = 'Viera';
  333. $this->data->device->type = Constants\DeviceType::TELEVISION;
  334. $this->data->device->identified |= Constants\Id::MATCH_UA;
  335. if (preg_match('/Panasonic\.tv\.(?:mid\.)?([0-9]+)/u', $ua, $match)) {
  336. $this->data->device->series = 'Viera ' . $match[1];
  337. }
  338. if (preg_match('/\(Panasonic, ([0-9]+),/u', $ua, $match)) {
  339. $this->data->device->series = 'Viera ' . $match[1];
  340. }
  341. if (preg_match('/Viera\; rv\:34/u', $ua, $match)) {
  342. $this->data->device->series = 'Viera 2015';
  343. }
  344. }
  345. if (preg_match('/; Diga;/u', $ua)) {
  346. $this->data->device->manufacturer = 'Panasonic';
  347. $this->data->device->series = 'Diga';
  348. $this->data->device->type = Constants\DeviceType::TELEVISION;
  349. $this->data->device->identified |= Constants\Id::MATCH_UA;
  350. }
  351. }
  352. /* Various set top boxes */
  353. private function detectSettopboxes($ua)
  354. {
  355. if (!preg_match('/(lacleTV|LOEWE|KreaTV|ADB|Mstar|TechniSat|Technicolor|Highway|CiscoBrowser|Sunniwell|Enseo|LocationFreeTV|Winbox|DuneHD|Roku|AppleTV|Apple TV|WebTV|OpenTV|MediStream)/ui', $ua)) {
  356. return;
  357. }
  358. /* Orange La clé TV */
  359. if (preg_match('/lacleTV\//u', $ua)) {
  360. $this->data->device->manufacturer = 'Orange';
  361. $this->data->device->series = 'La clé TV';
  362. $this->data->device->type = Constants\DeviceType::TELEVISION;
  363. $this->data->device->identified |= Constants\Id::MATCH_UA;
  364. }
  365. /* Loewe */
  366. if (preg_match('/LOEWE\/TV/u', $ua)) {
  367. $this->data->device->manufacturer = 'Loewe';
  368. $this->data->device->series = 'Smart TV';
  369. $this->data->device->type = Constants\DeviceType::TELEVISION;
  370. $this->data->device->identified |= Constants\Id::MATCH_UA;
  371. if (preg_match('/((?:SL|ID)[0-9]+)/u', $ua, $match)) {
  372. $this->data->device->model = $match[1];
  373. }
  374. }
  375. /* KreaTV */
  376. if (preg_match('/KreaTV/u', $ua)) {
  377. $this->data->os->reset();
  378. $this->data->device->series = 'KreaTV';
  379. $this->data->device->type = Constants\DeviceType::TELEVISION;
  380. $this->data->device->identified |= Constants\Id::MATCH_UA;
  381. $this->data->device->generic = false;
  382. if (preg_match('/Motorola/u', $ua)) {
  383. $this->data->device->manufacturer = 'Motorola';
  384. }
  385. }
  386. /* ADB */
  387. if (preg_match('/\(ADB; ([^\)]+)\)/u', $ua, $match)) {
  388. $this->data->os->reset();
  389. $this->data->device->manufacturer = 'ADB';
  390. $this->data->device->model = ($match[1] != 'Unknown' ? str_replace('ADB', '', $match[1]) . ' ' : '') . 'IPTV receiver';
  391. $this->data->device->type = Constants\DeviceType::TELEVISION;
  392. $this->data->device->identified |= Constants\Id::MATCH_UA;
  393. $this->data->device->generic = false;
  394. }
  395. /* MStar */
  396. if (preg_match('/Mstar;/u', $ua)) {
  397. $this->data->os->reset();
  398. $this->data->device->manufacturer = 'MStar';
  399. $this->data->device->model = 'PVR';
  400. $this->data->device->type = Constants\DeviceType::TELEVISION;
  401. $this->data->device->identified |= Constants\Id::MATCH_UA;
  402. }
  403. /* TechniSat */
  404. if (preg_match('/TechniSat ([^;]+);/u', $ua, $match)) {
  405. $this->data->os->reset();
  406. $this->data->device->manufacturer = 'TechniSat';
  407. $this->data->device->model = $match[1];
  408. $this->data->device->type = Constants\DeviceType::TELEVISION;
  409. $this->data->device->identified |= Constants\Id::MATCH_UA;
  410. $this->data->device->generic = false;
  411. }
  412. /* Technicolor */
  413. if (preg_match('/Technicolor_([^;]+);/u', $ua, $match)) {
  414. $this->data->os->reset();
  415. $this->data->device->manufacturer = 'Technicolor';
  416. $this->data->device->model = $match[1];
  417. $this->data->device->type = Constants\DeviceType::TELEVISION;
  418. $this->data->device->identified |= Constants\Id::MATCH_UA;
  419. $this->data->device->generic = false;
  420. }
  421. /* Cisco MediaHighway */
  422. if (preg_match('/(Media-Highway Evolution|CiscoBrowser\/CI)/u', $ua, $match)) {
  423. $this->data->os->reset();
  424. $this->data->device->manufacturer = 'Cisco';
  425. $this->data->device->model = 'MediaHighway';
  426. $this->data->device->type = Constants\DeviceType::TELEVISION;
  427. $this->data->device->identified |= Constants\Id::MATCH_UA;
  428. $this->data->device->generic = false;
  429. }
  430. /* Sunniwell */
  431. if (preg_match('/Sunniwell/u', $ua) && preg_match('/Resolution/u', $ua)) {
  432. $this->data->os->reset();
  433. $this->data->device->manufacturer = 'Sunniwell';
  434. $this->data->device->series = 'STB';
  435. $this->data->device->type = Constants\DeviceType::TELEVISION;
  436. $this->data->device->identified |= Constants\Id::MATCH_UA;
  437. $this->data->device->generic = false;
  438. }
  439. /* Enseo */
  440. if (preg_match('/Enseo\/([A-Z0-9]+)/u', $ua, $match)) {
  441. $this->data->os->reset();
  442. $this->data->device->manufacturer = 'Enseo';
  443. $this->data->device->model = $match[1];
  444. $this->data->device->series = 'STB';
  445. $this->data->device->type = Constants\DeviceType::TELEVISION;
  446. $this->data->device->identified |= Constants\Id::MATCH_UA;
  447. $this->data->device->generic = false;
  448. }
  449. /* Sony LocationFreeTV */
  450. if (preg_match('/LocationFreeTV\/([A-Z0-9\-]+)/u', $ua, $match)) {
  451. $this->data->os->reset();
  452. $this->data->device->manufacturer = 'Sony';
  453. $this->data->device->model = 'LocationFreeTV ' . $match[1];
  454. $this->data->device->type = Constants\DeviceType::TELEVISION;
  455. $this->data->device->identified |= Constants\Id::MATCH_UA;
  456. $this->data->device->generic = false;
  457. }
  458. /* Winbox Evo2 */
  459. if (preg_match('/Winbox Evo2/u', $ua)) {
  460. $this->data->os->reset();
  461. $this->data->device->manufacturer = 'Winbox';
  462. $this->data->device->model = 'Evo2';
  463. $this->data->device->type = Constants\DeviceType::TELEVISION;
  464. $this->data->device->identified |= Constants\Id::MATCH_UA;
  465. $this->data->device->generic = false;
  466. }
  467. /* DuneHD */
  468. if (preg_match('/DuneHD\//u', $ua)) {
  469. $this->data->os->reset();
  470. $this->data->device->manufacturer = 'Dune HD';
  471. $this->data->device->model = '';
  472. $this->data->device->type = Constants\DeviceType::TELEVISION;
  473. $this->data->device->identified |= Constants\Id::MATCH_UA;
  474. if (preg_match('/DuneHD\/[0-9.]+ \(([^;]+);/u', $ua, $match)) {
  475. $this->data->device->model = $match[1];
  476. }
  477. }
  478. /* Roku */
  479. if (preg_match('/^Roku\/DVP-(?:[0-9A-Z]+-)?[0-9\.]+ \(([0-9]{2,2})/u', $ua, $match)) {
  480. $this->data->os->reset();
  481. $this->data->device->manufacturer = 'Roku';
  482. $this->data->device->type = Constants\DeviceType::TELEVISION;
  483. switch ($match[1]) {
  484. case '02':
  485. $this->data->device->model = '2 XS';
  486. $this->data->device->generic = false;
  487. break;
  488. case '04':
  489. $this->data->device->model = '3';
  490. $this->data->device->generic = false;
  491. break;
  492. case '07':
  493. $this->data->device->model = 'LT';
  494. $this->data->device->generic = false;
  495. break;
  496. case '09':
  497. $this->data->device->model = 'Streaming Stick';
  498. $this->data->device->generic = false;
  499. break;
  500. }
  501. $this->data->device->identified |= Constants\Id::MATCH_UA;
  502. }
  503. if (preg_match('/\(Roku/u', $ua)) {
  504. $this->data->device->manufacturer = 'Roku';
  505. $this->data->device->model = '';
  506. $this->data->device->type = Constants\DeviceType::TELEVISION;
  507. $this->data->device->identified |= Constants\Id::MATCH_UA;
  508. }
  509. /* AppleTV */
  510. if (preg_match('/Apple ?TV/u', $ua)) {
  511. $this->data->os->reset();
  512. $this->data->device->manufacturer = 'Apple';
  513. $this->data->device->model = 'AppleTV';
  514. $this->data->device->type = Constants\DeviceType::TELEVISION;
  515. $this->data->device->identified |= Constants\Id::MATCH_UA;
  516. $this->data->device->generic = false;
  517. }
  518. /* WebTV */
  519. if (preg_match('/WebTV\/[0-9.]/u', $ua)) {
  520. $this->data->os->reset();
  521. $this->data->device->manufacturer = 'Microsoft';
  522. $this->data->device->model = 'WebTV';
  523. $this->data->device->type = Constants\DeviceType::TELEVISION;
  524. $this->data->device->identified |= Constants\Id::MATCH_UA;
  525. $this->data->device->generic = false;
  526. }
  527. /* MediStream */
  528. if (preg_match('/MediStream/u', $ua)) {
  529. $this->data->os->reset();
  530. $this->data->device->manufacturer = 'Bewatec';
  531. $this->data->device->model = 'MediStream';
  532. $this->data->device->type = Constants\DeviceType::TELEVISION;
  533. $this->data->device->identified |= Constants\Id::MATCH_UA;
  534. $this->data->device->generic = false;
  535. }
  536. }
  537. /* Generic model information */
  538. private function detectGenericTelevisionModels($ua)
  539. {
  540. if (preg_match('/\(([^,\(]+),\s*([^,\(]+),\s*(?:[Ww]ired|[Ww]ireless)\)/u', $ua, $match)) {
  541. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  542. $modelName = trim($match[2]);
  543. $this->data->device->type = Constants\DeviceType::TELEVISION;
  544. $this->data->device->identified |= Constants\Id::PATTERN;
  545. if (!isset($this->data->device->series)) {
  546. $this->data->device->series = 'Smart TV';
  547. }
  548. switch ($vendorName) {
  549. case 'ARRIS':
  550. $this->data->device->manufacturer = 'Arris';
  551. $this->data->device->model = $modelName;
  552. break;
  553. case 'LG':
  554. $this->data->device->manufacturer = 'LG';
  555. switch ($modelName) {
  556. case 'WEBOS1':
  557. case 'webOS.TV':
  558. $this->data->device->series = 'webOS TV';
  559. break;
  560. case 'NETCAST4':
  561. case 'NetCast4.0':
  562. case 'GLOBAL-PLAT4':
  563. $this->data->device->series = 'NetCast TV 2013';
  564. break;
  565. default:
  566. $this->data->device->model = $modelName;
  567. break;
  568. }
  569. break;
  570. case 'Google Fiber':
  571. $this->data->device->manufacturer = $vendorName;
  572. $this->data->device->model = 'TV Box';
  573. break;
  574. case 'Sagemcom':
  575. $this->data->device->manufacturer = $vendorName;
  576. $this->data->device->series = 'Settopbox';
  577. if (preg_match('/^([A-Z]+[0-9]+)/ui', $modelName, $match)) {
  578. $this->data->device->model = $match[1];
  579. unset($this->data->device->series);
  580. }
  581. break;
  582. case 'TiVo':
  583. $this->data->device->manufacturer = 'TiVo';
  584. $this->data->device->series = 'DVR';
  585. break;
  586. default:
  587. $this->data->device->manufacturer = $vendorName;
  588. if (!in_array($modelName, [ 'dvb' ])) {
  589. $this->data->device->model = $modelName;
  590. }
  591. break;
  592. }
  593. }
  594. }
  595. /* InettvBrowser model information */
  596. private function detectGenericInettvBrowser($ua)
  597. {
  598. if (preg_match('/(?:DTVNetBrowser|InettvBrowser|Hybridcast)\/[0-9\.]+[A-Z]? ?\(/u', $ua, $match)) {
  599. $this->data->device->type = Constants\DeviceType::TELEVISION;
  600. $vendorName = null;
  601. $modelName = null;
  602. $found = false;
  603. if (preg_match('/(?:DTVNetBrowser|InettvBrowser)\/[0-9\.]+[A-Z]? ?\(([^;]*)\s*;\s*([^;]*)\s*;/u', $ua, $match)) {
  604. $vendorName = trim($match[1]);
  605. $modelName = trim($match[2]);
  606. $found = true;
  607. }
  608. if (preg_match('/Hybridcast\/[0-9\.]+ ?\([^;]*;([^;]*)\s*;\s*([^;]*)\s*;/u', $ua, $match)) {
  609. $vendorName = trim($match[1]);
  610. $modelName = trim($match[2]);
  611. $found = true;
  612. }
  613. if ($found) {
  614. $this->data->device->identified |= Constants\Id::PATTERN;
  615. $data = [
  616. '0003D5' => 'Advanced Communications',
  617. '000024' => 'Connect AS',
  618. '000087' => 'Hitachi',
  619. '00A0B0' => 'I-O Data Device',
  620. '00E091' => 'LG',
  621. '0050C9' => 'Maspro Denkoh',
  622. '002692' => 'Mitsubishi',
  623. '38E08E' => 'Mitsubishi',
  624. '008045' => 'Panasonic',
  625. '00E036' => 'Pioneer',
  626. '00E064' => 'Samsung',
  627. '08001F' => 'Sharp',
  628. '00014A' => 'Sony',
  629. '000039' => 'Toshiba'
  630. ];
  631. if (isset($data[$vendorName])) {
  632. $this->data->device->manufacturer = $data[$vendorName];
  633. if ($this->data->device->manufacturer == 'LG') {
  634. switch ($modelName) {
  635. case 'LGE2D2012M':
  636. $this->data->device->series = 'NetCast TV 2012';
  637. break;
  638. case 'LGE3D2012M':
  639. $this->data->device->series = 'NetCast TV 2012';
  640. break;
  641. case 'LGwebOSTV':
  642. $this->data->device->series = 'webOS TV';
  643. break;
  644. }
  645. }
  646. if ($this->data->device->manufacturer == 'Panasonic') {
  647. if (substr($modelName, 0, 6) != 'PANATV') {
  648. $this->data->device->model = $modelName;
  649. }
  650. }
  651. }
  652. if (!isset($this->data->device->series)) {
  653. $this->data->device->series = 'Smart TV';
  654. }
  655. }
  656. }
  657. }
  658. /* HbbTV model information */
  659. private function detectGenericHbbTV($ua)
  660. {
  661. if (preg_match('/((HbbTV|OHTV|SmartTV)\/[0-9\.]+|CE-HTML)/iu', $ua)) {
  662. $this->data->device->type = Constants\DeviceType::TELEVISION;
  663. $vendorName = null;
  664. $modelName = null;
  665. $found = false;
  666. if (preg_match('/HbbTV\/[0-9\.]+;CE-HTML\/[0-9\.]+;([A-Z]+)\s([^;]+);/iu', $ua, $match)) {
  667. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  668. $modelName = trim($match[2]);
  669. $found = true;
  670. }
  671. if (preg_match('/UID\([a-f0-9:]+\/([^\/]+)\/([^\/]+)\/[0-9a-z\.]+\)\+CE-HTML/iu', $ua, $match)) {
  672. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[2]);
  673. $modelName = trim($match[1]);
  674. $found = true;
  675. }
  676. if (preg_match('/(?:HbbTV|OHTV)\/[0-9\.]+ \(([^;]*);\s*([^;]*)\s*;\s*([^;]*)\s*;/u', $ua, $match)) {
  677. if (trim($match[1]) == "" || in_array(strtok($match[1], ' '), [ 'PVR', 'DL' ]) || strpos($match[1], '+') !== false) {
  678. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[2]);
  679. $modelName = trim($match[3]);
  680. } else {
  681. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  682. $modelName = trim($match[2]);
  683. }
  684. $found = true;
  685. }
  686. if (preg_match('/(?:^|\s)SmartTV\/[0-9\.]+ \(([^;]*)\s*;\s*([^;]*)\s*;/u', $ua, $match)) {
  687. $vendorName = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  688. $modelName = trim($match[2]);
  689. $found = true;
  690. }
  691. if (in_array($vendorName, [ 'Access', 'ANT', 'EMSYS', 'Em-Sys', 'Opera', 'Opera Software', 'Seraphic', 'Vendor' ])) {
  692. $found = false;
  693. }
  694. if ($found) {
  695. $this->data->device->identified |= Constants\Id::PATTERN;
  696. switch ($vendorName) {
  697. case 'LG':
  698. $this->data->device->manufacturer = 'LG';
  699. switch ($modelName) {
  700. case 'NetCast 3.0':
  701. case 'GLOBAL_PLAT3':
  702. $this->data->device->series = 'NetCast TV 2012';
  703. break;
  704. case 'NetCast 4.0':
  705. case 'GLOBAL-PLAT4':
  706. $this->data->device->series = 'NetCast TV 2013';
  707. break;
  708. case 'WEBOS3':
  709. $this->data->device->series = 'webOS TV';
  710. break;
  711. }
  712. break;
  713. case 'Samsung':
  714. $this->data->device->manufacturer = 'Samsung';
  715. switch ($modelName) {
  716. case 'SmartTV2012':
  717. $this->data->device->series = 'Smart TV 2012';
  718. break;
  719. case 'SmartTV2013':
  720. $this->data->device->series = 'Smart TV 2013';
  721. break;
  722. case 'SmartTV2014':
  723. $this->data->device->series = 'Smart TV 2014';
  724. break;
  725. case 'SmartTV2015':
  726. $this->data->device->series = 'Smart TV 2015';
  727. break;
  728. case 'OTV-SMT-E5015':
  729. $this->data->device->model = 'Olleh SkyLife Smart Settopbox';
  730. unset($this->data->device->series);
  731. break;
  732. }
  733. break;
  734. case 'Panasonic':
  735. $this->data->device->manufacturer = 'Panasonic';
  736. switch ($modelName) {
  737. case 'VIERA 2011':
  738. $this->data->device->series = 'Viera 2011';
  739. break;
  740. case 'VIERA 2012':
  741. $this->data->device->series = 'Viera 2012';
  742. break;
  743. case 'VIERA 2013':
  744. $this->data->device->series = 'Viera 2013';
  745. break;
  746. case 'VIERA 2014':
  747. $this->data->device->series = 'Viera 2014';
  748. break;
  749. case 'VIERA 2015':
  750. case 'Viera2015.mid':
  751. $this->data->device->series = 'Viera 2015';
  752. break;
  753. default:
  754. $this->data->device->model = $modelName;
  755. break;
  756. }
  757. break;
  758. case 'TV2N':
  759. $this->data->device->manufacturer = 'TV2N';
  760. switch ($modelName) {
  761. case 'videoweb':
  762. $this->data->device->model = 'Videoweb';
  763. break;
  764. }
  765. break;
  766. default:
  767. if ($vendorName != '' && !in_array($vendorName, [ 'OEM', 'vendorName' ])) {
  768. $this->data->device->manufacturer = $vendorName;
  769. }
  770. if ($modelName != '' && !in_array($modelName, [ 'dvb', 'modelName', 'undefined-model-name', 'N/A' ])) {
  771. $this->data->device->model = $modelName;
  772. }
  773. break;
  774. }
  775. switch ($modelName) {
  776. case 'hdr1000s':
  777. $this->data->device->manufacturer = 'Humax';
  778. $this->data->device->model = 'HDR-1000S';
  779. $this->data->device->identified |= Constants\Id::MATCH_UA;
  780. $this->data->device->generic = false;
  781. break;
  782. case 'hdr4000t':
  783. $this->data->device->manufacturer = 'Humax';
  784. $this->data->device->model = 'HDR-4000T';
  785. $this->data->device->identified |= Constants\Id::MATCH_UA;
  786. $this->data->device->generic = false;
  787. break;
  788. case 'hgs1000s':
  789. $this->data->device->manufacturer = 'Humax';
  790. $this->data->device->model = 'HGS-1000S';
  791. $this->data->device->identified |= Constants\Id::MATCH_UA;
  792. $this->data->device->generic = false;
  793. break;
  794. case 'hms1000s':
  795. case 'hms1000sph2':
  796. $this->data->device->manufacturer = 'Humax';
  797. $this->data->device->model = 'HMS-1000S';
  798. $this->data->device->identified |= Constants\Id::MATCH_UA;
  799. $this->data->device->generic = false;
  800. break;
  801. }
  802. }
  803. }
  804. if (preg_match('/HbbTV\/[0-9.]+;CE-HTML\/[0-9.]+;([^\s;]+)\s[^\s;]+;/u', $ua, $match)) {
  805. $this->data->device->manufacturer = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  806. if (!isset($this->data->device->series)) {
  807. $this->data->device->series = 'Smart TV';
  808. }
  809. }
  810. if (preg_match('/HbbTV\/[0-9.]+;CE-HTML\/[0-9.]+;Vendor\/([^\s;]+);/u', $ua, $match)) {
  811. $this->data->device->manufacturer = Data\Manufacturers::identify(Constants\DeviceType::TELEVISION, $match[1]);
  812. if (!isset($this->data->device->series)) {
  813. $this->data->device->series = 'Smart TV';
  814. }
  815. }
  816. }
  817. /* Try to reformat some of the detected generic models */
  818. private function improveModelsOnDeviceTypeTelevision()
  819. {
  820. if ($this->data->device->type != Constants\DeviceType::TELEVISION) {
  821. return;
  822. }
  823. if (isset($this->data->device->model) && isset($this->data->device->manufacturer)) {
  824. if ($this->data->device->manufacturer == 'Dune HD') {
  825. if (preg_match('/tv([0-9]+[a-z]?)/u', $this->data->device->model, $match)) {
  826. $this->data->device->model = 'TV-' . strtoupper($match[1]);
  827. }
  828. if ($this->data->device->model == 'connect') {
  829. $this->data->device->model = 'Connect';
  830. }
  831. }
  832. if ($this->data->device->manufacturer == 'Humax') {
  833. $this->data->device->series = "Digital Receiver";
  834. }
  835. if ($this->data->device->manufacturer == 'Inverto') {
  836. if (preg_match('/IDL[ -]?([0-9]+.*)/u', $this->data->device->model, $match)) {
  837. $this->data->device->model = 'IDL ' . $match[1];
  838. }
  839. if (preg_match('/MBN([0-9]+)/u', $this->data->device->model, $match)) {
  840. $this->data->device->model = 'MBN ' . $match[1];
  841. }
  842. }
  843. if ($this->data->device->manufacturer == 'HyperPanel') {
  844. $this->data->device->model = strtok(strtoupper($this->data->device->model), ' ');
  845. }
  846. if ($this->data->device->manufacturer == 'LG') {
  847. if (preg_match('/(?:ATSC|DVB)-(.*)/u', $this->data->device->model, $match)) {
  848. $this->data->device->model = $match[1];
  849. $this->data->device->generic = false;
  850. }
  851. if (preg_match('/[0-9][0-9]([A-Z][A-Z][0-9][0-9][0-9][0-9A-Z])/u', $this->data->device->model, $match)) {
  852. $this->data->device->model = $match[1];
  853. $this->data->device->generic = false;
  854. }
  855. if (preg_match('/Media\/(.*)/u', $this->data->device->model, $match)) {
  856. $this->data->device->model = $match[1];
  857. $this->data->device->generic = false;
  858. }
  859. }
  860. if ($this->data->device->manufacturer == 'Loewe') {
  861. $this->data->device->series = 'Smart TV';
  862. if (preg_match('/((?:ID|SL)[0-9]+)/u', $this->data->device->model, $match)) {
  863. $this->data->device->model = 'Connect '. $match[1];
  864. $this->data->device->generic = false;
  865. }
  866. }
  867. if ($this->data->device->manufacturer == 'Philips') {
  868. if (preg_match('/[0-9][0-9]([A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9])/u', $this->data->device->model, $match)) {
  869. $this->data->device->model = $match[1];
  870. $this->data->device->generic = false;
  871. }
  872. if (preg_match('/(MT[0-9]+)/u', $this->data->device->model, $match)) {
  873. $this->data->device->model = $match[1];
  874. $this->data->device->series = "Digital Receiver";
  875. $this->data->device->generic = false;
  876. }
  877. if (preg_match('/(BDP[0-9]+)/u', $this->data->device->model, $match)) {
  878. $this->data->device->model = $match[1];
  879. $this->data->device->series = "Blu-ray Player";
  880. $this->data->device->generic = false;
  881. }
  882. }
  883. if ($this->data->device->manufacturer == 'Toshiba') {
  884. if (preg_match('/DTV_(.*)/u', $this->data->device->model, $match)) {
  885. $this->data->device->model = 'Regza ' . $match[1];
  886. $this->data->device->generic = false;
  887. }
  888. if (preg_match('/[0-9][0-9]([A-Z][A-Z][0-9][0-9][0-9])/u', $this->data->device->model, $match)) {
  889. $this->data->device->model = 'Regza ' . $match[1];
  890. $this->data->device->generic = false;
  891. }
  892. if (preg_match('/[0-9][0-9](ZL[0-9])/u', $this->data->device->model, $match)) {
  893. $this->data->device->model = $match[1] . ' Cevo';
  894. $this->data->device->generic = false;
  895. }
  896. if (preg_match('/(BDX[0-9]+)/u', $this->data->device->model, $match)) {
  897. $this->data->device->model = $match[1];
  898. $this->data->device->series = "Blu-ray Player";
  899. $this->data->device->generic = false;
  900. }
  901. }
  902. if ($this->data->device->manufacturer == 'Selevision') {
  903. $this->data->device->model = str_replace('Selevision ', '', $this->data->device->model);
  904. }
  905. if ($this->data->device->manufacturer == 'Sharp') {
  906. if (preg_match('/[0-9][0-9]([A-Z]+[0-9]+[A-Z]+)/u', $this->data->device->model, $match)) {
  907. $this->data->device->model = $match[1];
  908. $this->data->device->generic = false;
  909. }
  910. }
  911. if ($this->data->device->manufacturer == 'Sony') {
  912. if (preg_match('/(BDP[0-9]+G)/u', $this->data->device->model, $match)) {
  913. $this->data->device->model = $match[1];
  914. $this->data->device->series = "Blu-ray Player";
  915. $this->data->device->generic = false;
  916. }
  917. if (preg_match('/KDL?-?[0-9]*([A-Z]+[0-9]+)[A-Z]*/u', $this->data->device->model, $match)) {
  918. $this->data->device->model = 'Bravia ' . $match[1];
  919. $this->data->device->series = 'Smart TV';
  920. $this->data->device->generic = false;
  921. }
  922. }
  923. if ($this->data->device->manufacturer == 'Pioneer') {
  924. if (preg_match('/(BDP-[0-9]+)/u', $this->data->device->model, $match)) {
  925. $this->data->device->model = $match[1];
  926. $this->data->device->series = "Blu-ray Player";
  927. $this->data->device->generic = false;
  928. }
  929. }
  930. }
  931. }
  932. }