Skip to content

Commit

Permalink
fix: Fetch correct information from Youtube URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Aug 9, 2024
1 parent 01f87f2 commit 252e099
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/LinkFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,15 @@ public function fetchUrl(string $url): array
$options = [
'max_size' => 20 * 1024 * 1024,
];

// If we fetch Twitter or Youtube, we need to alter our user agent
// to get server-side rendered content.
if ($this->isTwitter($url)) {
// If we fetch Twitter, we need to alter our user agent to get
// server-side rendered content.
// @see https://stackoverflow.com/a/64332370
$options['user_agent'] = $this->http->user_agent . ' (compatible; bot)';
} elseif ($this->isYoutube($url)) {
// @see https://stackoverflow.com/a/46616889
$options['user_agent'] = $this->http->user_agent . ' (compatible; facebookexternalhit/1.1)';
}

if ($selected_ip) {
Expand Down

0 comments on commit 252e099

Please sign in to comment.