Skip to content

Commit

Permalink
Only do vid, if it is not an ISBN
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Dec 21, 2024
1 parent 1e7f543 commit 8d7db9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -3827,9 +3827,14 @@ public function clean_google_books(): void
if (preg_match('~^https?://books\.google\..*id\&\#61\;.*$~', $url, $matches)) {
$url = str_replace('=', '=', $url);
}
if (preg_match('~^https?://books\.google\.[^/]+/(?:books|)\?[qv]id=(.+)$~', $url, $matches)) {
if (preg_match('~^https?://books\.google\.[^/]+/(?:books|)\?qid=(.+)$~', $url, $matches)) {
$url = 'https://books.google.com/books?id=' . $matches[1];
}
if (preg_match('~^https?://books\.google\.[^/]+/(?:books|)\?vid=(.+)$~', $url, $matches)) {
if (str_ireplace(['isbn', 'lccn', 'oclc'], '', $matches[1]) === $matches[1]) {
$url = 'https://books.google.com/books?id=' . $matches[1];
}
}
if (preg_match('~^https?://(?:|www\.)books\.google\.com/\?id=(.+)$~', $url, $matches)) {
$url = 'https://books.google.com/books?id=' . $matches[1];
}
Expand Down

0 comments on commit 8d7db9c

Please sign in to comment.