Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMendolia committed Oct 13, 2023
1 parent 814a53d commit eb2e535
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Controller/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function index(Request $request, Book $book, string $slug, BookSuggestion
$openLibraries = (bool) $request->get('openlib', false);
if (!$book->isVerified() && $google === true) {
$suggestions = $bookSuggestions->getGoogleSuggestions($book);
}elseif (!$book->isVerified() && $openLibraries === true) {
} elseif (!$book->isVerified() && $openLibraries === true) {
$suggestions = $bookSuggestions->getCategorySuggestions($book);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public function index(Request $request, Book $book, string $slug, BookSuggestion
#[Route('/download-image/{id}/{image}', name: 'app_book_downloadImage')]
public function downloadImage(Book $book, string $image, BookSuggestions $bookSuggestions, EntityManagerInterface $entityManager, BookFileSystemManager $fileSystemManager): Response
{
$suggestions = $bookSuggestions->getSuggestions($book);
$suggestions = $bookSuggestions->getGoogleSuggestions($book);

$url = $suggestions['image'][$image] ?? null;

Expand Down
11 changes: 6 additions & 5 deletions src/Service/BookSuggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,23 @@ public function getCategorySuggestions(Book $book): array

$mainAuthor = current($book->getAuthors());

$query = ['q'=>'title:'.$book->getTitle().' author:'.$mainAuthor, 'fields'=>'title,author_name,key,cover_i,subject'];
$query = ['q' => 'title:'.$book->getTitle().' author:'.$mainAuthor, 'fields' => 'title,author_name,key,cover_i,subject'];

$client = new \GuzzleHttp\Client();


$results = $client->request('GET','https://openlibrary.org/search.json', ['query'=>$query])->getBody()->getContents();
$results = $client->request('GET', 'https://openlibrary.org/search.json', ['query' => $query])->getBody()->getContents();

$results = json_decode($results, true);

if (!is_array($results) || !array_key_exists('docs', $results)) {
return $suggestions;
}
foreach ($results['docs'] as $result) {

foreach ($result['subject'] as $category) {
$suggestions['tags'][$category] = $category;
}

}

return $suggestions;
}

Expand Down

0 comments on commit eb2e535

Please sign in to comment.