Skip to content

Commit c897d6e

Browse files
committed
lets see title and description in backend ui for audiothek content
1 parent 5eb159b commit c897d6e

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## 3.15.2 - 2026-02-17
3+
### Fixed
4+
- Personal settings now shows proper titles/descriptions for ARD Audiothek subscriptions by resolving both API and website URLs to metadata.
5+
26
## 3.15.1 - 2026-02-17
37
### Fixed
48
- Personal settings view no longer crashes on load – `PodcastDataReader` now requests the PSR logger (resolving the `OCP\ILogger` DI error)

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>GPodder Sync</name>
66
<summary>replicate basic GPodder.net API</summary>
77
<description><![CDATA[Expose GPodder API to sync podcast consumer apps like AntennaPod]]></description>
8-
<version>3.15.1</version>
8+
<version>3.15.2</version>
99
<licence>agpl</licence>
1010
<author mail="thrillfall@disroot.org">Thrillfall</author>
1111
<namespace>GPodderSync</namespace>

lib/Core/PodcastData/PodcastDataReader.php

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCP\ICache;
1313
use OCP\ICacheFactory;
1414
use Psr\Log\LoggerInterface;
15+
use Throwable;
1516

1617
class PodcastDataReader {
1718
private ?ICache $cache = null;
@@ -67,22 +68,22 @@ public function fetchPodcastData(string $url, string $userId): ?PodcastData {
6768
}
6869

6970
private function fetchPodcastDataForUrl(string $url): PodcastData {
70-
if ($this->isArdAudiothekUrl($url)) {
71-
return $this->fetchArdAudiothekData($url);
71+
$ardProgramId = $this->extractArdProgramId($url);
72+
if ($ardProgramId !== null) {
73+
try {
74+
return $this->fetchArdAudiothekData($ardProgramId, $url);
75+
} catch (Throwable $e) {
76+
$this->logger->warning('Failed to resolve ARD Audiothek metadata, falling back to RSS parsing.', [
77+
'url' => $url,
78+
'exception' => $e,
79+
]);
80+
}
7281
}
7382
$resp = $this->fetchUrl($url);
7483
return PodcastData::parseRssXml($resp->getBody());
7584
}
7685

77-
private function isArdAudiothekUrl(string $url): bool {
78-
return (bool)preg_match(self::ARD_PROGRAMSET_REGEX, $url);
79-
}
80-
81-
private function fetchArdAudiothekData(string $url): PodcastData {
82-
$programId = $this->extractArdProgramId($url);
83-
if ($programId === null) {
84-
throw new \InvalidArgumentException('Could not extract ARD Audiothek program id from URL');
85-
}
86+
private function fetchArdAudiothekData(string $programId, string $originalUrl): PodcastData {
8687
$resp = $this->fetchUrl("https://" . self::ARD_AUDIOTHEK_HOST . "/programsets/$programId");
8788
$body = $resp->getBody();
8889
$decoded = json_decode($body, true);
@@ -98,7 +99,7 @@ private function fetchArdAudiothekData(string $url): PodcastData {
9899
return new PodcastData(
99100
$programSet['title'] ?? null,
100101
$programSet['publicationService']['title'] ?? null,
101-
$programSet['sharingUrl'] ?? $url,
102+
$programSet['sharingUrl'] ?? $originalUrl,
102103
$programSet['synopsis'] ?? ($programSet['description'] ?? null),
103104
$this->resolveArdImageUrl($programSet['image'] ?? null),
104105
(new DateTime())->getTimestamp()
@@ -116,7 +117,32 @@ private function extractArdProgramId(string $url): ?string {
116117
if (preg_match(self::ARD_PROGRAMSET_REGEX, $url, $matches)) {
117118
return $matches['id'];
118119
}
119-
return null;
120+
return $this->extractArdProgramIdFromWebsite($url);
121+
}
122+
123+
private function extractArdProgramIdFromWebsite(string $url): ?string {
124+
$parts = parse_url($url);
125+
if ($parts === false) {
126+
return null;
127+
}
128+
$host = strtolower($parts['host'] ?? '');
129+
if (!in_array($host, ['ardaudiothek.de', 'www.ardaudiothek.de'], true)) {
130+
return null;
131+
}
132+
$path = $parts['path'] ?? '';
133+
if ($path === '') {
134+
return null;
135+
}
136+
$segments = array_values(array_filter(explode('/', $path), 'strlen'));
137+
if (count($segments) < 3) {
138+
return null;
139+
}
140+
$section = strtolower($segments[0]);
141+
if (!in_array($section, ['sendung', 'podcast'], true)) {
142+
return null;
143+
}
144+
$possibleId = $segments[count($segments) - 1];
145+
return ctype_digit($possibleId) ? $possibleId : null;
120146
}
121147

122148
private function tryFetchImageBlob(PodcastData $data): ?string {

0 commit comments

Comments
 (0)