Integrate physical book library with epub/pdf/audiobook library

Having gone all in with DT3, all of sources of books are now imported into DT. I like that in any one group I can see the various formats of a particular author along with a bookmark for a wiki page, a relevant article, or an interview. Now, I would like to add an entry for each of my physical books. Currently, I have them all in a web database called Libib. From there, I can export a .csv file and import it into DT. This allows me to page through each record in the .csv file. Very nifty but I’d rather have an individual record of each book that I can place in various groups and DT databases. I haven’t found a specific thread on here which addresses that. I looked into the Bookends app but that’s not what I need. Any suggestions would be appreciated.

You could create records from the csv with a script.

Screen captures or clarification of what you’re hoping to do in DEVONthink could be helpful.

I would like to create a DT record, whether it’s a formatted note or sheet, from my my web entries which look like (see attached). I can only export all of the book entries from Libib (Main Site - https://www.libib.com) as one .csv file. (I could attach that if you wish). If it would involve scripting, I could use some advice on how to implement one.

And would you be expecting the item(s) in DEVONthink to look like they’re shown in your screen capture?
If so, it’s unlikely the CSV file would contain that kind of data - though yes, you could ZIP and post a .CSV file, if you’d like.

I would like the Dt record to include the book cover, book description, publish date, ISBN–the basic book info but it needn’t visually look the same as the Libib entries. Here’s the ,csv file. Thanks for having a look.

library_20210724104528.csv.zip (66.7 KB)

You’re welcome.
As I suspected, the book cover art is not referenced in the CSV.

1 Like

Right…I saw that in my import. It’s not a deal-breaker. I can always add in the art a bit at a time from other sources…

I did this with Bookpedia - Bookpedia - it will scan and look up info. from bar codes with a cheap USB reader. I think I added about 600 books, then exported all the details to BibTeX & thence to BibDesk where it’s easy to automate adding a search for the cover images.

1 Like

Sounds god for your use case. I’ve already got my books scanned into Libib and just want to get them into DT.

As I mentioned before, scripting might help. A very basic starter in JavaScript:

//x-devonthink-item://A99A22C6-952C-4D30-89D8-1DD2398B3682

(() => {
    const UUID = "A99A22C6-952C-4D30-89D8-1DD2398B3682";

	const app = Application("DEVONthink 3");
	app.includeStandardAdditions = true; 
	const dbName = "books"
	let db = app.databases[dbName];
	
	/* If database does not exist, create it. The stuipid try/catch
	    block is needed because db is _never_ undefined, even if the
		database does not exist */
		
	try {
	  let dbPath = db.path();
	} catch {
	  /* get path of first DB (zero'th seems to be inbox sometimes */
	  const basePath = app.databases[1].path();
	  let targetPath = basePath.split('/').slice(0, -1).join('/') + `/${dbName}.dtBase2`;
	  
	  /* create new DB at same location in filesystem as DB 1 */
	  db = app.createDatabase(targetPath);
	
	}
	
	/* Get or create group "imported" in the database */
	const dbGroup =  app.createLocation("/imported", {in: db});

	/* Get all rows from the table */
	const rows = app.getRecordWithUuid(UUID).cells();

	/* Loop over all rows in table 
	   for each row, create a new markdown record named after the title of the book
	   set it's contents to some basic metadata including the description
	   Note: No styling here, the rendered MD looks ugly. 
	   Note2: Accessing the columns with numerial indices is error-prone, one should better use
	          constants with meaningful names like "authorCol", "titleCol" etc. 
	   */

	rows.forEach(r => {
      const rec = app.createRecordWith({name: r[3], type: "markdown", plainText:""}, {in: dbGroup});	
	  let plainText = `# ${r[3]}\n\n## by ${r[0]}\n\n## Published ${r[16]||"not known"} at ${r[17]}\n\n`;
	  plainText += `## ${r[18]|| "unknown"} pages\n\n## Description: \n${r[4]}\n`;
	  rec.plainText = plainText;
	})
})()

This assumes that you’ve imported the CSV file into DT already, and the string in getRecordWithUuid refers to the UUID of this file.

This small thingy creates a record for each row in the table in the group “imported” in table “books”. Table and group are created if necessary. This is just a proof of concept, not the complete solution. Therefore, the code is particularly ugly and peppered with parenthesis, brackets, and all that.

I’m just not sure that I see the point of this exercise. First, there’s erroneous data in the CSV already (I noted an ISBN-13 that is considerably shorter than 13 characters and another ISBN that is obviously meant to be a price). Second, importing semi-structured data into unstructured notes is bound to loose a ton of useful information. How are you goint to recognize the author, isbn, pages, whatever in a mardown file or a note? Yes, you could use class names or ids in HTML, but that’s just a translation from one flawed format (for this purpose!) to another one.

3 Likes

I appreciate you taking the time to look into this. I think I’ll just start from scratch since there’s only around 300 books. Would you have a recommendation on the type of DT note I could implement to make a record of each book?

Perhaps a rich text template or a Markdown template depending on your preference

1 Like