Last active
July 12, 2017 01:12
-
-
Save aarmora/ce4d24f0b28e0c9a187214ece948625a to your computer and use it in GitHub Desktop.
Just paste this into the console of your audible library and run it and it will compile an object of basic information of all the books (shown) in your library. This is brittle and depends on their html structure remaining the same. If they change it, this could no longer work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tables = document.getElementsByTagName('table'); | |
let rows = tables[2].getElementsByTagName('tr'); | |
let books = []; | |
for (let i = 0; i < rows.length; i++) { | |
try { | |
// It's generally a normal row if there is a fourth cell | |
if (rows[i].cells[3]) { | |
let url = rows[i].cells[3].children[0].href; | |
let title = rows[i].cells[3].children[0].innerText; | |
let author = ""; | |
if (rows[i].cells[4].children) { | |
author = rows[i].cells[4].children[0].innerText; | |
} | |
let length = ""; | |
if (rows[i].cells[5].children[0]) { | |
length = rows[i].cells[5].children[0].innerText; | |
} | |
let imageUrl = rows[i].cells[1].children[0].src | |
let book = { | |
url: url, | |
title: title, | |
author: author, | |
length: length, | |
imageUrl: imageUrl | |
} | |
// Child rows (books with multiple parts) don't have imageUrls | |
if (imageUrl) { | |
// Replace image url with better quality | |
book.imageUrl = book.imageUrl.replace("SL80", "SL300"); | |
books.push(book); | |
} | |
} | |
} catch (error) { | |
console.log(`Error in ${i} `, rows[i], error); | |
} | |
} | |
console.log("pretty books", books); | |
console.log("Stringified books", JSON.stringify(books)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment