Set updated at timestamp for videos
Since the metadata only provides a date, set the time part to 12:00:00 (UTC). Also fix up the deprecation warning for the creation of the initial zero last build timestamp.
This commit is contained in:
parent
9f88f4f9a3
commit
4177e1c6f9
|
@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use async_trait::async_trait;
|
||||
use cached::proc_macro::cached;
|
||||
use chrono::Utc;
|
||||
use chrono::{DateTime, Utc};
|
||||
use reqwest::Url;
|
||||
use rocket::futures::StreamExt;
|
||||
use ytextract::playlist::video::{Error as YouTubeVideoError, Video as YouTubePlaylistVideo};
|
||||
|
@ -197,6 +197,11 @@ impl From<YouTubeVideoWithStream> for Item {
|
|||
.iter()
|
||||
.max_by_key(|tn| tn.width * tn.height)
|
||||
.map(|tn| tn.url.clone());
|
||||
let timestamp = video
|
||||
.date()
|
||||
.and_hms_opt(12, 0, 0)
|
||||
.expect("Invalid hour, minute and/or second");
|
||||
let updated_at = DateTime::from_utc(timestamp, Utc);
|
||||
|
||||
Item {
|
||||
title: video.title().to_string(),
|
||||
|
@ -208,7 +213,7 @@ impl From<YouTubeVideoWithStream> for Item {
|
|||
guid: id,
|
||||
keywords: Default::default(),
|
||||
image,
|
||||
updated_at: Utc::now(), // TODO: Get a decent timestamp somewhere?!
|
||||
updated_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ pub(crate) fn construct(backend_id: &str, config: &Config, channel: Channel) ->
|
|||
.unwrap_or_default(),
|
||||
)
|
||||
.build();
|
||||
let mut last_build = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(0, 0), Utc);
|
||||
let unix_timestamp = NaiveDateTime::from_timestamp_opt(0, 0)
|
||||
.expect("Out-of-range seconds or invalid nanoseconds");
|
||||
let mut last_build = DateTime::from_utc(unix_timestamp, Utc);
|
||||
let generator = String::from(concat!(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
" ",
|
||||
|
|
Loading…
Reference in New Issue