View Single Post
Old 01-30-2015, 07:25 AM   #11
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 18,163
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
Thanks! Following your tips, I did some test on the following book:
https://www.mobileread.com/forums/sho...d.php?t=255021

Code:
$ calibredb set_metadata --list-fields
Title                                    Field name 

Attachment ID                            #attachmentid
Uploader                                 #uploader
Author Sort                              author_sort
...

$ calibredb add ~/mrlibrary/AlexBell/255021/134208_What\ Diantha\ Did\ -\ Charlotte\ Perkins\ Gilman.mobi   

Backing up metadata
Added book ids: 6
Notifying calibre of the change

$ calibredb set_metadata 6 --field \#uploader:"AlexBell"      

Title               : What Diantha Did
Title sort          : What Diantha Did
Author(s)           : Charlotte Perkins Gilman [Gilman, Charlotte Perkins]
Publisher           : Bellware
Tags                : humanism, servant question, romance
Languages           : eng
Timestamp           : 2015-01-30T09:51:46+00:00
Published           : 2015-01-24T13:00:00+00:00
Identifiers         : mobi-asin:cec96dd0-e53e-4f26-b392-166f8c160ce4
Comments            : <p class="description">'What Diantha Did' was serialised in 'The Forerunner' from November 1909 to October 1910, and published separately in 1910. The main themes are 'The servant question' and the grief caused by having to do work in which one is not interested; set against a background of future female in-laws who would be ashamed to earn their own living, and a fiance who believes that 'No man - that is a man - would marry a woman and let her run a business.'</p>
Uploader            : AlexBell
Backing up metadata
Notifying calibre of the change

$ calibredb set_metadata 6 --field \#attachmentid:"134208" 

Title               : What Diantha Did
Title sort          : What Diantha Did
Author(s)           : Charlotte Perkins Gilman [Gilman, Charlotte Perkins]
Publisher           : Bellware
Tags                : humanism, servant question, romance
Languages           : eng
Timestamp           : 2015-01-30T09:51:46+00:00
Published           : 2015-01-24T13:00:00+00:00
Identifiers         : mobi-asin:cec96dd0-e53e-4f26-b392-166f8c160ce4
Comments            : <p class="description">'What Diantha Did' was serialised in 'The Forerunner' from November 1909 to October 1910, and published separately in 1910. The main themes are 'The servant question' and the grief caused by having to do work in which one is not interested; set against a background of future female in-laws who would be ashamed to earn their own living, and a fiance who believes that 'No man - that is a man - would marry a woman and let her run a business.'</p>
Uploader            : AlexBell
Attachment ID       : 134208
Backing up metadata
Notifying calibre of the change
Looking good.

Also changing the identifier would work as suggested:

Code:
$ calibredb set_metadata 6 --field identifiers:mobileread:134208

Title               : What Diantha Did
Title sort          : What Diantha Did
Author(s)           : Charlotte Perkins Gilman [Gilman, Charlotte Perkins]
Publisher           : Bellware
Tags                : humanism, servant question, romance
Languages           : eng
Timestamp           : 2015-01-30T11:42:14+00:00
Published           : 2015-01-24T13:00:00+00:00
Identifiers         : mobileread:134208
Comments            : <p class="description">'What Diantha Did' was serialised in 'The Forerunner' from November 1909 to October 1910, and published separately in 1910. The main themes are 'The servant question' and the grief caused by having to do work in which one is not interested; set against a background of future female in-laws who would be ashamed to earn their own living, and a fiance who believes that 'No man - that is a man - would marry a woman and let her run a business.'</p>
Uploader            : AlexBell
Attachment ID       : 134208
Backing up metadata
Notifying calibre of the change
From what I understood performance and schematic wise it's better to use the identifier field for the attachment id rather than a custom field, right?

As Kovid suggested using a small script to parse the filenames and to embed the info via calibredb set_metadata during the import process seems like an easy solution.

@BetterRed, @davidfor, I tested importing the extra metadata via an opf file (which would be another easy solution as I could include all the extra data in the opf while extracting the attachments from the MR database), but it appears that calibre then erases part of the existing metadata.

Code:
$ calibredb add ~/mrlibrary/AlexBell/255021/134208_What\ Diantha\ Did\ -\ Charlotte\ Perkins\ Gilman.mobi   

Backing up metadata
Added book ids: 8
Notifying calibre of the change

$ calibredb show_metadata 8

Title               : What Diantha Did
Title sort          : What Diantha Did
Author(s)           : Charlotte Perkins Gilman [Gilman, Charlotte Perkins]
Publisher           : Bellware
Tags                : romance, humanism, servant question
Languages           : eng
Timestamp           : 2015-01-30T12:18:08+00:00
Published           : 2015-01-24T13:00:00+00:00
Identifiers         : mobi-asin:cec96dd0-e53e-4f26-b392-166f8c160ce4
Comments            : <p class="description">'What Diantha Did' was serialised in 'The Forerunner' from November 1909 to October 1910, and published separately in 1910. The main themes are 'The servant question' and the grief caused by having to do work in which one is not interested; set against a background of future female in-laws who would be ashamed to earn their own living, and a fiance who believes that 'No man - that is a man - would marry a woman and let her run a business.'</p>

$ cat ~/mrlibrary/AlexBell/255021/metadata.opf        
<?xml version='1.0' encoding='utf-8'?>
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id" version="2.0">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
        <meta name="calibre:user_metadata:#uploader" content="{&quot;kind&quot;: &quot;field&quot;, &quot;#value#&quot;: &quot;alex&quot;, &quot;column&quot;: &quot;value&quot;, &quot;colnum&quot;: 1, &quot;is_multiple&quot;: null, &quot;is_multiple2&quot;: {}, &quot;search_terms&quot;: [&quot;#uploader&quot;], &quot;is_csp&quot;: false, &quot;is_category&quot;: true, &quot;table&quot;: &quot;custom_column_1&quot;, &quot;is_custom&quot;: true, &quot;is_editable&quot;: true, &quot;rec_index&quot;: 22, &quot;link_column&quot;: &quot;value&quot;, &quot;label&quot;: &quot;uploader&quot;, &quot;#extra#&quot;: null, &quot;datatype&quot;: &quot;text&quot;, &quot;name&quot;: &quot;Uploader&quot;, &quot;category_sort&quot;: &quot;value&quot;, &quot;display&quot;: {&quot;use_decorations&quot;: 0}}"/>
    </metadata>
</package>

$ calibredb set_metadata 8 ~/mrlibrary/AlexBell/255021/metadata.opf     

Title               : Unknown
Title sort          : Unknown
Author(s)           : Unknown
Publisher           : Bellware
Tags                : romance, humanism, servant question
Languages           : eng
Timestamp           : 2015-01-30T12:18:08+00:00
Published           : 2015-01-24T13:00:00+00:00
Identifiers         : mobi-asin:cec96dd0-e53e-4f26-b392-166f8c160ce4
Comments            : <p class="description">'What Diantha Did' was serialised in 'The Forerunner' from November 1909 to October 1910, and published separately in 1910. The main themes are 'The servant question' and the grief caused by having to do work in which one is not interested; set against a background of future female in-laws who would be ashamed to earn their own living, and a fiance who believes that 'No man - that is a man - would marry a woman and let her run a business.'</p>
Uploader            : alex
Backing up metadata
Notifying calibre of the change
The Uploader field was set correctly, but notice how Title, Title sort and Author are erased?

@davidfor, I love the idea of a metadata source plugin that could translate the attachment id to a relevant URL! Would that be very difficult to write?
Alexander Turcic is offline   Reply With Quote