File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Embed \Providers \OEmbed ;
4
4
5
+ use Embed \Adapters \Adapter ;
6
+
5
7
class Youtube extends EndPoint implements EndPointInterface
6
8
{
7
9
protected static $ pattern = ['*youtube.* ' , '*youtu\.be.* ' ];
8
10
protected static $ endPoint = 'https://www.youtube.com/oembed ' ;
11
+
12
+ public static function create (Adapter $ adapter )
13
+ {
14
+ $ response = $ adapter ->getResponse ();
15
+ // If the starting URL is a valid YouTube URL, but we've been redirected to a consent page,
16
+ // we should attempt to get Oembed using the original URL instead of the consent URL
17
+ if (
18
+ preg_match ('/consent\.youtube.*/ ' , $ response ->getUrl ())
19
+ && $ response ->getStartingUrl ()->match (static ::$ pattern )
20
+ ) {
21
+ return new static ($ response , $ response ->getStartingUrl ());
22
+ }
23
+
24
+ return parent ::create ($ adapter );
25
+ }
9
26
}
You can’t perform that action at this time.
0 commit comments