aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Pipe.cpp
blob: 5d7d2699829ec83baac46ed0bda348b2a8719ee8 (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
30
31
32
33
#include "../../plugins/Pipe.hpp"
#include <string>
#include <iostream>

namespace QuickMedia {
    PluginResult PipePage::submit(const std::string &title, const std::string&, std::vector<Tab> &result_tabs) {
        puts(title.c_str());
        return PluginResult::OK;
    }

    // static
    void PipePage::load_body_items_from_stdin(BodyItems &items) {
        std::string line;
        while(std::getline(std::cin, line)) {
            std::string name;
            std::string filepath;
            size_t split_index = line.find('|');
            if(split_index == std::string::npos) {
                name = std::move(line);
            } else {
                name = line.substr(0, split_index);
                filepath = line.substr(split_index + 1);
            }

            auto body_item = BodyItem::create(std::move(name));
            if(!filepath.empty()) {
                body_item->thumbnail_url = std::move(filepath);
                body_item->thumbnail_is_local = true;
            }
            items.push_back(std::move(body_item));
        }
    }
}