diff options
author | Nick White <git@njw.name> | 2022-03-21 16:18:59 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2022-03-21 16:18:59 +0000 |
commit | ea6f43514ea470fac399a8155155babfbabec118 (patch) | |
tree | 059540d1f88b9152ccc82a04a622faaf0a544c44 | |
parent | fd50c673c5dc4f42c9ad11a75120b86f1122446a (diff) |
rescribe: Remove unneeded clause and add example urls for gbook id function
-rw-r--r-- | cmd/rescribe/gui.go | 7 |
1 files 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 { |