mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 15:20:32 -04:00
Improve Google Books artwork normalization
This commit is contained in:
parent
e17a4bcc65
commit
d4a2c598cc
1 changed files with 5 additions and 2 deletions
|
@ -511,17 +511,20 @@ class Artwork extends PropertiesBase{
|
|||
elseif($parsedUrl['host'] == 'www.google.com'){
|
||||
// New style
|
||||
|
||||
if(!preg_match('|^/books/edition/_/[^/]+$|ius', $parsedUrl['path'])){
|
||||
if(!preg_match('|^/books/edition/[^/]+/[^/]+$|ius', $parsedUrl['path'])){
|
||||
throw new Exceptions\InvalidGoogleBooksUrlException();
|
||||
}
|
||||
|
||||
preg_match('|^/books/edition/[^/]+/([^/]+)$|ius', $parsedUrl['path'], $matches);
|
||||
$id = $matches[1];
|
||||
|
||||
parse_str($parsedUrl['query'] ?? '', $vars);
|
||||
|
||||
if(!isset($vars['gbpv']) || $vars['gbpv'] !== '1' || !isset($vars['pg']) || is_array($vars['pg'])){
|
||||
throw new Exceptions\InvalidGoogleBooksUrlException();
|
||||
}
|
||||
|
||||
$outputUrl = 'https://' . $parsedUrl['host'] . $parsedUrl['path'] . '?gbpv=' . $vars['gbpv'] . '&pg=' . $vars['pg'];
|
||||
$outputUrl = 'https://' . $parsedUrl['host'] . '/books/edition/_/' . $id . '?gbpv=' . $vars['gbpv'] . '&pg=' . $vars['pg'];
|
||||
}
|
||||
else{
|
||||
throw new Exceptions\InvalidGoogleBooksUrlException();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue