aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-08-11 18:35:42 +0200
committerdec05eba <dec05eba@protonmail.com>2021-08-11 18:35:42 +0200
commit2a15b70c229e2e654e69d11f2df2a5ccd7c22f40 (patch)
tree2577867266a479578d1cde033c05627df3852acd /src/plugins
parenta64c0d866a510a7e2838d5d6ba6e292f5215f6a3 (diff)
Youtube: dont update signature while youtube is running
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/youtube/Signature.cpp41
1 files changed, 11 insertions, 30 deletions
diff --git a/src/plugins/youtube/Signature.cpp b/src/plugins/youtube/Signature.cpp
index 102f56e..30c78b6 100644
--- a/src/plugins/youtube/Signature.cpp
+++ b/src/plugins/youtube/Signature.cpp
@@ -16,7 +16,7 @@ namespace QuickMedia {
static YoutubeSignatureDecryptor *instance = nullptr;
static std::mutex update_signature_mutex;
- static const int timeout_default_sec = 60 * 5; // 5 minutes
+ static const int timeout_default_sec = 60 * 10; // 10 minutes
static bool is_whitespace(char c) {
switch(c) {
@@ -158,42 +158,23 @@ namespace QuickMedia {
}
}
+ if(up_to_date)
+ return;
+
running = true;
poll_task = AsyncTask<void>([this]() mutable {
- bool has_notified_error = false;
- int decrypt_function_update_timeout_seconds = timeout_default_sec;
- while(running) {
- time_t time_now = time(nullptr);
- if(time_now - decrypt_function_last_updated > decrypt_function_update_timeout_seconds) {
- int update_res = update_decrypt_function();
- if(update_res != 0) {
- if(!has_notified_error) {
- if(program_is_dead_in_current_thread()) {
- running = false;
- return;
- } else if(update_res == U_DEC_FUN_NET_ERR) {
- show_notification("QuickMedia", "Failed to decrypt youtube signature. Is your internet down?", Urgency::CRITICAL);
- decrypt_function_update_timeout_seconds = 10;
- } else if(update_res == U_DEC_FUN_FAILED_MATCH_ERR) {
- show_notification("QuickMedia", "Failed to decrypt youtube signature. Make sure you are running the latest version of QuickMedia", Urgency::CRITICAL);
- running = false;
- return;
- }
- }
- has_notified_error = true;
- } else {
- decrypt_function_update_timeout_seconds = timeout_default_sec;
- }
+ int update_res = update_decrypt_function();
+ if(update_res != 0 && !program_is_dead_in_current_thread()) {
+ if(update_res == U_DEC_FUN_NET_ERR) {
+ show_notification("QuickMedia", "Failed to decrypt youtube signature. Is your internet down?", Urgency::CRITICAL);
+ } else if(update_res == U_DEC_FUN_FAILED_MATCH_ERR) {
+ show_notification("QuickMedia", "Failed to decrypt youtube signature. Make sure you are running the latest version of QuickMedia", Urgency::CRITICAL);
}
- usleep(1 * 1000 * 1000); // 1 second
}
+ running = false;
});
}
- YoutubeSignatureDecryptor::~YoutubeSignatureDecryptor() {
- running = false;
- }
-
// static
YoutubeSignatureDecryptor& YoutubeSignatureDecryptor::get_instance() {
std::lock_guard<std::mutex> lock(update_signature_mutex);