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 all 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
2 changes: 2 additions & 0 deletions DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use DeviceDetector\Parser\Device\Mobile;
use DeviceDetector\Parser\Device\Notebook;
use DeviceDetector\Parser\Device\PortableMediaPlayer;
use DeviceDetector\Parser\Device\ShellTv;
use DeviceDetector\Parser\OperatingSystem;
use DeviceDetector\Parser\VendorFragment;
use DeviceDetector\Yaml\ParserInterface as YamlParser;
Expand Down Expand Up @@ -198,6 +199,7 @@ public function __construct(string $userAgent = '')
$this->addClientParser(new Library());

$this->addDeviceParser(new HbbTv());
$this->addDeviceParser(new ShellTv());
$this->addDeviceParser(new Notebook());
$this->addDeviceParser(new Console());
$this->addDeviceParser(new CarBrowser());
Expand Down
15 changes: 15 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 @@ -303,6 +305,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'EA' => 'EBEST',
'E4' => 'Echo Mobiles',
'ES' => 'ECS',
'35' => 'ECON',
'E6' => 'EE',
'EK' => 'EKO',
'EY' => 'Einstein',
Expand All @@ -314,13 +317,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 @@ -399,6 +404,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'G1' => 'GoMobile',
'GO' => 'Google',
'G0' => 'Goophone',
'6G' => 'Gooweel',
'GR' => 'Gradiente',
'GP' => 'Grape',
'G6' => 'Gree',
Expand All @@ -413,6 +419,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 @@ -523,6 +530,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'KI' => 'Kingsun',
'KF' => 'KINGZONE',
'KV' => 'Kivi',
'64' => 'Kvant',
'0K' => 'Klipad',
'KC' => 'Kocaso',
'KK' => 'Kodak',
Expand Down Expand Up @@ -556,6 +564,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'LV' => 'Lava',
'LC' => 'LCT',
'L5' => 'Leagoo',
'U3' => 'Leben',
'LD' => 'Ledstar',
'L1' => 'LeEco',
'4B' => 'Leff',
Expand All @@ -575,6 +584,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'5L' => 'Linsar',
'LW' => 'Linnex',
'LO' => 'Loewe',
'YL' => 'Loview',
'1L' => 'Logic',
'LM' => 'Logicom',
'0L' => 'Lumigon',
Expand Down Expand Up @@ -698,6 +708,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 @@ -894,6 +905,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 @@ -1002,6 +1014,7 @@ abstract class AbstractDeviceParser extends AbstractParser
'6U' => 'UTime',
'5V' => 'VAIO',
'VA' => 'Vastking',
'VP' => 'Vargo',
'VB' => 'VC',
'VN' => 'Venso',
'VQ' => 'Vega',
Expand Down Expand Up @@ -1092,8 +1105,10 @@ abstract class AbstractDeviceParser extends AbstractParser
'YT' => 'Ytone',
'Y1' => 'Yu',
'Y0' => 'YUHO',
'YN' => 'Yuno',
'YU' => 'Yuandao',
'YS' => 'Yusun',
'YJ' => 'YASIN',
'YX' => 'Yxtel',
'0Z' => 'Zatec',
'2Z' => 'Zaith',
Expand Down
2 changes: 1 addition & 1 deletion Parser/Device/HbbTv.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HbbTv extends AbstractDeviceParser
*/
public function parse(): ?array
{
// only parse user agents containing hbbtv fragment
// only parse user agents containing fragments: hbbtv
if (null === $this->isHbbTv()) {
return null;
}
Expand Down
66 changes: 66 additions & 0 deletions Parser/Device/ShellTv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);

/**
* Device Detector - The Universal Device Detection library for parsing User Agents
*
* @link https://matomo.org
*
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Parser\Device;

/**
* Class ShellTv
*/
class ShellTv extends AbstractDeviceParser
{
/**
* @var string
*/
protected $fixtureFile = 'regexes/device/shell_tv.yml';

/**
* @var string
*/
protected $parserName = 'shelltv';

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

return null !== $match;
}

/**
* Parses the current UA and checks whether it contains ShellTv information
*
* @see shell_tv.yml for list of detected televisions
*
* @return array|null
*/
public function parse(): ?array
{
// only parse user agents containing fragments: {brand} shell
if (false === $this->isShellTv()) {
return null;
}

parent::parse();

// always set device type to tv, even if no model/brand could be found
$this->deviceType = self::DEVICE_TYPE_TV;

return $this->getResult();
}
}
2 changes: 1 addition & 1 deletion Tests/Parser/Device/CameraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Devices;
namespace DeviceDetector\Tests\Parser\Device;

use \Spyc;
use DeviceDetector\Parser\Device\Camera;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Device/CarBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Devices;
namespace DeviceDetector\Tests\Parser\Device;

use \Spyc;
use DeviceDetector\Parser\Device\CarBrowser;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Device/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Devices;
namespace DeviceDetector\Tests\Parser\Device;

use \Spyc;
use DeviceDetector\Parser\Device\Console;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Device/DeviceParserAbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Devices;
namespace DeviceDetector\Tests\Parser\Device;

use DeviceDetector\Parser\Device\AbstractDeviceParser;
use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Device/HbbTvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Devices;
namespace DeviceDetector\Tests\Parser\Device;

use DeviceDetector\Parser\Device\HbbTv;
use PHPUnit\Framework\TestCase;
Expand Down
28 changes: 28 additions & 0 deletions Tests/Parser/Device/ShellTvTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/**
* Device Detector - The Universal Device Detection library for parsing User Agents
*
* @link https://matomo.org
*
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/

namespace DeviceDetector\Tests\Parser\Device;

use DeviceDetector\Parser\Device\ShellTv;
use PHPUnit\Framework\TestCase;

class ShellTvTest extends TestCase
{
public function testIsShellTv(): void
{
$dd = new ShellTv();
$dd->setUserAgent('Leff Shell LC390TA2A');
$this->assertEquals($dd->isShellTv(), true);
$dd->setUserAgent('Leff Shell');
$this->assertEquals($dd->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