diff --git a/db/test.json b/db/test.json index af57374..e8eaf31 100644 --- a/db/test.json +++ b/db/test.json @@ -1,10 +1,35 @@ [ { - "id": 1, - "titles": ["testing!"], - "authors": ["nipponeselandian"], - "artists": ["nipponeselandian"], - "last_updated": 1, + "info": + { + "id": 1, + "type": "Manga", + "titles": + [ + "testing!" + ], + "artists": + [ + "artist!" + ], + "authors": + [ + "Sakurai Norio" + ], + "genres": + [ + "Comedy", + "Romance", + "School" + ], + "country_of_origin": "JP", + "publication_status": "Ongoing", + "scanlation_status": true, + "mal_id": 0, + "anilist_id": 0, + "mangaupdates_id": 0, + "last_updated": 1617791510 + }, "chapters": [ { diff --git a/instance.php b/instance.php index 7f9b92b..93b5dee 100644 --- a/instance.php +++ b/instance.php @@ -13,7 +13,7 @@ class ml { foreach ($this->db as $manga) { - if ($manga["id"] == $id) + if ($manga["info"]["id"] == $id) { return($manga); } diff --git a/routes.php b/routes.php index 81c36d4..fe87068 100644 --- a/routes.php +++ b/routes.php @@ -8,12 +8,17 @@ function route($path, $ml) return file_get_contents("db/info.json"); break; case "/manga/search": - return file_get_contents("db/test.json"); + $response = []; + foreach ($ml->db as $manga) + { + array_push($response, $manga["info"]); + } + return json_encode($response); break; case "/manga/from_id": - if (!isset($_GET["id"])) + if (isset($_GET["id"])) { - return json_encode($ml->getManga($_GET["id"])); + return json_encode($ml->getManga($_GET["id"])["info"]); } http_response_code(404); break; @@ -28,13 +33,14 @@ function route($path, $ml) if (isset($_GET["id"])) { header('Content-Type:image/webp'); - readfile("db/thumb/".$_GET["id"].".webp"); + readfile("thumbnail/".$_GET["id"].".webp"); return; } http_response_code(404); break; default: http_response_code(404); + return("lol@".$path); } } ?> \ No newline at end of file diff --git a/db/thumb/1.webp b/thumbnail/1.webp similarity index 100% rename from db/thumb/1.webp rename to thumbnail/1.webp