Bump the depend on ytextract

This newer version is able to correctly parse the date of streamed
videos.

Also use the full `ytextract::Video` structs which should have have all
the metadata.
This commit is contained in:
Paul van Tilburg 2022-12-19 21:38:12 +01:00
parent 94121c0828
commit 9f88f4f9a3
Signed by: paul
GPG Key ID: C6DE073EDA9EEC4D
3 changed files with 61 additions and 12 deletions

61
Cargo.lock generated
View File

@ -435,6 +435,16 @@ dependencies = [
"darling_macro 0.13.4",
]
[[package]]
name = "darling"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa"
dependencies = [
"darling_core 0.14.2",
"darling_macro 0.14.2",
]
[[package]]
name = "darling_core"
version = "0.12.4"
@ -463,6 +473,20 @@ dependencies = [
"syn",
]
[[package]]
name = "darling_core"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.12.4"
@ -485,6 +509,17 @@ dependencies = [
"syn",
]
[[package]]
name = "darling_macro"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e"
dependencies = [
"darling_core 0.14.2",
"quote",
"syn",
]
[[package]]
name = "derive_builder"
version = "0.10.2"
@ -875,6 +910,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hkdf"
version = "0.12.3"
@ -2115,21 +2156,27 @@ dependencies = [
[[package]]
name = "serde_with"
version = "1.14.0"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff"
checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef"
dependencies = [
"base64 0.13.1",
"chrono",
"hex",
"indexmap",
"serde",
"serde_json",
"serde_with_macros",
"time 0.3.17",
]
[[package]]
name = "serde_with_macros"
version = "1.5.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082"
checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa"
dependencies = [
"darling 0.13.4",
"darling 0.14.2",
"proc-macro2",
"quote",
"syn",
@ -3077,9 +3124,9 @@ dependencies = [
[[package]]
name = "ytextract"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca88fc42bde556e9f8343d9f0f8a13eba27f54445529dbb6df3b69fea52236a2"
checksum = "d23e95563efc0a066ac0e6491ecd7012940ef495ce050c9f09de145a034ccabf"
dependencies = [
"async-stream",
"base64 0.13.1",

View File

@ -20,7 +20,7 @@ rss = "2.0.1"
thiserror = "1.0.31"
url = { version = "2.2.2", features = ["serde"] }
youtube_dl = { version = "0.7.0", features = ["tokio"] }
ytextract = "0.11.0"
ytextract = "0.11.1"
[package.metadata.deb]
maintainer = "Paul van Tilburg <paul@luon.net>"

View File

@ -9,9 +9,10 @@ use cached::proc_macro::cached;
use chrono::Utc;
use reqwest::Url;
use rocket::futures::StreamExt;
use ytextract::playlist::video::{Error as YouTubeVideoError, Video as YouTubeVideo};
use ytextract::playlist::video::{Error as YouTubeVideoError, Video as YouTubePlaylistVideo};
use ytextract::{
Channel as YouTubeChannel, Client, Playlist as YouTubePlaylist, Stream as YouTubeStream,
Video as YouTubeVideo,
};
use super::{Channel, Enclosure, Item};
@ -190,7 +191,7 @@ impl From<YouTubeVideoWithStream> for Item {
let mut link = Url::parse(VIDEO_BASE_URL).expect("valid URL");
link.query_pairs_mut().append_pair("v", &id);
let description = Some(format!("Taken from YouTube: {0}", link));
let duration = Some(video.length().as_secs() as u32);
let duration = Some(video.duration().as_secs() as u32);
let image = video
.thumbnails()
.iter()
@ -267,13 +268,14 @@ async fn fetch_channel_videos(
/// Fetches the stream and relevant metadata for a YouTube video result.
///
/// If there is a video retieving the metadata, the video is discarded/ignored.
/// If there is a error retrieving the metadata, the video is discarded/ignored.
/// If there are problems retrieving the streams or metadata, the video is also discarded.
async fn fetch_stream(
yt_video: Result<YouTubeVideo, YouTubeVideoError>,
yt_video: Result<YouTubePlaylistVideo, YouTubeVideoError>,
) -> Option<YouTubeVideoWithStream> {
match yt_video {
Ok(video) => {
let video = video.upgrade().await.ok()?;
let stream = video
.streams()
.await