Skip to content

Commit 9004683

Browse files
authored
Use two proper user-agent to scrape feeds (fix #208) (#210)
1 parent f30fb8d commit 9004683

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/Core/PodcastData/PodcastDataReader.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ private function tryFetchImageBlob(PodcastData $data): ?string {
7575
}
7676

7777
private function fetchUrl(string $url): IResponse {
78-
$resp = $this->httpClient->get($url);
78+
$resp = $this->httpClient->get($url, ['headers' => ['User-Agent' => 'nextcloud-gpodder (+https://nextcloud.com; like iTMS)']]);
7979
$statusCode = $resp->getStatusCode();
8080
if ($statusCode < 200 || $statusCode >= 300) {
81-
throw new \ErrorException("Web request returned non-2xx status code: $statusCode");
81+
$resp = $this->httpClient->get($url, ['headers' => ['User-Agent' => 'nextcloud-gpodder (+https://nextcloud.com)']]);
82+
$statusCode = $resp->getStatusCode();
83+
if ($statusCode < 200 || $statusCode >= 300) {
84+
throw new \ErrorException("Web request returned non-2xx status code: $statusCode");
85+
}
8286
}
8387
return $resp;
8488
}

0 commit comments

Comments
 (0)