From 8f7601edd8c4ddc344a213ce35435a122f8f6ba9 Mon Sep 17 00:00:00 2001 From: 0x6470 <36334850+0x6470@users.noreply.github.com> Date: Thu, 14 May 2020 10:59:59 +0200 Subject: [PATCH] Fix xHamster support, fixes #264 (#276) * Fix xhamster support * Send http headers properly * added spaces * convert stdObject to array for comparison Co-authored-by: Pierre Rudloff --- classes/Video.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/classes/Video.php b/classes/Video.php index 8b67ae0..1a53a9b 100644 --- a/classes/Video.php +++ b/classes/Video.php @@ -622,12 +622,22 @@ class Video { $client = new Client(); $urls = $this->getUrl(); + $stream_context_options = []; + + if (array_key_exists('Referer', (array)$this->http_headers)) { + $stream_context_options = [ + 'http' => [ + 'header' => 'Referer: ' . $this->http_headers->Referer + ] + ]; + } return $client->request( 'GET', $urls[0], [ 'stream' => true, + 'stream_context' => $stream_context_options, 'headers' => array_merge((array)$this->http_headers, $headers) ] );