Neu: App Store Update Bridge
This commit is contained in:
149
AppStoreUpdateBridge.php
Normal file
149
AppStoreUpdateBridge.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
class AppStoreUpdateBridge extends BridgeAbstract
|
||||||
|
{
|
||||||
|
const MAINTAINER = 'Akamaru';
|
||||||
|
const NAME = 'App Store Update Bridge';
|
||||||
|
const URI = 'https://apps.apple.com/';
|
||||||
|
const CACHE_TIMEOUT = 3600; // 1 hour
|
||||||
|
const DESCRIPTION = 'Returns app updates from the Apple App Store using iTunes API';
|
||||||
|
|
||||||
|
const PARAMETERS = [
|
||||||
|
[
|
||||||
|
'app_id' => [
|
||||||
|
'name' => 'App ID',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'title' => 'The numeric App ID from the App Store URL (e.g., 383457673)',
|
||||||
|
'exampleValue' => '383457673'
|
||||||
|
],
|
||||||
|
'country' => [
|
||||||
|
'name' => 'Country Code',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => false,
|
||||||
|
'defaultValue' => 'de',
|
||||||
|
'title' => 'Two-letter country code (e.g., de, us, fr, jp)',
|
||||||
|
'exampleValue' => 'de'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
private ?array $appData = null;
|
||||||
|
|
||||||
|
private function getAppData(): ?array
|
||||||
|
{
|
||||||
|
if ($this->appData !== null) {
|
||||||
|
return $this->appData;
|
||||||
|
}
|
||||||
|
|
||||||
|
$appId = $this->getInput('app_id');
|
||||||
|
if (!$appId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$country = $this->getInput('country') ?: 'de';
|
||||||
|
|
||||||
|
$apiUrl = sprintf(
|
||||||
|
'https://itunes.apple.com/lookup?id=%s&country=%s',
|
||||||
|
urlencode($appId),
|
||||||
|
urlencode($country)
|
||||||
|
);
|
||||||
|
|
||||||
|
$json = getContents($apiUrl);
|
||||||
|
$data = json_decode($json, true);
|
||||||
|
|
||||||
|
if (!$data || $data['resultCount'] === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->appData = $data['results'][0];
|
||||||
|
return $this->appData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectData()
|
||||||
|
{
|
||||||
|
$appData = $this->getAppData();
|
||||||
|
|
||||||
|
if (!$appData) {
|
||||||
|
returnServerError('Could not find app with the given ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
$country = $this->getInput('country') ?: 'de';
|
||||||
|
$appId = $this->getInput('app_id');
|
||||||
|
|
||||||
|
// Parse release date
|
||||||
|
$releaseDate = $appData['currentVersionReleaseDate'] ?? $appData['releaseDate'] ?? null;
|
||||||
|
$timestamp = $releaseDate ? strtotime($releaseDate) : time();
|
||||||
|
|
||||||
|
// If the date doesn't contain a year, use current year
|
||||||
|
if ($timestamp === false) {
|
||||||
|
$timestamp = time();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format release notes
|
||||||
|
$releaseNotes = $appData['releaseNotes'] ?? 'No release notes available.';
|
||||||
|
$content = nl2br(htmlspecialchars($releaseNotes));
|
||||||
|
|
||||||
|
$item = [
|
||||||
|
'uri' => sprintf('https://apps.apple.com/%s/app/id%s', $country, $appId),
|
||||||
|
'title' => sprintf('%s %s', $appData['trackName'] ?? 'App', $appData['version'] ?? ''),
|
||||||
|
'content' => $content,
|
||||||
|
'timestamp' => $timestamp,
|
||||||
|
'author' => $appData['artistName'] ?? null,
|
||||||
|
'uid' => sprintf('%s-%s', $appId, $appData['version'] ?? 'unknown'),
|
||||||
|
'enclosures' => [
|
||||||
|
$appData['artworkUrl512'] ?? $appData['artworkUrl100'] ?? null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
$appData = $this->getAppData();
|
||||||
|
if ($appData && isset($appData['trackName'])) {
|
||||||
|
return sprintf('%s - App Store Updates', $appData['trackName']);
|
||||||
|
}
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI()
|
||||||
|
{
|
||||||
|
$appId = $this->getInput('app_id');
|
||||||
|
$country = $this->getInput('country') ?: 'de';
|
||||||
|
|
||||||
|
if ($appId) {
|
||||||
|
return sprintf('https://apps.apple.com/%s/app/id%s', $country, $appId);
|
||||||
|
}
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon()
|
||||||
|
{
|
||||||
|
$appData = $this->getAppData();
|
||||||
|
if ($appData && isset($appData['artworkUrl100'])) {
|
||||||
|
return $appData['artworkUrl100'];
|
||||||
|
}
|
||||||
|
return 'https://www.apple.com/favicon.ico';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detectParameters($url)
|
||||||
|
{
|
||||||
|
// Match URLs like:
|
||||||
|
// https://apps.apple.com/de/app/plex-film-tv/id383457673
|
||||||
|
// https://apps.apple.com/us/app/id383457673
|
||||||
|
$pattern = '/apps\.apple\.com\/([a-z]{2})\/app\/(?:[^\/]+\/)?id(\d+)/i';
|
||||||
|
|
||||||
|
if (preg_match($pattern, $url, $matches)) {
|
||||||
|
return [
|
||||||
|
'country' => $matches[1],
|
||||||
|
'app_id' => $matches[2]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,12 @@ Diese Sammlung enthält verschiedene Bridge-Implementierungen für RSS-Bridge, u
|
|||||||
### [Ananta Game News Bridge](https://bridge.ponywave.de/#bridge-AnantaBridge) (Von Akamaru)
|
### [Ananta Game News Bridge](https://bridge.ponywave.de/#bridge-AnantaBridge) (Von Akamaru)
|
||||||
- **Beschreibung**: Zeigt die neuesten Nachrichten von Ananta Game
|
- **Beschreibung**: Zeigt die neuesten Nachrichten von Ananta Game
|
||||||
|
|
||||||
|
### [App Store Update Bridge](https://bridge.ponywave.de/#bridge-AppStoreUpdateBridge) (Von Akamaru)
|
||||||
|
- **Beschreibung**: Zeigt App-Updates aus dem Apple App Store (Release Notes)
|
||||||
|
- **Parameter**:
|
||||||
|
- **App ID**: Die numerische App-ID aus der App Store URL (z.B. 383457673)
|
||||||
|
- **Country Code** (optional): Zwei-Buchstaben-Ländercode (z.B. de, us, fr, jp). Standard: de
|
||||||
|
|
||||||
### [Blue Archive News Bridge](https://bridge.ponywave.de/#bridge-BlueArchiveNewsBridge) (Von Akamaru)
|
### [Blue Archive News Bridge](https://bridge.ponywave.de/#bridge-BlueArchiveNewsBridge) (Von Akamaru)
|
||||||
- **Beschreibung**: Zeigt die neuesten Ankündigungen, Updates und Events aus dem Blue Archive (EN) Forum
|
- **Beschreibung**: Zeigt die neuesten Ankündigungen, Updates und Events aus dem Blue Archive (EN) Forum
|
||||||
- **Parameter**:
|
- **Parameter**:
|
||||||
|
|||||||
Reference in New Issue
Block a user