Malformed Video thumbnail URL

Created on 28 September 2023, 9 months ago
Updated 29 September 2023, 9 months ago

Problem/Motivation

The thumbnail URL of the VIDEO is incorrect. This URL is hit in the AvPortalClient::getThumbnail() method. The URL is collected from the metadata response in MediaAvPortalSourceBase::getMetadata().

Example for incorrect thumbnail URL: https://eucom-posters.freecaster.com/videos/eucom/9a3993ec-2b13-4550-b69...

Correct one: https://eucom-posters.freecaster.com/videos/eucom/9a3993ec-2b13-4550-b69...

Note that, I used 1080 because the thumbnails here (https://audiovisual.ec.europa.eu/en/video) are also fetched using that size parameter.

Without this fix, there is an error when a the create new AV Portal Video media form is submitted:

GuzzleHttp\Exception\ClientException: Client error: `GET https://eucom-posters.freecaster.com/videos/eucom/9a3993ec-2b13-4550-b69a-70da0d7aab84-1695721361/%25%7BSIZE%7D.jpg` resulted in a `400 Bad Request` response: <html> <head><title>400 Bad Request</title></head> <body> <center><h1>400 Bad Request</h1></center> <hr><center>ngin (truncated...) in GuzzleHttp\Exception\RequestException::create() (line 113 of /var/www/html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).GuzzleHttp\Middleware::GuzzleHttp\{closure}() (Line: 204)
GuzzleHttp\Promise\Promise::callHandler() (Line: 153)
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (Line: 48)
GuzzleHttp\Promise\TaskQueue->run() (Line: 248)
GuzzleHttp\Promise\Promise->invokeWaitFn() (Line: 224)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 269)
GuzzleHttp\Promise\Promise->invokeWaitList() (Line: 226)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 62)
GuzzleHttp\Promise\Promise->wait() (Line: 182)
GuzzleHttp\Client->request() (Line: 95)
GuzzleHttp\Client->__call() (Line: 141)
Drupal\media_avportal\AvPortalClient->getThumbnail() (Line: 293)
Drupal\media_avportal\Plugin\media\Source\MediaAvPortalSourceBase->importRemoteThumbnail() (Line: 263)
Drupal\media_avportal\Plugin\media\Source\MediaAvPortalSourceBase->getLocalThumbnailUri() (Line: 156)
Drupal\media_avportal\Plugin\media\Source\MediaAvPortalSourceBase->getMetadata() (Line: 260)
Drupal\media\Entity\Media->getThumbnailUri() (Line: 156)
Drupal\media\Entity\Media->updateThumbnail() (Line: 448)
Drupal\media\Entity\Media->prepareSave() (Line: 27)
Drupal\media\MediaStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 285)
Drupal\Core\Entity\EntityForm->save() (Line: 61)
Drupal\media\MediaForm->save()
call_user_func_array() (Line: 128)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 66)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 48)

Steps to reproduce

1. Try to create a new AV Portal Media entity using the default add new media form.
2. Type an existing video URL, for example: https://audiovisual.ec.europa.eu/en/video/I-246110
3. Submit the form.

Remaining tasks

1. Report the bug to European Audiovisual Services
2. If it is not a bug, then consider implementing a more robust solution and pass the size as a parameter

πŸ› Bug report
Status

Active

Version

1.3

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary peter_serfozo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @peter_serfozo
  • First commit to issue fork.
  • πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels

    I can confirm the issue, and also that #3 is working at the moment and the thumbnails are retrieved with the URL fix. The fix is not ideal though, this should be fixed in the API, which returns the bad URL, or maybe in the request that retrieves the resource, not sure.

    However, I think the request exception should be caught when trying to get thumbnail, so in that case the method should return NULL without exception. (Ideally, this should also be logged, but the fact that the thumbnail was not downloaded is logged in MediaAvPortalSourceBase::importRemoteThumbnail())

    The attached patch is only for catching the exception (committed in 29c7af22)

  • πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels

    This patch is combining #3 and #5, in case you need a temp fix and also want to catch exceptions.

  • πŸ‡§πŸ‡ͺBelgium keszthelyi Brussels
Production build 0.69.0 2024