Use actual video publication date if availiable

This commit add usage of the video publication date in addition to the
"Added to playlist" date that was used up to this point. This improves
the video list behavior for channels which upload videos and add them to
the playlists a while before the actual publication date. Before these
published, but old in the playlist videos would show up at their upload
date instead of the publication date which is the relevant one for this
application. The "added to playlist" date is still recorded and being kept.
This commit is contained in:
Daniel Schulte 2021-07-18 16:39:32 +02:00
parent b77cd9c227
commit 17b8727f62
3 changed files with 21 additions and 15 deletions

View file

@ -118,7 +118,8 @@ void draw_channel_list(const std::vector<Video> &videos, bool show_channel_name=
struct tm tm;
memset(&tm, 0, sizeof(tm));
if(strptime(video.published.c_str(), "%FT%T%z", &tm) != nullptr) {
const std::string &date_str = !video.published.empty() ? video.published : video.added_to_playlist;
if(strptime(date_str.c_str(), "%FT%T%z", &tm) != nullptr) {
strftime(dt.data(), date_width + 10, "%F %H:%M", &tm);
}