spicywebau / craft-embedded-assets

Manage YouTube videos, Instagram photos, Twitter posts and more as first class assets in Craft CMS
MIT License
171 stars 34 forks source link

Embed\Exceptions\InvalidUrlException: Invalid url ... (Status code 429) #249

Closed lukastransom closed 3 months ago

lukastransom commented 5 months ago

Bug Description

On my production site, pasting a YouTube URL results in a "Could not retrieve embed information." error.

Interestingly, my staging site of the same project, server & PHP version works successfully (preview shows up after pasting URL).

I see it is returning "Status code 429", which indicates the client application has surpassed its rate limit. Does this mean it is a YouTube issue? Are there any workarounds? We are not even using a large number of YouTube URLs or requests during this initial development phase of the site...

Here's the web.log error output for this action on the production server:

2024-02-06 17:04:56 [-][1][2jikokf5g3u11cu0rgdpamb8mm][error][Embed\Exceptions\InvalidUrlException] Embed\Exceptions\InvalidUrlException: Invalid url 'https://www.youtube.com/watch?v=wk0sMrLTaLU' (Status code 429) in /home/forge/my-craft-project.com/vendor/embed/embed/src/Embed.php:142
Stack trace:
#0 /home/forge/my-craft-project.com/vendor/embed/embed/src/Embed.php(81): Embed\Embed::process()
#1 /home/forge/my-craft-project.com/vendor/spicyweb/craft-embedded-assets/src/Service.php(123): Embed\Embed::create()
#2 /home/forge/my-craft-project.com/vendor/spicyweb/craft-embedded-assets/src/Service.php(67): spicyweb\embeddedassets\
Service->_getDataFromAdapter()
#3 /home/forge/my-craft-project.com/vendor/spicyweb/craft-embedded-assets/src/Controller.php(168): spicyweb\embeddedass
ets\Service->requestUrl()
#4 [internal function]: spicyweb\embeddedassets\Controller->actionPreview()
#5 /home/forge/my-craft-project.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#6 /home/forge/my-craft-project.com/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(
)
#7 /home/forge/my-craft-project.com/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#8 /home/forge/my-craft-project.com/vendor/craftcms/cms/src/web/Application.php(295): yii\base\Module->runAction()
#9 /home/forge/my-craft-project.com/vendor/craftcms/cms/src/web/Application.php(608): craft\web\Application->runAction(
)
#10 /home/forge/my-craft-project.com/vendor/craftcms/cms/src/web/Application.php(274): craft\web\Application->_processA
ctionRequest()
#11 /home/forge/my-craft-project.com/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleReques
t()
#12 /home/forge/my-craft-project.com/web/index.php(21): yii\base\Application->run()
#13 {main}

Potentially related:

Steps to reproduce

  1. Open "Assets" in Craft Control Panel
  2. Paste YouTube URL
  3. "Could not retrieve embed information." error appears

Expected behaviour

Video preview shows up after pasting YouTube URL.

Embedded Assets version

2.11.4

Craft CMS version

Craft CMS 3.9.10

ttempleton commented 3 months ago

My understanding, based on https://github.com/oscarotero/Embed/issues/337, is that this should be working with Embed 4, and should therefore be working with Embedded Assets 4 (for Craft 4) and 5 (for Craft 5). There are no plans to release an Embed 4 version of Embedded Assets for Craft 3, so you will need to upgrade Craft to resolve this.