From 845a8f793698e64a65e0bbc6c47a77904866d240 Mon Sep 17 00:00:00 2001 From: July Date: Sun, 28 May 2023 12:23:01 -0400 Subject: [PATCH] [MangaDexBridge] Add option to add chapter images to entries (#3412) --- bridges/MangaDexBridge.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/bridges/MangaDexBridge.php b/bridges/MangaDexBridge.php index 143cd732..009d2532 100644 --- a/bridges/MangaDexBridge.php +++ b/bridges/MangaDexBridge.php @@ -21,6 +21,18 @@ class MangaDexBridge extends BridgeAbstract 'exampleValue' => 'en,jp', 'required' => false ], + 'images' => [ + 'name' => 'Fetch chapter page images', + 'type' => 'list', + 'title' => 'Places chapter images in feed contents. Entries will consume more bandwidth.', + 'defaultValue' => 'no', + 'values' => [ + 'None' => 'no', + 'Data Saver' => 'saver', + 'Full Quality' => 'yes' + ] + ] + ], 'Title Chapters' => [ 'url' => [ @@ -239,6 +251,27 @@ class MangaDexBridge extends BridgeAbstract $item['content'] .= '
Other Users: ' . implode(', ', $users); } + // Fetch chapter page images if desired and add to content + if ($this->getInput('images') !== 'no') { + $api_uri = self::API_ROOT . 'at-home/server/' . $item['uid']; + $header = [ 'Content-Type: application/json' ]; + $pages = json_decode(getContents($api_uri, $header), true); + if ($pages['result'] != 'ok') { + returnServerError('Could not retrieve API results'); + } + + if ($this->getInput('images') == 'saver') { + $page_base = $pages['baseUrl'] . '/data-saver/' . $pages['chapter']['hash'] . '/'; + foreach ($pages['chapter']['dataSaver'] as $image) { + $item['content'] .= '
'; + } + } else { + $page_base = $pages['baseUrl'] . '/data/' . $pages['chapter']['hash'] . '/'; + foreach ($pages['chapter']['data'] as $image) { + $item['content'] .= '
'; + } + } + } $this->items[] = $item; } }