diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/youtube/Signature.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/youtube/Signature.cpp b/src/plugins/youtube/Signature.cpp index 30093d5..2460f8a 100644 --- a/src/plugins/youtube/Signature.cpp +++ b/src/plugins/youtube/Signature.cpp @@ -5,6 +5,7 @@ #include "../../../include/StringUtils.hpp" #include "../../../include/Program.hpp" #include <regex> +#include <mutex> #include <unistd.h> namespace QuickMedia { @@ -14,7 +15,8 @@ namespace QuickMedia { }; static YoutubeSignatureDecryptor *instance = nullptr; - static const int timeout_default_sec = 60; + static std::mutex update_signature_mutex; + static const int timeout_default_sec = 60 * 5; // 5 minutes bool YoutubeSignatureDecryptor::js_code_to_operations(const std::string &function_body_str, const std::string &var_body_str, std::vector<DecryptFuncCall> &new_func_calls, std::map<std::string, DecryptFunction> &new_func_decls) { std::vector<std::string> function_body; @@ -170,6 +172,7 @@ namespace QuickMedia { // static YoutubeSignatureDecryptor& YoutubeSignatureDecryptor::get_instance() { + std::lock_guard<std::mutex> lock(update_signature_mutex); if(!instance) instance = new YoutubeSignatureDecryptor(); return *instance; @@ -183,7 +186,6 @@ namespace QuickMedia { int num_tries = 0; const int max_tries = 30; while(running && num_tries < max_tries && !program_is_dead_in_current_thread()) { // 6 seconds in total - std::lock_guard<std::mutex> lock(update_signature_mutex); if(up_to_date) break; ++num_tries; |