From ea6f43514ea470fac399a8155155babfbabec118 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 21 Mar 2022 16:18:59 +0000 Subject: rescribe: Remove unneeded clause and add example urls for gbook id function --- cmd/rescribe/gui.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index 3de29e3..a75b816 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -45,6 +45,9 @@ var trainingNames = map[string]string{ // getBookIdFromUrl returns a 12 character Google Book ID from // a Google URL, or an error if one can't be found. +// Example URLs: +// https://books.google.it/books?id=QjQepCuN8JYC +// https://www.google.it/books/edition/_/VJbr-Oe2au0C func getBookIdFromUrl(url string) (string, error) { lurl := strings.ToLower(url) if len(url) == 12 && !strings.ContainsAny(url, "?/:") { @@ -56,10 +59,6 @@ func getBookIdFromUrl(url string) (string, error) { return "", err } - if matchUrl == false && !strings.HasPrefix(lurl, "https://books.google") { - return "", fmt.Errorf("Not a Google Books URL") - } - if strings.HasPrefix(lurl, "https://books.google") { start := strings.Index(lurl, "?id=") if start == -1 { -- cgit v1.2.1-24-ge1ad