Skip to content

Commit

Permalink
Merge branch 'hotfix/0.4.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne-Lexa committed Aug 19, 2022
2 parents d8c1624 + db0a2a4 commit 9cc772c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/Scraper/AppInfoScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ public function __invoke(RequestInterface $request, ResponseInterface $response,
{
$scriptData = ScraperUtil::extractScriptData($response->getBody()->getContents());

$appInfo = ScraperUtil::getValue($scriptData, 'ds:4.1.2');
$appInfo = null;
$editorsChoice = false;

foreach ($scriptData as $data) {
if (isset($data[1][2][72][0][1])) {
$appInfo = $data[1][2];
} elseif (isset($data[1][2][136][0][1][0])) {
$editorsChoice = (bool) $data[1][2][136][0][1][0];
}
}

if (!\is_array($appInfo)) {
throw (new GooglePlayException('Unable to get data for this application.'))->setUrl(
$request->getUri()->__toString()
Expand Down Expand Up @@ -94,7 +104,6 @@ public function __invoke(RequestInterface $request, ResponseInterface $response,
$minAndroidVersion = null;
}

$editorsChoice = (bool) ScraperUtil::getValue($appInfo, 'ds:5.1.2.136.0.1.0');
$privacyPoliceUrl = $appInfo[99][0][5][2] ?? '';
$categoryFamily = $this->extractCategory($appInfo[118][0][0][0] ?? []);
$icon = $this->extractIcon($appInfo);
Expand Down
23 changes: 16 additions & 7 deletions src/Scraper/ClusterPagesFromListAppsScraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ public function __invoke(RequestInterface $request, ResponseInterface $response,
$contents = $response->getBody()->getContents();
$scriptData = ScraperUtil::extractScriptData($contents);

if (isset($scriptData['ds:4'][0][1])) {
$scriptDataInfo = $scriptData['ds:4'][0][1];
$token = $scriptData['ds:4'][0][3][1] ?? null;
} elseif (isset($scriptData['ds:3'][0][1])) {
$scriptDataInfo = $scriptData['ds:3'][0][1];
$token = $scriptData['ds:3'][0][3][1] ?? null;
} else {
$scriptDataInfo = null;
$token = null;

foreach ($scriptData as $data) {
if (isset($data[0][1][0][21][0])
|| isset($data[0][1][1][21][0])
|| isset($data[0][1][0][22][0])
|| isset($data[0][1][1][22][0])
) {
$scriptDataInfo = $data[0][1];
$token = $data[0][3][1] ?? null;
break;
}
}

if (!$scriptDataInfo) {
return [
'results' => [],
'token' => null,
Expand Down

0 comments on commit 9cc772c

Please sign in to comment.