diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-08-11 18:35:42 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-08-11 18:35:42 +0200 |
commit | 2a15b70c229e2e654e69d11f2df2a5ccd7c22f40 (patch) | |
tree | 2577867266a479578d1cde033c05627df3852acd | |
parent | a64c0d866a510a7e2838d5d6ba6e292f5215f6a3 (diff) |
Youtube: dont update signature while youtube is running
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | plugins/youtube/Signature.hpp | 1 | ||||
-rw-r--r-- | src/plugins/youtube/Signature.cpp | 41 |
3 files changed, 16 insertions, 32 deletions
@@ -192,4 +192,8 @@ Synapse is gay and mentions do not actually include the whole mxid. It only incl Make it possible to redact invites. Reapply filter when changing body item text. When fetching previous messages in matrix, ignore user info updates. -Add throttling to youtube live stream (MediaProxy).
\ No newline at end of file +Add throttling to youtube live stream (MediaProxy). +Use event timestamp to sort display name/room name (etc) events to apply them in order when fetching previous messages or additional messages. +Restart and resume youtube media download in downloader when media is throttled. +Try to reconnect media proxy on disconnect. The internet may be unstable (for example on mobile internet). +Youtube is still getting throttled, but to 500kb/sec from 5mb/sec. How to detect this???.
\ No newline at end of file diff --git a/plugins/youtube/Signature.hpp b/plugins/youtube/Signature.hpp index 01299ee..fc235df 100644 --- a/plugins/youtube/Signature.hpp +++ b/plugins/youtube/Signature.hpp @@ -14,7 +14,6 @@ namespace QuickMedia { bool decrypt(const std::string &s, const std::string &sp, std::string &sig_key, std::string &sig_value); private: YoutubeSignatureDecryptor(); - ~YoutubeSignatureDecryptor(); YoutubeSignatureDecryptor(const YoutubeSignatureDecryptor&) = delete; YoutubeSignatureDecryptor& operator=(const YoutubeSignatureDecryptor&) = delete; 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); |