[ '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; } }