Skip to content

Commit

Permalink
add compatibility to unavailable images caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsgsDesign committed Dec 5, 2021
1 parent b87ce7e commit bda2f4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ private function cacheImage($dom)
$imageResponse = $this->getCodeForcesResponse($url);
$extensions = ['image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif', 'image/bmp' => '.bmp'];
if (isset($imageResponse->headers['content-type'])) {
if(!isset($extensions[$imageResponse->headers['content-type']])) {
continue; // image illegal
}
$extension = $extensions[$imageResponse->headers['content-type']];
} else {
$extension = pathinfo($imageElement->src, PATHINFO_EXTENSION);
Expand Down
2 changes: 1 addition & 1 deletion babel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "CodeForces Gym Interface for NOJ",
"license": "MIT",
"repository": "https://github.com/NJUPTAAA/NOJ_Extension_CodeForces_Gym",
"version": "0.1.5",
"version": "0.1.6",
"website": "https://codeforces.com/gyms",
"custom": {
"css": "resources/custom.css"
Expand Down

0 comments on commit bda2f4e

Please sign in to comment.