aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Manga.cpp
blob: 3fa5d47746d9f8dd114b648f63d89bd0d19ca65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "../../plugins/Manga.hpp"
#include "../../include/Program.hpp"
#include "../../include/Notification.hpp"

namespace QuickMedia {
    TrackResult MangaChaptersPage::track(const std::string &str) {
        const char *args[] = { "automedia", "add", "html", content_url.data(), "--start-after", str.data(), "--name", content_title.data(), nullptr };
        if(exec_program(args, nullptr, nullptr) == 0) {
            show_notification("QuickMedia", "You are now tracking \"" + content_title + "\" after \"" + str + "\"", Urgency::LOW);
            return TrackResult::OK;
        } else {
            show_notification("QuickMedia", "Failed to track media \"" + content_title + "\", chapter: \"" + str + "\"", Urgency::CRITICAL);
            return TrackResult::ERR;
        }
    }

    void MangaChaptersPage::on_navigate_to_page(Body *body) {
        (void)body;
        std::string manga_id;
        if(extract_id_from_url(content_url, manga_id))
            load_manga_content_storage(get_service_name(), content_title, manga_id);
    }

    std::shared_ptr<BodyItem> MangaChaptersPage::get_bookmark_body_item() {
        auto body_item = std::make_shared<BodyItem>(content_title);
        body_item->url = content_url;
        return body_item;
    }
}