mirror of
https://github.com/OMGeeky/twba.twitch_fetcher.git
synced 2026-02-23 15:49:57 +01:00
some fixes and logging
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -3372,7 +3372,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "twba-twitch-data"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/OMGeeky/twitch_data.git#908cbae28ff0c7b13e00a942955776c1c0e14707"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
@@ -3396,7 +3395,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "twitch-fetcher"
|
||||
name = "twba-twitch-fetcher"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "twitch-fetcher"
|
||||
name = "twba-twitch-fetcher"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -56,16 +56,16 @@ impl<'a> FetcherClient<'a> {
|
||||
.await
|
||||
.map_err(FetcherError::GetVideosError)?;
|
||||
for video in videos {
|
||||
info!("Adding video: {} to the database", video.title);
|
||||
let existing_video_found = Videos::find()
|
||||
.filter(VideosColumn::TwitchId.eq(video.id.to_string()))
|
||||
.one(&self.db)
|
||||
.await
|
||||
.is_ok();
|
||||
.await?
|
||||
.is_some();
|
||||
if existing_video_found {
|
||||
info!("Video with id: {} already exists in the database", video.id);
|
||||
continue;
|
||||
}
|
||||
info!("Adding video: {} to the database", video.title);
|
||||
|
||||
ActiveModel {
|
||||
id: ActiveValue::NotSet,
|
||||
@@ -74,7 +74,7 @@ impl<'a> FetcherClient<'a> {
|
||||
user_id: ActiveValue::Set(user.id),
|
||||
created_at: ActiveValue::Set(video.created_at.to_rfc3339()),
|
||||
youtube_id: ActiveValue::NotSet,
|
||||
youtube_playlist_name: ActiveValue::NotSet,
|
||||
youtube_playlist_name: ActiveValue::Set("".to_string()),
|
||||
youtube_preview_image_url: ActiveValue::NotSet,
|
||||
youtube_playlist_id: ActiveValue::NotSet,
|
||||
duration: ActiveValue::Set(video.duration as i32),
|
||||
|
||||
@@ -10,7 +10,7 @@ async fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::INFO)
|
||||
.with_env_filter(
|
||||
"sea_orm=warn,sea_orm_migration=warn,sqlx=warn,twba_fetcher=trace,twba_local_db=warn,twba_twitch_data=info,twba_downloader_config=info,twba_backup_config=info,other=warn",
|
||||
"sea_orm=warn,sea_orm_migration=warn,sqlx=warn,twba_twitch_fetcher=trace,twba_local_db=warn,twba_twitch_data=info,twba_downloader_config=info,twba_backup_config=info,other=warn",
|
||||
)
|
||||
.init();
|
||||
info!("Hello, world!");
|
||||
@@ -29,13 +29,18 @@ async fn run() -> Result<()> {
|
||||
.load()
|
||||
.map_err(|e| FetcherError::LoadConfig(e.into()))?;
|
||||
|
||||
trace!("Opening database");
|
||||
let db = twba_local_db::open_database(Some(&conf.db_url)).await?;
|
||||
twba_local_db::migrate_db(&db).await?;
|
||||
trace!("Creating twitch client");
|
||||
let twitch_client = twba_twitch_data::get_client()
|
||||
.await
|
||||
.map_err(FetcherError::CreateClientError)?;
|
||||
|
||||
info!("Creating client");
|
||||
let client = client::FetcherClient::new(conf, db, twitch_client);
|
||||
info!("Fetching new videos");
|
||||
client.fetch_new_videos().await?;
|
||||
info!("Done fetching new videos");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use twba_backup_config::Conf;
|
||||
|
||||
pub use crate::errors::FetcherError;
|
||||
pub(crate) use std::result::Result as StdResult;
|
||||
pub(crate) use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
Reference in New Issue
Block a user