diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-27 04:40:33 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-27 04:40:33 +0200 |
commit | 66e8390dce2d96c2def73f0781c0072a26acd8e4 (patch) | |
tree | e57afa85b96163968fc84075d2cea23dd24d8b06 /src | |
parent | ad1077586958cae19acbe925b0be354902a7cb9e (diff) |
Add date to youtube search results
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Youtube.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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<BodyItem>(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); |