garethbjohnson / gutendex

Web API for Project Gutenberg ebook metadata
https://gutendex.com
MIT License
236 stars 48 forks source link

File Size #36

Open fakerybakery opened 11 months ago

fakerybakery commented 11 months ago

Hi, Sorry to ask so many questions. I was wondering if it might be possible to get the file size of each file. It can be helpful to estimate how long a book is :).

garethbjohnson commented 11 months ago

Hi again, no worries, that is another good idea. I found a number value in the Gutenberg catalogue XML files that seems to roughly match the number of bytes in each book format's file.

To alter what I suggested in the last issue thread (#35), I could instead make "all_formats" an array of objects with properties for media type, file URL, and file size:

{
  ...
  "formats": {
    ...
    "application/x-mobipocket-ebook": "https://www.gutenberg.org/ebooks/84.kf8.images",
    ...
  },
  "all_formats": [
    ...
    {
      "media_type": "application/x-mobipocket-ebook",
      "size": 448727,
      "url": "https://www.gutenberg.org/ebooks/84.kindle.images"
    },
    {
      "media_type": "application/x-mobipocket-ebook",
      "size": 476477,
      "url": "https://www.gutenberg.org/ebooks/84.kf8.images"
    },
    ...
  ],
  ...
}

Would that work for you?

fakerybakery commented 11 months ago

Thank you, that works! Commented in the other issue