diff --git a/AppStoreUpdateBridge.php b/AppStoreUpdateBridge.php new file mode 100644 index 0000000..c48062c --- /dev/null +++ b/AppStoreUpdateBridge.php @@ -0,0 +1,149 @@ + [ + '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; + } +} diff --git a/README.md b/README.md index 040d33b..5854d14 100644 --- a/README.md +++ b/README.md @@ -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) - **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) - **Beschreibung**: Zeigt die neuesten Ankündigungen, Updates und Events aus dem Blue Archive (EN) Forum - **Parameter**: