aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-09 12:59:07 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-09 13:01:45 +0200
commitc90eab0046f95b5ff20e85be46fa4d70d451f3b6 (patch)
treec8f779edb66a2ff60c9be0b95f0940cee6a36180 /src/plugins
parent7492c9aa0df61e7bd7e136679a0ef90414ed1283 (diff)
Handle youtube cookies initialization failure, reorder youtube tabs
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 0f5e807..0fcf61d 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -384,11 +384,9 @@ namespace QuickMedia {
Path cookies_filepath_p;
if(get_cookies_filepath(cookies_filepath_p, "youtube") != 0) {
show_notification("QuickMedia", "Failed to create youtube cookies file", Urgency::CRITICAL);
- abort();
+ return {};
}
- cookies_filepath = cookies_filepath_p.data;
-
// TODO: Re-enable this if the api key ever changes in the future
#if 0
//api_key = youtube_page_find_api_key();
@@ -396,12 +394,20 @@ namespace QuickMedia {
api_key = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
#endif
- if(get_file_type(cookies_filepath_p) != FileType::REGULAR) {
+ if(get_file_type(cookies_filepath_p) == FileType::REGULAR) {
+ cookies_filepath = cookies_filepath_p.data;
+ } else {
+ Path cookies_filepath_tmp = cookies_filepath_p;
+ cookies_filepath_tmp.append(".tmp");
+
// TODO: Is there any way to bypass this? this is needed to set VISITOR_INFO1_LIVE which is required to read comments
- const char *args[] = { "curl", "-I", "-s", "-b", cookies_filepath.c_str(), "-c", cookies_filepath.c_str(), "https://www.youtube.com/subscription_manager?disable_polymer=1", nullptr };
- if(exec_program(args, nullptr, nullptr) != 0) {
+ const char *args[] = { "curl", "-I", "-s", "-f", "-L", "-b", cookies_filepath_tmp.data.c_str(), "-c", cookies_filepath_tmp.data.c_str(), "https://www.youtube.com/subscription_manager?disable_polymer=1", nullptr };
+ if(exec_program(args, nullptr, nullptr) == 0) {
+ rename_atomic(cookies_filepath_tmp.data.c_str(), cookies_filepath_p.data.c_str());
+ cookies_filepath = cookies_filepath_p.data;
+ } else {
show_notification("QuickMedia", "Failed to fetch cookies to view youtube comments", Urgency::CRITICAL);
- abort();
+ return {};
}
}
}