#pragma once #include "../../include/AsyncTask.hpp" #include #include #include #include namespace QuickMedia { // Thread safe class YoutubeSignatureDecryptor { public: static YoutubeSignatureDecryptor& get_instance(); bool decrypt(const std::string &s, const std::string &sp, std::string &sig_key, std::string &sig_value); private: YoutubeSignatureDecryptor(); YoutubeSignatureDecryptor(const YoutubeSignatureDecryptor&) = delete; YoutubeSignatureDecryptor& operator=(const YoutubeSignatureDecryptor&) = delete; struct DecryptFuncCall { std::string func_name; long arg; }; enum class DecryptFunction { REVERSE, SPLICE, SWAP }; bool js_code_to_operations(const std::string &function_body_str, const std::string &var_body_str, std::vector &new_func_calls, std::map &new_func_decls); int update_decrypt_function(); private: // TODO: Remove this task and instead add the network download task to a queue and add a poll function to check if it has finished downloading // or if it needs to be updated. AsyncTask poll_task; std::string decryption_function; time_t decrypt_function_last_updated = 0; bool running = false; bool up_to_date = false; std::vector func_calls; std::map func_decls; }; }