Good Reads Lookup
Find books on GoodReads.
Samples
import ch.derlin.grmetafetcher.GoodReadsLookup
import ch.derlin.grmetafetcher.GoodReadsMetadata
import ch.derlin.grmetafetcher.GoodReadsPaginatedSearchResults
import ch.derlin.grmetafetcher.Retry
import ch.derlin.grmetafetcher.RetryConfiguration
fun main() {
//sampleStart
val p: (GoodReadsMetadata) -> Unit = { println(it.toCompilableString()) }
// very shot titles need authors to match
p(GoodReadsMetadata.lookup(title = "substance", author = "claro"))
// Authors will match without the initials, and can be ignored in search for specific/long enough titles
p(GoodReadsMetadata.lookup("House of Leaves", "Mark Danielewski", includeAuthorInSearch = false))
// Subtitle can be ignored in lookup
p(GoodReadsMetadata.lookup(title = "Masters of Doom"))
// The same can be achieved using GoodReadsLookup // accents don't matter
p(GoodReadsLookup(title = "la cle de salomon").findBestMatch().getMetadata())
// If you know the URL or GoodReads ID, you can use them directly
p(GoodReadsMetadata.fromGoodReadsId("41940388"))
//sampleEnd
}
import ch.derlin.grmetafetcher.GoodReadsLookup
import ch.derlin.grmetafetcher.GoodReadsMetadata
import ch.derlin.grmetafetcher.GoodReadsPaginatedSearchResults
import ch.derlin.grmetafetcher.Retry
import ch.derlin.grmetafetcher.RetryConfiguration
fun main() {
//sampleStart
val reader = java.util.Scanner(System.`in`)
print("Enter a book title: ")
val title = reader.nextLine()
print("Enter an author (press enter for none): ")
val author = reader.nextLine().ifBlank { null }
val matches = GoodReadsLookup(title = title, author = author).getMatches()
println("\nResults:")
matches.indices.take(10).forEach { println(" [$it] ${matches[it].title} by ${matches[it].authorsStr}") }
print("\nEnter the index of the book you want: ")
val index = reader.nextInt()
println("\nMetadata:")
println(matches[index].getMetadata().toCompilableString())
//sampleEnd
}
Constructors
Functions
Search and try to find the best match for the given title (and maybe authors) on GoodReads.
Get the list of matches for the given search query (see searchUrl). Note that only the results appearing on the first page are returned, hence a maximum of 20 results.
Get the list of matches for the given search query (see searchUrl), paginated.
Should return the String representation of this class as a compilable snippet (can be copy-pasted into Kotlin code).
Properties
The (partial) author(s) to look for. If multiple authors, they can be separated by any of ,
,
or &
. If you plan to use findBestMatch, the author should at least match the first author in the form "FirstName Lastname".
The (partial) title to look for. If you plan to use findBestMatch, the title should be "exact".