Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

woothee v1.12.1 #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/AgentCategory/Browser/SafariChrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public static function challenge($ua, &$result)
return true;
}

if (preg_match('@GSA/([.0-9]+)@', $ua, $matches)) {
$version = $matches[1];
static::updateMap($result, DataSet::get('GSA'));
static::updateVersion($result, $version);

return true;;
}

if (preg_match('/Version\/([.0-9]+)/uD', $ua, $matches)) {
$version = $matches[1];
}
Expand Down
27 changes: 27 additions & 0 deletions src/AgentCategory/Browser/SamsungBrowser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Woothee\AgentCategory\Browser;

use Woothee\AgentCategory\AbstractCategory;
use Woothee\DataSet;

class SamsungBrowser extends AbstractCategory
{
public static function challenge($ua, &$result)
{
if (strpos($ua, 'SamsungBrowser/') === false) {
return false;
}

$version = DataSet::VALUE_UNKNOWN;

if (preg_match('/SamsungBrowser\/([.0-9]+)/Du', $ua, $matches)) {
$version = $matches[1];
}

static::updateMap($result, DataSet::get('SamsungBrowser'));
static::updateVersion($result, $version);

return true;
}
}
12 changes: 12 additions & 0 deletions src/AgentCategory/Crawler/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public static function challenge($ua, &$result)
}
}

if (strpos($ua, 'compatible; AdsBot-Google-Mobile;') !== false) {
static::updateMap($result, DataSet::get('AdsBotGoogleMobile'));

return true;
}

if (strpos($ua, 'AdsBot-Google') === 0) {
static::updateMap($result, DataSet::get('AdsBotGoogle'));

return true;
}

if (strpos($ua, 'Googlebot-Image/') !== false) {
static::updateMap($result, DataSet::get('GoogleBot'));

Expand Down
5 changes: 5 additions & 0 deletions src/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Woothee\AgentCategory\Browser\Msie;
use Woothee\AgentCategory\Browser\Opera;
use Woothee\AgentCategory\Browser\SafariChrome;
use Woothee\AgentCategory\Browser\SamsungBrowser;
use Woothee\AgentCategory\Browser\Sleipnir;
use Woothee\AgentCategory\Browser\Vivaldi;
use Woothee\AgentCategory\Browser\Webview;
Expand Down Expand Up @@ -76,6 +77,10 @@ public function tryBrowser($ua, &$result)
return true;
}

if (SamsungBrowser::challenge($ua, $result)) {
return true;
}

if (SafariChrome::challenge($ua, $result)) {
return true;
}
Expand Down
26 changes: 25 additions & 1 deletion src/DataSet.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Woothee;

// GENERATED from dataset.yml at Sun Jul 22 02:46:33 JST 2018 by tell_k
// GENERATED from dataset.yml at Sat Sep 25 04:34:00 UTC 2021 by tadsan
class DataSet
{
const DATASET_KEY_LABEL = 'label';
Expand Down Expand Up @@ -100,6 +100,12 @@ class DataSet
'type' => 'browser',
'vendor' => 'Fenrir Inc.',
),
'GSA' => array(
'label' => 'GSA',
'name' => 'Google Search App',
'type' => 'browser',
'vendor' => 'Google',
),
'Webview' => array(
'label' => 'Webview',
'name' => 'Webview',
Expand All @@ -112,6 +118,12 @@ class DataSet
'type' => 'browser',
'vendor' => 'Yandex',
),
'SamsungBrowser' => array(
'label' => 'SamsungBrowser',
'name' => 'SamsungBrowser',
'type' => 'browser',
'vendor' => 'Samsung',
),
'Win' => array(
'label' => 'Win',
'name' => 'Windows UNKNOWN Ver',
Expand Down Expand Up @@ -634,6 +646,18 @@ class DataSet
'type' => 'full',
'category' => 'crawler',
),
'AdsBotGoogleMobile' => array(
'label' => 'AdsBotGoogleMobile',
'name' => 'AdsBot-Google-Mobile',
'type' => 'full',
'category' => 'crawler',
),
'AdsBotGoogle' => array(
'label' => 'AdsBotGoogle',
'name' => 'AdsBot-Google',
'type' => 'full',
'category' => 'crawler',
)
);

public static function get($label)
Expand Down