refactor
This commit is contained in:
parent
f91e826e36
commit
8b06509084
@ -17,17 +17,23 @@
|
|||||||
#include "utils/windows.hpp"
|
#include "utils/windows.hpp"
|
||||||
|
|
||||||
namespace monitarr {
|
namespace monitarr {
|
||||||
|
[[nodiscard]] static auto create_client(const server_cfg &server)
|
||||||
|
-> httplib::Client {
|
||||||
|
httplib::Client cli{server.url};
|
||||||
|
cli.set_default_headers({
|
||||||
|
{"X-Api-Key", server.api_key},
|
||||||
|
});
|
||||||
|
|
||||||
|
return cli;
|
||||||
|
}
|
||||||
|
|
||||||
static void remove_stalled(std::string_view download_id, std::string_view title,
|
static void remove_stalled(std::string_view download_id, std::string_view title,
|
||||||
std::uint64_t episode_id, std::uint64_t movie_id,
|
std::uint64_t episode_id, std::uint64_t movie_id,
|
||||||
const server_cfg &server, data_db &state_db) {
|
const server_cfg &server, data_db &state_db) {
|
||||||
fmt::println("remove and block {}|{}", download_id, title);
|
fmt::println("remove and block {}|{}", download_id, title);
|
||||||
state_db.remove(download_id);
|
state_db.remove(download_id);
|
||||||
|
|
||||||
httplib::Client cli{server.url};
|
auto cli = create_client(server);
|
||||||
cli.set_default_headers({
|
|
||||||
{"X-Api-Key", server.api_key},
|
|
||||||
});
|
|
||||||
|
|
||||||
auto response = cli.Delete(
|
auto response = cli.Delete(
|
||||||
fmt::format("/api/{}/queue/{}?blocklist=true&skipRedownload=false",
|
fmt::format("/api/{}/queue/{}?blocklist=true&skipRedownload=false",
|
||||||
server.api_version,
|
server.api_version,
|
||||||
@ -69,10 +75,7 @@ static void remove_stalled(std::string_view download_id, std::string_view title,
|
|||||||
static void check_server(const server_cfg &server, data_db &state_db) {
|
static void check_server(const server_cfg &server, data_db &state_db) {
|
||||||
fmt::println("checking server|{}|{}", server.id, server.url);
|
fmt::println("checking server|{}|{}", server.id, server.url);
|
||||||
|
|
||||||
httplib::Client cli{server.url};
|
auto cli = create_client(server);
|
||||||
cli.set_default_headers({
|
|
||||||
{"X-Api-Key", server.api_key},
|
|
||||||
});
|
|
||||||
|
|
||||||
std::uint16_t page{0U};
|
std::uint16_t page{0U};
|
||||||
while (++page != 0U) {
|
while (++page != 0U) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user