aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-03 03:54:00 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-03 03:54:00 +0200
commit3f0421bea6b37d81d2d66c001b0fac2df91dd702 (patch)
tree560faf05481ba106aec6c79d478d018d02385c52
parentbab24cdda37e93bf87e487d22056361efaf90d50 (diff)
Show youtube play fail reason in notification, more items below correct width!
-rw-r--r--plugins/Page.hpp5
-rw-r--r--plugins/Youtube.hpp4
-rw-r--r--src/QuickMedia.cpp16
-rw-r--r--src/plugins/Youtube.cpp8
4 files changed, 20 insertions, 13 deletions
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 3ecb016..6944afb 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -151,7 +151,10 @@ namespace QuickMedia {
virtual std::string url_get_playable_url(const std::string &url) { return url; }
virtual bool video_should_be_skipped(const std::string &url) { (void)url; return false; }
// This needs to be called before the other functions are called
- virtual PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters) { (void)title; (void)channel_url; (void)chapters; return PluginResult::OK; }
+ virtual PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) {
+ (void)title; (void)channel_url; (void)chapters; (void)err_str;
+ return PluginResult::OK;
+ }
virtual void mark_watched() {};
// Should not do any network request to not slow down video loading
virtual void get_subtitles(SubtitleData &subtitle_data) { (void)subtitle_data; }
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index e2bc2a4..97dea19 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -151,11 +151,11 @@ namespace QuickMedia {
std::string get_url_timestamp() override { return timestamp; }
std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override;
std::string get_audio_url(std::string &ext) override;
- PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters) override;
+ PluginResult load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) override;
void mark_watched() override;
void get_subtitles(SubtitleData &subtitle_data) override;
private:
- PluginResult parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters);
+ PluginResult parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str);
void parse_format(const Json::Value &format_json, bool is_adaptive);
void parse_formats(const Json::Value &streaming_data_json);
private:
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 2157a4d..1b48743 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2254,7 +2254,7 @@ namespace QuickMedia {
more_items_above_rect.setSize(sf::Vector2f(window_size.x, more_items_height));
more_items_below_rect.setPosition(sf::Vector2f(0.0f, window_size.y - more_items_height));
- more_items_below_rect.setSize(sf::Vector2f(window_size.y, more_items_height));
+ more_items_below_rect.setSize(sf::Vector2f(window_size.x, more_items_height));
}
if(tab_associated_data[selected_tab].fetching_next_page_running) {
@@ -2815,12 +2815,13 @@ namespace QuickMedia {
audio_url.clear();
has_embedded_audio = true;
+ std::string err_str;
const int num_retries = is_youtube ? 3 : 1;
bool load_successful = false;
for(int i = 0; i < num_retries; ++i) {
bool cancelled = false;
TaskResult load_result = run_task_with_loading_screen([&]() {
- if(video_page->load(new_title, channel_url, media_chapters) != PluginResult::OK)
+ if(video_page->load(new_title, channel_url, media_chapters, err_str) != PluginResult::OK)
return false;
std::string ext;
@@ -2880,7 +2881,7 @@ namespace QuickMedia {
}
if(!load_successful) {
- show_notification("QuickMedia", "Failed to load media", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to load media" + (err_str.empty() ? "" : ", error: " + err_str), Urgency::CRITICAL);
current_page = previous_page;
go_to_previous_page = true;
return;
@@ -4420,7 +4421,7 @@ namespace QuickMedia {
more_items_above_rect.setSize(sf::Vector2f(window_size.x, more_items_height));
more_items_below_rect.setPosition(sf::Vector2f(0.0f, window_size.y - more_items_height));
- more_items_below_rect.setSize(sf::Vector2f(window_size.y, more_items_height));
+ more_items_below_rect.setSize(sf::Vector2f(window_size.x, more_items_height));
}
//comment_input.update();
@@ -7163,12 +7164,13 @@ namespace QuickMedia {
bool load_successful = false;
const int largest_monitor_height = get_largest_monitor_height(disp);
+ std::string err_str;
for(int i = 0; i < 3; ++i) {
- task_result = run_task_with_loading_screen([this, &youtube_video_page, &filename, &video_url, &audio_url, &video_content_length, &audio_content_length, largest_monitor_height, &cancelled]{
+ task_result = run_task_with_loading_screen([&]{
std::string channel_url;
std::vector<MediaChapter> chapters;
filename.clear();
- if(youtube_video_page->load(filename, channel_url, chapters) != PluginResult::OK)
+ if(youtube_video_page->load(filename, channel_url, chapters, err_str) != PluginResult::OK)
return false;
std::string ext;
@@ -7218,7 +7220,7 @@ namespace QuickMedia {
}
if(!load_successful) {
- show_notification("QuickMedia", "Download failed", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Download failed" + (err_str.empty() ? "" : ", error: " + err_str), Urgency::CRITICAL);
exit_code = 1;
return;
}
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 34fd250..d308346 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2321,7 +2321,7 @@ namespace QuickMedia {
}
}
- PluginResult YoutubeVideoPage::parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters) {
+ PluginResult YoutubeVideoPage::parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) {
livestream_url.clear();
video_formats.clear();
audio_formats.clear();
@@ -2338,6 +2338,8 @@ namespace QuickMedia {
const Json::Value &status_json = playability_status_json["status"];
if(status_json.isString() && (strcmp(status_json.asCString(), "UNPLAYABLE") == 0 || strcmp(status_json.asCString(), "LOGIN_REQUIRED") == 0)) {
const Json::Value &reason_json = playability_status_json["reason"];
+ if(reason_json.isString())
+ err_str = reason_json.asString();
fprintf(stderr, "Unable to play video, status: %s, reason: %s\n", status_json.asCString(), reason_json.isString() ? reason_json.asCString() : "Unknown");
return PluginResult::ERR;
}
@@ -2432,7 +2434,7 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeVideoPage::load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters) {
+ PluginResult YoutubeVideoPage::load(std::string &title, std::string &channel_url, std::vector<MediaChapter> &chapters, std::string &err_str) {
livestream_url.clear();
video_formats.clear();
audio_formats.clear();
@@ -2479,7 +2481,7 @@ R"END(
DownloadResult download_result = download_json(json_root, "https://www.youtube.com/youtubei/v1/player?key=" + api_key + "&gl=US&hl=en", additional_args, true);
if(download_result != DownloadResult::OK) return download_result_to_plugin_result(download_result);
- return parse_video_response(json_root, title, channel_url, chapters);
+ return parse_video_response(json_root, title, channel_url, chapters, err_str);
}
void YoutubeVideoPage::mark_watched() {