Calameo media information could not be retrieved: Unknown book

Created on 23 January 2025, 3 months ago

We installed the module on one of our projects. And we're getting an error message when we want to save a Calameo document with the complete url or the Calameo id.

The media is created, but we can't save because the error message blocks saving.

Drupal Core : 10.4.1
PHP : 8.3
media_entity_calameo : 1.0.3

Install the module, then try adding a calameo media with a url, for example, this sample calameo book available on their site :

https://www.calameo.com/read/0005709839fd7f02a8daf

The we have this error message :

Calameo media information could not be retrieved: Unknown book

"The media items have been created but have not yet been saved. Fill in any required fields and save to add them to the media library."

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France lifelifeone

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

Comments & Activities

  • Issue created by @lifelifeone
  • As a matter of fact, the error is triggered because the Calameo API is unable to return any book information. The response is a 200 but contains following information :

    "response" => [
        "status" => "error"
        "version" => 2
        "requestid" => "t7scjv"
        "requests" => 9
        "error" => [
          "code" => 501
          "message" => "Unknown book"
        ]
      ]

    (see here for full list of error codes: https://developer.calameo.com/content/api/#errorcodes)

    It makes sense that Calameo::getMetadata() method returns an error message since `$data['response']['error']` is not empty.

    What I'd suggest, though, would be to change the level of the user-returned message to "Warning" since these errors do not prevent the media from being created. I think it could result in a better user experience.

    Any thoughts?

    • anfor committed e0389b50 on 1.0.x
      Fix shortcode from publication URL with publisher - issue #3501732
      
    • anfor committed 1e1d96ac on 1.0.x
      Return default metadata on response error - issue #3501732
      
  • 🇫🇷France anfor

    Hi @misterdidi, thank you for your feedback.

    The error message type seems logical to me, since we can't base it on the error level in the Calameo API.
    Some publishers will argue that a missing book for a valid API key is actually a significant problem.

    Nonetheless, I updated the error message to include the API page you mentioned.

    Do you have the exact same issue with latest release 1.0.5 ?

Production build 0.71.5 2024