diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-08 20:31:30 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-08 20:31:30 +0200 |
commit | d0dda48e791e6f08f6be3936623a2c305caacb3c (patch) | |
tree | 0e1289c3034ad30235f84df54a4884661aee0c23 /src/plugins/Peertube.cpp | |
parent | 215ac920166087ffcf917c293caf6497adf50c3d (diff) |
Peertube: load known instances from config file
Diffstat (limited to 'src/plugins/Peertube.cpp')
-rw-r--r-- | src/plugins/Peertube.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp index 4fb2ac4..6d55e16 100644 --- a/src/plugins/Peertube.cpp +++ b/src/plugins/Peertube.cpp @@ -3,6 +3,7 @@ #include "../../include/Notification.hpp" #include "../../include/Utils.hpp" #include "../../include/StringUtils.hpp" +#include "../../include/Config.hpp" #include <json/value.h> namespace QuickMedia { @@ -27,23 +28,19 @@ namespace QuickMedia { } PluginResult PeertubeInstanceSelectionPage::lazy_fetch(BodyItems &result_items) { - result_items.push_back(create_instance_selection_item("tube.midov.pl", "https://tube.midov.pl")); - result_items.push_back(create_instance_selection_item("videos.lukesmith.xyz", "https://videos.lukesmith.xyz")); - result_items.push_back(create_instance_selection_item("peertube.se", "https://peertube.se")); - result_items.push_back(create_instance_selection_item("bittube.video", "https://bittube.video")); - result_items.push_back(create_instance_selection_item("video.nobodyhasthe.biz", "https://video.nobodyhasthe.biz")); - result_items.push_back(create_instance_selection_item("libre.tube", "https://libre.tube")); - result_items.push_back(create_instance_selection_item("open.tube", "https://open.tube")); - result_items.push_back(create_instance_selection_item("runtube.re", "https://runtube.re")); - result_items.push_back(create_instance_selection_item("tube.kenfm.de", "https://tube.kenfm.de")); - result_items.push_back(create_instance_selection_item("tcode.kenfm.de", "https://tcode.kenfm.de")); - result_items.push_back(create_instance_selection_item("tube.querdenken-711.de", "https://tube.querdenken-711.de")); - result_items.push_back(create_instance_selection_item("peertube.rage.lol", "https://peertube.rage.lol")); - result_items.push_back(create_instance_selection_item("gegenstimme.tv", "https://gegenstimme.tv")); - result_items.push_back(create_instance_selection_item("tv.poa.st", "https://tv.poa.st")); - result_items.push_back(create_instance_selection_item("libre.video", "https://libre.video")); - result_items.push_back(create_instance_selection_item("gorf.tube", "https://gorf.tube")); - result_items.push_back(create_instance_selection_item("neogenesis.tv", "https://neogenesis.tv")); + for(const std::string &known_instance : get_config().peertube.known_instances) { + std::string homeserver_name = known_instance; + if(!homeserver_name.empty() && homeserver_name.back() == '/') + homeserver_name.pop_back(); + + if(string_starts_with(homeserver_name, "http://")) + homeserver_name.erase(homeserver_name.begin(), homeserver_name.begin() + 7); + + if(string_starts_with(homeserver_name, "https://")) + homeserver_name.erase(homeserver_name.begin(), homeserver_name.begin() + 8); + + result_items.push_back(create_instance_selection_item(homeserver_name, known_instance)); + } return PluginResult::OK; } |