aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Youtube.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 3b4a752..2827d83 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -43,6 +43,14 @@ namespace QuickMedia {
date = text_json.asCString();
}
+ const char *length = nullptr;
+ const Json::Value &length_text_json = video_renderer_json["lengthText"];
+ if(length_text_json.isObject()) {
+ const Json::Value &text_json = length_text_json["simpleText"];
+ if(text_json.isString())
+ length = text_json.asCString();
+ }
+
const char *title = nullptr;
const Json::Value &title_json = video_renderer_json["title"];
if(title_json.isObject()) {
@@ -62,8 +70,15 @@ namespace QuickMedia {
auto body_item = std::make_unique<BodyItem>(title);
/* TODO: Make date a different color */
+ std::string date_str;
if(date)
- body_item->set_description(date);
+ date_str += date;
+ if(length) {
+ if(!date_str.empty())
+ date_str += '\n';
+ date_str += length;
+ }
+ body_item->set_description(std::move(date_str));
body_item->url = "https://www.youtube.com/watch?v=" + video_id_str;
body_item->thumbnail_url = std::move(thumbnail_url);
added_videos.insert(video_id_str);
@@ -452,6 +467,14 @@ namespace QuickMedia {
date = text_json.asCString();
}
+ const char *length = nullptr;
+ const Json::Value &length_text_json = compact_video_renderer_json["lengthText"];
+ if(length_text_json.isObject()) {
+ const Json::Value &text_json = length_text_json["simpleText"];
+ if(text_json.isString())
+ length = text_json.asCString();
+ }
+
const char *title = nullptr;
const Json::Value &title_json = compact_video_renderer_json["title"];
if(title_json.isObject()) {
@@ -466,8 +489,15 @@ namespace QuickMedia {
auto body_item = std::make_unique<BodyItem>(title);
/* TODO: Make date a different color */
+ std::string date_str;
if(date)
- body_item->set_description(date);
+ date_str += date;
+ if(length) {
+ if(!date_str.empty())
+ date_str += '\n';
+ date_str += length;
+ }
+ body_item->set_description(std::move(date_str));
body_item->url = "https://www.youtube.com/watch?v=" + video_id_str;
body_item->thumbnail_url = std::move(thumbnail_url);
added_videos.insert(video_id_str);