diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-11-26 20:29:09 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-11-26 20:29:09 +0100 |
commit | c5f465fe6c04afa26fd20ca600457d8de50cf42e (patch) | |
tree | 5801d74b030b22401f7507ae08bc7a1458e23865 /src | |
parent | 2409bd1b0dc0118036c3024fdf19a5dc16a26586 (diff) |
Allow nsfw ecchi in artists/authors page, add option to show h
Diffstat (limited to 'src')
-rw-r--r-- | src/Config.cpp | 7 | ||||
-rw-r--r-- | src/plugins/Mangadex.cpp | 12 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index 570504f..dd7f7ad 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -273,7 +273,7 @@ namespace QuickMedia { for(const DownloadPaths &download_paths : download_paths_list) { const Json::Value &directory_json = download_json[download_paths.json_field]; if(!directory_json.isString()) { - fprintf(stderr, "Warning: config variable config.download.%s is not a string, using path \"%s\" instead\n", download_paths.json_field, download_paths.fallback_dir.c_str()); + fprintf(stderr, "Warning: config variable config.download.%s is not a string, using path \"%s\" or \"%s\" instead\n", download_paths.json_field, download_paths.xdg_var_name, download_paths.fallback_dir.c_str()); continue; } *download_paths.config_var = path_expanduser(directory_json.asString()); @@ -299,6 +299,11 @@ namespace QuickMedia { get_json_value_path(font_json, "symbols", config->font.symbols); } + const Json::Value &mangadex_json = json_root["mangadex"]; + if(mangadex_json.isObject()) { + get_json_value(mangadex_json, "allow_hentai", config->mangadex.allow_hentai); + } + get_json_value(json_root, "use_system_fonts", config->use_system_fonts); get_json_value(json_root, "use_system_mpv_config", config->use_system_mpv_config); get_json_value(json_root, "enable_shaders", config->enable_shaders); diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index bc19536..f517869 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -1,6 +1,7 @@ #include "../../plugins/Mangadex.hpp" #include "../../include/Utils.hpp" #include "../../include/Theme.hpp" +#include "../../include/Config.hpp" #include <json/writer.h> namespace QuickMedia { @@ -62,7 +63,10 @@ namespace QuickMedia { }; static PluginResult search_manga(Page *plugin_page, SearchType search_type, const std::string &query, int page, BodyItems &result_items) { - std::string url = "https://api.mangadex.org/manga?limit=20&order[relevance]=desc&includes[]=cover_art&offset=" + std::to_string(page * 20); + std::string url = "https://api.mangadex.org/manga?limit=20&order[relevance]=desc&includes[]=cover_art&offset=" + std::to_string(page * 20) + "&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica"; + if(get_config().mangadex.allow_hentai) + url += "&contentRating[]=pornographic"; + const std::string query_encoded = url_param_encode(query); switch(search_type) { case SearchType::TITLE: @@ -165,10 +169,12 @@ namespace QuickMedia { } static PluginResult get_chapters_for_manga(Page *page, const std::string &manga_id, int page_num, BodyItems &result_items) { - std::string request_url = "https://api.mangadex.org/manga/" + manga_id + "/feed?order[chapter]=desc&limit=100&translatedLanguage[]=en&offset=" + std::to_string(page_num * 100); + std::string url = "https://api.mangadex.org/manga/" + manga_id + "/feed?order[chapter]=desc&limit=100&translatedLanguage[]=en&offset=" + std::to_string(page_num * 100) + "&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica"; + if(get_config().mangadex.allow_hentai) + url += "&contentRating[]=pornographic"; Json::Value json_root; - if(page->download_json(json_root, request_url, {}, true) != DownloadResult::OK) + if(page->download_json(json_root, url, {}, true) != DownloadResult::OK) return PluginResult::NET_ERR; if(!json_root.isObject()) |