Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-06-2022, 11:13 PM   #1
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Adding Cover by URL When adding books

Hello,

I'm wondering if it is possible to add a book cover by URL not by a file path when adding a book with the calibredb add command.

I could successfully add a cover with a file path using the --cover option. But when I try to specify a URL instead of a file path, it gives an error.

Quote:
Traceback (most recent call last):

File "runpy.py", line 196, in _run_module_as_main
File "runpy.py", line 86, in _run_code
File "site.py", line 83, in <module>
File "site.py", line 78, in main
File "site.py", line 50, in run_entry_point
File "calibre\db\cli\main.py", line 252, in main
File "calibre\db\cli\main.py", line 40, in run_cmd
File "calibre\db\cli\cmd_add.py", line 474, in main
File "calibre\db\cli\cmd_add.py", line 241, in do_add
File "calibre\ebooks\metadata\book\serialize.py", line 26, in serialize_cover

OSError: [Errno 22] Invalid argument: 'https://some.where/xxxxxxxx.jpg'
If it's not possible, it would be great to see it being implemented.
tn4w is offline   Reply With Quote
Old 12-06-2022, 11:51 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There are gazillions of command line tools that can download a URL. Use any of then and then call calibredb with the downloaded cover.
kovidgoyal is offline   Reply With Quote
Old 12-07-2022, 12:27 AM   #3
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Thanks for the comment.

That's what I'm doing currently. But you know, you have to validate the downloaded image file to ensure it's not broken and delete it after confirming that the book has been successfully added to the database.

These might be better to be handled by experienced programmers.

If this is done on the Calibre side, it would be great.
tn4w is offline   Reply With Quote
Old 12-07-2022, 03:28 PM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,223
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by tn4w View Post
Thanks for the comment.

That's what I'm doing currently. But you know, you have to validate the downloaded image file to ensure it's not broken and delete it after confirming that the book has been successfully added to the database.

These might be better to be handled by experienced programmers.

If this is done on the Calibre side, it would be great.
I gather you think that calibre should able to validate the cover image for you? An interesting concept.

Also out of curiosity, where is the URL coming from?
DNSB is online now   Reply With Quote
Old 12-07-2022, 07:39 PM   #5
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Quote:
Originally Posted by DNSB View Post
validate the cover image for you?
For all the users.
tn4w is offline   Reply With Quote
Old 12-08-2022, 02:17 AM   #6
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,223
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by tn4w View Post
For all the users.
The you in my comment was not you personally but a generic you as in a calibre user.

Umm... just how is calibre going to validate the cover image for all the users?

I won't ask you to write the code but perhaps you could generate a simple flow diagram of how you would program the image insertion code to be able to distinguish a "good" cover from a "bad" cover.

Don't forget to allow for tasks such as distinguishing image quality, image size, colour depth, etc. that we currently use wetware to handle. Make sure that you include the code paths needed to analyze the image file to locate strings of text to match to the author(s), editor(s), book title, series title and index, etc. to ensure that you have a cover image that matches the book. You may also want to familiarize yourself with the current state of the art in image recognition and the current software patents in this area.

In simple words, what you are asking for is not a simple task.

For your original query, with the current state of calibre development, how would you know that the URL you want to use to download the image has a valid, reasonably sized image if you haven't visited the page and examined the image for yourself?
DNSB is online now   Reply With Quote
Old 12-08-2022, 03:13 AM   #7
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Quote:
how is calibre going to validate the cover image for all the users?
Ensuring it is not broken is just enough. Sometimes downloads are incomplete due to various reasons, and the image files get broken and unable to load. Checking if an image is not broken doesn't seem to be that complicated (see).

Quote:
perhaps you could generate a simple flow diagram of how you would program the image insertion code to be able to distinguish a "good" cover from a "bad" cover.
When the user explicitly specifies an image, it is not necessary to check whether the cover is the real one or not because the user already knows it is the legitimate one. The reason the user wants to specify it in the first place is because Calibre occasionally assigns the wrong cover or fails to set a cover.

When downloading the specified image fails, do the normal cover finding task like it does when the --cover option is not set.

Quote:
In simple words, what you are asking for is not a simple task.
Then it must be so for the end users. Then why do you ask them to write code for such a complicated task? Most end users are even unfamiliar with coding.

Quote:
For your original query, with the current state of calibre development, how would you know that the URL you want to use to download the image has a valid, reasonably sized image if you haven't visited the page and examined the image for yourself?
1. Check the response header like shown in this post.
2. Download the image.
3. Check if it is not broken.
4-a. Add it to Calibre with the book.
4-b. If it is broken or the given URL is not available, do the normal adding book task without the --cover option.
tn4w is offline   Reply With Quote
Old 12-08-2022, 03:28 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Any decent file download tool will automatically check if the download is not broken in the sense you mean. Again, just use one.
kovidgoyal is offline   Reply With Quote
Old 12-08-2022, 11:53 PM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,223
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by tn4w View Post
Ensuring it is not broken is just enough. Sometimes downloads are incomplete due to various reasons, and the image files get broken and unable to load. Checking if an image is not broken doesn't seem to be that complicated (see).

When the user explicitly specifies an image, it is not necessary to check whether the cover is the real one or not because the user already knows it is the legitimate one. The reason the user wants to specify it in the first place is because Calibre occasionally assigns the wrong cover or fails to set a cover.

When downloading the specified image fails, do the normal cover finding task like it does when the --cover option is not set.

Then it must be so for the end users. Then why do you ask them to write code for such a complicated task? Most end users are even unfamiliar with coding.

1. Check the response header like shown in this post.
2. Download the image.
3. Check if it is not broken.
4-a. Add it to Calibre with the book.
4-b. If it is broken or the given URL is not available, do the normal adding book task without the --cover option.
It would appear that instead of pointing the cover image to a URL instead of a file, you now want to download the file and use imghdr to verify the file. Sadly, that would still leave issues with some cover images I've seen returned by searches. Nothing like using a 1800x2700 file which was created by re-sizing a 120x80 image for that fuzzy effect. Perhaps finding that the web site where the cover image was found has a nasty habit of watermarking the downloads.

I didn't ask you to write the code. I asked you for a flow diagram or flowchart which is a lot simpler task. Ask any programmer whom has been handed one. I thought this might get you to think about what you are actually asking for.

The best way at the moment to do a decent job of verifying a cover image is to use the mark one eyeball. In which case, downloading the image and pointing calibre at that file would make more sense than copying the URL.
DNSB is online now   Reply With Quote
Old 12-09-2022, 01:32 AM   #10
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Quote:
Originally Posted by DNSB View Post
It would appear that instead of pointing the cover image to a URL instead of a file, you now want to download the file and use imghdr to verify the file.
It appears that you didn't understand what was suggested in the first place.

Quote:
I didn't ask you to write the code. I asked you for a flow diagram or flowchart which is a lot simpler task. Ask any programmer whom has been handed one. I thought this might get you to think about what you are actually asking for.
I gave you a simple workflow list already.

Quote:
Originally Posted by DNSB View Post
downloading the image and pointing calibre at that file would make more sense than copying the URL.
Nobody except you talks about copying URLs and it is irrelevant. You should review what you wrote quoted below and think about what you suggested above.
Quote:
Originally Posted by DNSB View Post
Sadly, that would still leave issues with some cover images I've seen returned by searches. Nothing like using a 1800x2700 file which was created by re-sizing a 120x80 image for that fuzzy effect. Perhaps finding that the web site where the cover image was found has a nasty habit of watermarking the downloads.
At this point, it appears you just want to give negative feedback for whatever reasons and I'm not interested in responding to it, sorry.
tn4w is offline   Reply With Quote
Old 12-09-2022, 06:28 AM   #11
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,062
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
You seem to be Ignoring advice by folk who Designed Calibre and its features or plugins.

Your work flow seemed odd to me (and I am not a Developer), and I have been using Calibre for over 10Y (and seen many suggestions ADOPTED).
theducks is online now   Reply With Quote
Old 12-09-2022, 07:39 AM   #12
tn4w
Enthusiast
tn4w began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Aug 2022
Device: Windows 10
Quote:
Originally Posted by theducks View Post
You seem to be Ignoring advice
Which one are you referring to?
tn4w is offline   Reply With Quote
Old 12-09-2022, 08:08 AM   #13
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,045
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
I either don't understand what you want, or if I do understand, it makes no sense. Use wget or browser to download by URL and how would you generally know what the URL is for a cover anyway?

There at least 6 ways to add a cover:
1) It's in the ebook file already and automatic when you add the ebook
2) You can go to Download in Edit Metadata and the usual book places are searched and you click on result you want.
3) Create a Generic cover from title & author in Edit Metadata
4) Browse to a directory where you have saved covers/images and pick one.
5) A cover creator addin that lets you create or edit a cover
6) Go to image editor of choice on your system via the cover thumnail even if there is no cover.

Where does this url you want to load from come from?

See wget (can be added to Windows and installed by default on Linux).
Quoth is offline   Reply With Quote
Old 12-09-2022, 03:16 PM   #14
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,729
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Quoth View Post
See wget (can be added to Windows and installed by default on Linux).
No need to add wget to Windows 7/8/10/11, its there already. It's an alias of the Invoke-WebRequest Powershell command.

@tn4w - in Powershell, you could try piping wget output into a calibredb add --cover command.

Curious - can one create a new book by adding a format file and a cover in the one command? e.g. calibredb add -c mycover.jpg mybook.epub.

FWIW: we should be encouraging people to step out of the (come in spinner) DOS Box into the brave new world of the Power Shell - at 16 it's old enough to take for a test drive

BR

Last edited by BetterRed; 12-09-2022 at 03:35 PM.
BetterRed is online now   Reply With Quote
Old 12-09-2022, 05:15 PM   #15
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,758
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
I find it's a lot easier to use Calibre (with various plugins) to look for and download covers. Most of the time it finds an appropriate hi-res cover. And the GUI is just so very much easier to use then the command line.
JSWolf is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Metadata by Google Books and Amazon URL Billa Library Management 3 11-06-2013 09:07 AM
Disable cover generation when adding books in Calibre? rebl Library Management 8 03-18-2013 06:56 AM
Cover images dissappeared after adding some books from my Calibre library fictionaddiction Kobo Reader 8 06-23-2011 10:42 AM
Including book cover when adding books Keith0603 Calibre 11 05-23-2011 12:10 AM
adding books cover comments icwright Calibre 5 12-22-2009 06:48 PM


All times are GMT -4. The time now is 07:47 PM.


MobileRead.com is a privately owned, operated and funded community.