chenyanming / calibredb.el

Emacs calibre client - An Ebook Management Solution in Emacs.
GNU General Public License v3.0
318 stars 16 forks source link

`calibredb-fetch-and-set-metadata-by-isbn` does not work on Windows #65

Open drcxd opened 1 year ago

drcxd commented 1 year ago

Executing that command by pressing s i and then enter the isbn number in *calibre-search* buffer results in the following output in *Messages* buffer.

D:/program/calibre/Calibre/fetch-ebook-metadata.exe -p "Google" --isbn "978-0-321-39952-6" 2>/dev/null
D:/program/calibre/Calibre/fetch-ebook-metadata.exe -p "Amazon.com" --isbn "978-0-321-39952-6" 2>/dev/null

"No metadata retrieved from sources"

Executing that command in Windows Powershell leads to the following error:

PS D:\program\calibre\Calibre> D:/program/calibre/Calibre/fetch-ebook-metadata.exe -p "Google" --isbn "978-0-321-39952-6" 2>/dev/null
out-file : Could not find a part of the path 'D:\dev\null'.
At line:1 char:1
+ D:/program/calibre/Calibre/fetch-ebook-metadata.exe -p "Google" --isb ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

Removing the 2>/dev/null/ leads to correct behavior:

PS D:\program\calibre\Calibre> D:/program/calibre/Calibre/fetch-ebook-metadata.exe -p "Google" --isbn "978-0-321-39952-6"
Title               : Computer Graphics: Principles and Practice
Author(s)           : John F. Hughes & Andries van Dam & Morgan McGuire & James D. Foley & David Sklar & Steven K. Feiner & Kurt Akeley
Publisher           : Addison-Wesley
Tags                : Computers, Software Development & Engineering, Computer Graphics
Languages           : eng
Published           : 2014-01-15T12:18:30.570926+00:00
Identifiers         : google:OVpsAQAAQBAJ, isbn:9780321399526
Comments            : <p>Computer Graphics: Principles and Practice, Third Edition,remains the most authoritative introduction to the field. The first edition, the original “Foley and van Dam,” helped to define computer graphics and how it could be taught. The second edition became an even more comprehensive resource for practitioners and students alike. This third edition has been completely rewritten to provide detailed and up-to-date coverage of key concepts, algorithms, technologies, and applications.</p>
...

I guess the 2>/dev/null/ is not platform-independent?

chenyanming commented 1 year ago

Yes, this would abandom errors on unix.

drcxd commented 1 year ago

Do you plan to support this command on Windows?

chenyanming commented 1 year ago

Let me check on later days.

drcxd commented 1 year ago

Found the equivalence of /dev/null here. https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows

I tried to modify the code fetching metadata by ISBN, changing /dev/null to $null. The fetching part seems worked, but the rest of the command seems doing wrong...

I checked some code here

https://github.com/chenyanming/calibredb.el/blob/3e3b4c0de3a9f4370aca9e5a1f82310bcfbfc9f4/calibredb-utils.el#L887

To me, it looks like no matter which library I am in and which book's metadata I am fetching, the program end up setting metadata of some book with the same ID in the default library?

Also, there are some other issues here.

First, there are some coding issues in the comments fetched.

image

When executing the command in Windows Powershell, no coding issue occurs. image

My operating system's default language is English.

Second, some error messages are written into the Author Sort part of the metadata. image I did not set calibredb-debug-program, but I assume this error message should not be written there?