From 66e8390dce2d96c2def73f0781c0072a26acd8e4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 27 Jul 2020 04:40:33 +0200 Subject: Add date to youtube search results --- src/plugins/Youtube.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 6923d04..b50939e 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -35,6 +35,14 @@ namespace QuickMedia { std::string thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/hqdefault.jpg"; + const char *date = nullptr; + const Json::Value &published_time_text_json = video_renderer_json["publishedTimeText"]; + if(published_time_text_json.isObject()) { + const Json::Value &text_json = published_time_text_json["simpleText"]; + if(text_json.isString()) + date = text_json.asCString(); + } + const char *title = nullptr; const Json::Value &title_json = video_renderer_json["title"]; if(title_json.isObject()) { @@ -53,6 +61,11 @@ namespace QuickMedia { return nullptr; auto body_item = std::make_unique(title); + /* TODO: Make date a different color */ + if(date) { + body_item->title += '\n'; + body_item->title += date; + } 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); -- cgit v1.2.3