File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Embed \Providers \OEmbed ;
44
5+ use Embed \Adapters \Adapter ;
6+
57class Youtube extends EndPoint implements EndPointInterface
68{
79 protected static $ pattern = ['*youtube.* ' , '*youtu\.be.* ' ];
810 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+ }
926}
You can’t perform that action at this time.
0 commit comments