Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create new parser ShellTv and Detect new brands: Elekta, Loview, Yuno, YASIN, AMCV, ECON, Erisson, Leben, Novex, Starwind, Vargo, Gooweel and Detect devices for existing brands: Leagoo, CUBOT, Ginzzu, Ulefone, ZTE, Alcatel, Quantum, Ark, BB Mobile #6776

Merged
merged 17 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Parser/Device/AbstractDeviceParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'AW' => 'Aiwa',
'85' => 'Aiuto',
'AK' => 'Akai',
'Q3' => 'AKIRA',
'1A' => 'Alba',
'AL' => 'Alcatel',
'20' => 'Alcor',
Expand All @@ -123,6 +124,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'AG' => 'AMGOO',
'9A' => 'Amigoo',
'AO' => 'Amoi',
'54' => 'AMCV',
'60' => 'Andowl',
'7A' => 'Anry',
'A0' => 'ANS',
Expand Down Expand Up @@ -302,6 +304,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'EA' => 'EBEST',
'E4' => 'Echo Mobiles',
'ES' => 'ECS',
'35' => 'ECON',
'E6' => 'EE',
'EK' => 'EKO',
'EY' => 'Einstein',
Expand All @@ -313,13 +316,15 @@ abstract class AbstractDeviceParser extends AbstractParser
'L0' => 'Element',
'EG' => 'Elenberg',
'EL' => 'Elephone',
'JE' => 'Elekta',
'4E' => 'Eltex',
'ED' => 'Energizer',
'E1' => 'Energy Sistem',
'3E' => 'Enot',
'8E' => 'Epik One',
'E7' => 'Ergo',
'EC' => 'Ericsson',
'05' => 'Erisson',
'ER' => 'Ericy',
'EE' => 'Essential',
'E2' => 'Essentielb',
Expand Down Expand Up @@ -397,6 +402,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'G1' => 'GoMobile',
'GO' => 'Google',
'G0' => 'Goophone',
'6G' => 'Gooweel',
'GR' => 'Gradiente',
'GP' => 'Grape',
'G6' => 'Gree',
Expand All @@ -411,6 +417,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'H6' => 'Helio',
'ZH' => 'Hezire',
'HL' => 'Hi-Level',
'3H' => 'Hi',
'H2' => 'Highscreen',
'Q1' => 'High Q',
'1H' => 'Hipstreet',
Expand Down Expand Up @@ -521,6 +528,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'KI' => 'Kingsun',
'KF' => 'KINGZONE',
'KV' => 'Kivi',
'64' => 'Kvant',
'0K' => 'Klipad',
'KC' => 'Kocaso',
'KK' => 'Kodak',
Expand Down Expand Up @@ -554,6 +562,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'LV' => 'Lava',
'LC' => 'LCT',
'L5' => 'Leagoo',
'U3' => 'Leben',
'LD' => 'Ledstar',
'L1' => 'LeEco',
'4B' => 'Leff',
Expand Down Expand Up @@ -696,6 +705,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'7N' => 'NorthTech',
'5N' => 'Nos',
'NO' => 'Nous',
'NQ' => 'Novex',
'NJ' => 'NuAns',
'NL' => 'NUU Mobile',
'N0' => 'Nuvo',
Expand Down Expand Up @@ -892,6 +902,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'OL' => 'Starlight',
'18' => 'Starmobile',
'2S' => 'Starway',
'45' => 'Starwind',
'SB' => 'STF Mobile',
'S8' => 'STK',
'GQ' => 'STG Telecom',
Expand Down Expand Up @@ -1000,6 +1011,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'6U' => 'UTime',
'5V' => 'VAIO',
'VA' => 'Vastking',
'VP' => 'Vargo',
'VB' => 'VC',
'VN' => 'Venso',
'VQ' => 'Vega',
Expand Down
19 changes: 17 additions & 2 deletions Parser/Device/HbbTv.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class HbbTv extends AbstractDeviceParser
*/
public function parse(): ?array
{
// only parse user agents containing hbbtv fragment
if (null === $this->isHbbTv()) {
// only parse user agents containing fragments: hbbtv, shell
if (null === $this->isHbbTv() && false === $this->isShellTv()) {
return null;
}

Expand All @@ -51,6 +51,21 @@ public function parse(): ?array
return $this->getResult();
}

/**
* Returns if the parsed UA was identified as Shell Tv device
*
* @return bool
*
* @throws \Exception
*/
public function isShellTv(): bool
{
$regex = '[a-z]+[ _]Shell[ _]\w{6}';
$match = $this->matchUserAgent($regex);

return null !== $match;
}

/**
* Returns if the parsed UA was identified as a HbbTV device
*
Expand Down
6 changes: 6 additions & 0 deletions Tests/Parser/Device/HbbTvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ public function testIsHbbTv(): void
$hbbTvParser = new HbbTv();
$hbbTvParser->setUserAgent('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');
$this->assertEquals($hbbTvParser->isHbbTv(), '1.1.1');


$hbbTvParser->setUserAgent('Leff Shell LC390TA2A');
$this->assertEquals($hbbTvParser->isShellTv(), true);
$hbbTvParser->setUserAgent('Leff Shell');
$this->assertEquals($hbbTvParser->isShellTv(), false);
}
}
15 changes: 15 additions & 0 deletions Tests/fixtures/mobile_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1103,3 +1103,18 @@
model: P40 Lite
os_family: Android
browser_family: Unknown
- user_agent: Mozilla/5.0 (Linux; Android 8.1.0; NEOSR620 Build/O11019; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36 Instagram 88.0.0.14.99 Android (27/8.1.0; 320dpi; 720x1404; TeslaGroup/LUMUS; NEOSR620; NEOSR620; mt6739; ru_RU; 149350058)
os:
name: Android
version: 8.1.0
platform: ""
client:
type: mobile app
name: Instagram App
version: 88.0.0.14.99
device:
type: smartphone
brand: Lumus
model: Neo SR620
os_family: Android
browser_family: Unknown
18 changes: 18 additions & 0 deletions Tests/fixtures/phablet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6224,3 +6224,21 @@
model: Mode 1 RS
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 11; Note 11P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36
os:
name: Android
version: "11"
platform: ""
client:
type: browser
name: Chrome Mobile
version: 90.0.4430.91
engine: Blink
engine_version: ""
device:
type: phablet
brand: Ulefone
model: Note 11P
os_family: Android
browser_family: Chrome
18 changes: 0 additions & 18 deletions Tests/fixtures/smartphone-19.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3059,24 +3059,6 @@
model: Smart Box v009
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 4.4.4; Leff Shell HV320WHB-N55) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 YaBrowser/18.11.1.1011.01 Safari/537.36
os:
name: Android
version: 4.4.4
platform: ""
client:
type: browser
name: Yandex Browser
version: 18.11.1.1011.01
engine: Blink
engine_version: ""
device:
type: tv
brand: Leff
model: ""
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; arm; Android 10; KRJ-W09) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 YaApp_Android/20.94.0/apad YaSearchBrowser/20.94.0/apad BroPP/1.0 SA/3 Mobile Safari/537.36
os:
Expand Down
36 changes: 0 additions & 36 deletions Tests/fixtures/smartphone-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9744,42 +9744,6 @@
model: Hi9 Pro
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 8.0.0; LUMUS Shell PT430CT02-1 Build/OPR5.170623.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Safari/537.36
os:
name: Android
version: 8.0.0
platform: ""
client:
type: browser
name: Chrome Webview
version: 61.0.3163.98
engine: Blink
engine_version: ""
device:
type: tv
brand: Lumus
model: ""
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 8.0.0; LUMUS Shell LSC320AN10 Build/OPR5.170623.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Safari/537.36
os:
name: Android
version: 8.0.0
platform: ""
client:
type: browser
name: Chrome Webview
version: 61.0.3163.98
engine: Blink
engine_version: ""
device:
type: tv
brand: Lumus
model: ""
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 7.0; PH544) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36
os:
Expand Down
2 changes: 1 addition & 1 deletion Tests/fixtures/smartphone-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7482,7 +7482,7 @@
os:
name: Android
version: "11"
platform:
platform: ""
client:
type: browser
name: Chrome Webview
Expand Down
Loading