04-16-2024, 09:25 AM | #1 |
Evangelist
Posts: 428
Karma: 2666666
Join Date: Nov 2020
Device: none
|
`gui.book_on_device` returns lower case book path for MTP devices
I'm using the book_on_device function to get book path on device but this function returns lower case path on MTP devices, could this function be updated? Or maybe there is another function I could use to get the correct book path on MTP devices?
|
04-17-2024, 10:00 AM | #2 |
Evangelist
Posts: 428
Karma: 2666666
Join Date: Nov 2020
Device: none
|
I find the code converts the path to lower case: https://github.com/kovidgoyal/calibr..._cache.py#L177
but I don't know if calibre's developer would accept the change, I hope remove `.lower()` won't break other code. |
Advert | |
|
04-17-2024, 10:43 AM | #3 |
creator of calibre
Posts: 44,530
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That function is definitely not going to be changed. And IIRC paths in MTP are case insensitive.
|
04-17-2024, 10:55 AM | #4 |
Evangelist
Posts: 428
Karma: 2666666
Join Date: Nov 2020
Device: none
|
Is there another function I could use to get the file name uploaded to mtp device by calibre? A user created an issue at https://github.com/xxyzz/WordDumb/issues/206 says calibre could change the book file name and my code would break using lower case path or the original book file name.
|
04-17-2024, 11:17 AM | #5 |
creator of calibre
Posts: 44,530
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The lowercased path is what calibre uses as a key. So no there is no other function. WHy do you care if the path is lowercased?
|
Advert | |
|
04-17-2024, 11:32 AM | #6 |
Evangelist
Posts: 428
Karma: 2666666
Join Date: Nov 2020
Device: none
|
Because I need to create a ".sdr" folder with the same name as the book file to put Kindle Word Wise file and X-Ray file, use the lower case folder name doesn't work for Kindle...
|
04-17-2024, 12:00 PM | #7 |
Evangelist
Posts: 428
Karma: 2666666
Join Date: Nov 2020
Device: none
|
The upload book job results contain the correct book file name, I think I could use that value.
|
04-17-2024, 12:20 PM | #8 |
creator of calibre
Posts: 44,530
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you are sending the book file yourself then yes you can use it.
|
04-17-2024, 06:36 PM | #9 |
Grand Sorcerer
Posts: 12,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
You can also try using os.path.realpath(lower_case_full_path).
In my tests on Windows 10 it converts an lcase path to the path as it really exists. I didn't try it on an MTP device. Example: Code:
import os.path s = 'c:/users/me' print(os.path.realpath(s)) C:\Users\Me |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Device Driver API for MTP devices (e.g. Kindle Scribe) | tomsem | Development | 2 | 09-24-2023 01:19 PM |
Shortcut to execute title case, lower case, etc. | birkmaggs | Library Management | 2 | 10-29-2018 12:42 AM |
Kindle Fire giving "invalid MTP path" error | Deadser | Devices | 2 | 06-29-2017 06:22 PM |
lower case to capital | tscamera | Sigil | 12 | 03-18-2012 11:54 PM |
[Bug] Calibre using all lower case path names | krunk | Calibre | 0 | 05-01-2010 03:58 PM |