diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-11 04:51:03 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-11 04:51:03 +0200 |
commit | 89383cff1ba5d8a928262fcb4c40382a981c78c8 (patch) | |
tree | da8b6062cc6770fd37e7a6f7b8c09fb61f46f7b2 /plugins/youtube | |
parent | 5b3becc79461d4ecf015e33515871cc09e26e04e (diff) |
Remove dependency on youtube-dl for streaming youtube, resulting in faster video startup
Diffstat (limited to 'plugins/youtube')
-rw-r--r-- | plugins/youtube/Signature.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/youtube/Signature.hpp b/plugins/youtube/Signature.hpp new file mode 100644 index 0000000..7456615 --- /dev/null +++ b/plugins/youtube/Signature.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "../../include/AsyncTask.hpp" +#include <string> +#include <vector> +#include <map> +#include <mutex> +#include <time.h> + +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(); + 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<DecryptFuncCall> &new_func_calls, std::map<std::string, DecryptFunction> &new_func_decls); + int update_decrypt_function(); + private: + AsyncTask<void> poll_task; + std::mutex update_signature_mutex; + std::string decryption_function; + time_t decrypt_function_last_updated = 0; + bool running = false; + bool up_to_date = false; + + std::vector<DecryptFuncCall> func_calls; + std::map<std::string, DecryptFunction> func_decls; + }; +}
\ No newline at end of file |