-
-
Save kemsakurai/9d4290497d561aeef987c2bdf2d9a3fb to your computer and use it in GitHub Desktop.
Amazon Kindle Export Cloud Readerから、kindleの書籍一覧をTSV形式で取得して、クリップボードへコピーする。Chrome dev tools の console で実行する
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
// init | |
let xhr = new XMLHttpRequest() | |
let domain = 'https://read.amazon.co.jp/' | |
let items = [] | |
let tsvData = "" | |
// function | |
function getItemsList(paginationToken = null) { | |
// https://read.amazon.co.jp/kindle-library/search?query=&libraryType=BOOKS&paginationToken=19&sortType=recency&querySize=50 | |
let url = domain + 'kindle-library/search?query=&libraryType=BOOKS' + ( paginationToken ? '&paginationToken=' + paginationToken : '' ) + '&sortType=recency&querySize=50' | |
xhr.open('GET', url, false) | |
xhr.send() | |
} | |
// request result | |
xhr.onreadystatechange = function() { | |
switch ( xhr.readyState ) { | |
case 0: | |
console.log('uninitialized') | |
break | |
case 1: | |
console.log('loading...') | |
break | |
case 4: | |
if(xhr.status == 200) { | |
let data = xhr.responseText | |
data = JSON.parse(data) | |
if(data.itemsList) { | |
items.push(...data.itemsList) | |
} | |
if(data.paginationToken) { | |
getItemsList(data.paginationToken) | |
} | |
} else { | |
console.log('Failed') | |
} | |
break | |
} | |
} | |
// action | |
getItemsList() | |
// to csv | |
items.forEach(item => { | |
// Write out CSV Style | |
tsvData += | |
'"' + item.asin + '"\t"' + item.title + '"\t"' + item.authors + | |
'"\t"' + item.mangaOrComicAsin + | |
'"\t"' + item.percentageRead + | |
'"\t"' + item.productUrl + '"\n' | |
}) | |
copy(tsvData); |
Itemは以下のような形式のJSONで取得できる。(漫画かどうかを示すフラグを持っている)
{
"asin": "B0BZNQ8X92",
"webReaderUrl": "https://read.amazon.co.jp/kindle-library/manga-wr/B0BZNQ8X92",
"productUrl": "https://m.media-amazon.com/images/I/51Z5IEKYwVL._SY400_.jpg",
"title": "ライドンキング(10) (シリウスコミックス) (Japanese Edition)",
"percentageRead": 0,
"authors": [
"馬場康誌:"
],
"resourceType": "EBOOK",
"originType": "PURCHASE",
"mangaOrComicAsin": true
}
共著のケース、authorsは配列になることはなくて、:
区切りの文字列で取得できている。
{
"asin": "B06ZZQP4RR",
"webReaderUrl": "https://read.amazon.co.jp/?asin=B06ZZQP4RR",
"productUrl": "https://m.media-amazon.com/images/I/51EjWwdQQCL._SY400_.jpg",
"title": "初学者のための数論入門 (Japanese Edition)",
"percentageRead": 0,
"authors": [
"西来路文朗:清水健一:"
],
"resourceType": "EBOOK",
"originType": "PURCHASE",
"mangaOrComicAsin": false
}
書誌情報を取得したい場合は、ASINをISBNに変換して、
後は、openBD の APIで取得すれば、良さげ。
openBD | 書誌情報・書影を自由に
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CSV化する方法としては以下のやり方がよさそう。
Chrome 拡張