2022-02-12 07:17:12 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
class GooglePlayStoreBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Google Play Store';
|
|
|
|
const URI = 'https://play.google.com/store/apps';
|
|
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
|
|
|
const DESCRIPTION = 'Returns the most recent version of an app with its changelog';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
const TEST_DETECT_PARAMETERS = [
|
|
|
|
'https://play.google.com/store/apps/details?id=com.ichi2.anki' => [
|
|
|
|
'id' => 'com.ichi2.anki'
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-02-12 07:17:12 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
const PARAMETERS = [[
|
|
|
|
'id' => [
|
|
|
|
'name' => 'Application ID',
|
|
|
|
'exampleValue' => 'com.ichi2.anki',
|
|
|
|
'required' => true
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-02-12 07:17:12 +03:00
|
|
|
]];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2023-10-01 19:53:50 +03:00
|
|
|
$id = $this->getInput('id');
|
|
|
|
$url = 'https://play.google.com/store/apps/details?id=' . $id;
|
|
|
|
$html = getSimpleHTMLDOM($url);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-10-01 19:53:50 +03:00
|
|
|
$updatedAtElement = $html->find('div.TKjAsc div', 2);
|
|
|
|
// Updated onSep 27, 2023
|
|
|
|
$updatedAt = $updatedAtElement->plaintext;
|
|
|
|
$description = $html->find('div.bARER', 0);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-10-01 19:53:50 +03:00
|
|
|
$item = [];
|
|
|
|
$item['uri'] = $url;
|
|
|
|
$item['title'] = $id . ' ' . $updatedAt;
|
|
|
|
$item['content'] = $description->innertext ?? '';
|
|
|
|
$item['uid'] = 'GooglePlayStoreBridge/' . $updatedAt;
|
2022-02-12 07:17:12 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
public function detectParameters($url)
|
|
|
|
{
|
|
|
|
// Example: https://play.google.com/store/apps/details?id=com.ichi2.anki
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
$params = [];
|
|
|
|
$regex = '/^(https?:\/\/)?play\.google\.com\/store\/apps\/details\?id=([^\/&?\n]+)/';
|
|
|
|
if (preg_match($regex, $url, $matches) > 0) {
|
|
|
|
$params['id'] = urldecode($matches[2]);
|
|
|
|
return $params;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-12 07:17:12 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|