Add check if user is live (prevents partial downloads)

This commit is contained in:
OMGeeky
2024-06-04 18:19:59 +02:00
parent 8187110a82
commit 7726acf5b6
3 changed files with 8 additions and 2 deletions

View File

@@ -1,12 +1,12 @@
[package]
name = "twba-twitch-fetcher"
version = "0.1.1"
version = "0.2.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
twba-twitch-data = { version = "0.3", git = "https://github.com/OMGeeky/twitch_data.git" }
twba-twitch-data = { version = "0.4", git = "https://github.com/OMGeeky/twitch_data.git" }
twba-common = { version = "0.2", git = "https://github.com/OMGeeky/twba.common.git" }
tracing = "0.1"

View File

@@ -34,6 +34,10 @@ impl<'a> FetcherClient<'a> {
.await?;
info!("Fetching videos for {} users", users.len());
for user in users {
if self.twitch_client.is_live(&user.twitch_name).await.map_err(FetcherError::CheckLiveError)? {
info!("User: {} is live, skipping fetching videos", user.twitch_name);
continue;
}
match self.fetch_videos_for_user(&user).await {
Ok(_) => {
info!("Fetched videos for user: {}", user.twitch_name);

View File

@@ -14,4 +14,6 @@ pub enum FetcherError {
CreateClientError(#[source] Box<dyn StdError>),
#[error("Could not get videos: {0:?}")]
GetVideosError(#[source] Box<dyn StdError>),
#[error("Could not get videos: {0:?}")]
CheckLiveError(#[source] Box<dyn StdError>),
}