mirror of
https://github.com/OMGeeky/twba_downloader.git
synced 2026-02-23 15:49:59 +01:00
rename crate local-db to twba-local-db
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use crate::prelude::*;
|
||||
use crate::twitch::TwitchClient;
|
||||
use local_db::prelude::*;
|
||||
use local_db::re_exports::sea_orm::ActiveValue::Set;
|
||||
use local_db::re_exports::sea_orm::{
|
||||
use std::path::Path;
|
||||
use twba_local_db::prelude::*;
|
||||
use twba_local_db::re_exports::sea_orm::ActiveValue::Set;
|
||||
use twba_local_db::re_exports::sea_orm::{
|
||||
ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter,
|
||||
};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DownloaderClient {
|
||||
@@ -19,12 +19,14 @@ impl DownloaderClient {
|
||||
}
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn download_not_downloaded_videos(&self) -> Result<()> {
|
||||
info!("Downloading not downloaded videos");
|
||||
let output_folder: &Path =
|
||||
Path::new(self.twitch_client.config.download_folder_path.as_str());
|
||||
let videos = Videos::find()
|
||||
.filter(VideosColumn::Status.eq(Status::NotStarted))
|
||||
.all(&self.db)
|
||||
.await?;
|
||||
info!("Found {} videos to download", videos.len());
|
||||
|
||||
for video in videos {
|
||||
let id = video.id;
|
||||
@@ -39,6 +41,7 @@ impl DownloaderClient {
|
||||
info!("Downloaded video with id: {}", id);
|
||||
}
|
||||
}
|
||||
info!("Finished downloading videos");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use twba_reqwest_backoff::ReqwestBackoffError;
|
||||
use std::path::PathBuf;
|
||||
use twba_reqwest_backoff::ReqwestBackoffError;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DownloaderError {
|
||||
@@ -15,7 +15,7 @@ pub enum DownloaderError {
|
||||
#[error("Backoff error")]
|
||||
Backoff(#[from] ReqwestBackoffError),
|
||||
#[error("Database Error")]
|
||||
Database(#[from] local_db::re_exports::sea_orm::DbErr),
|
||||
Database(#[from] twba_local_db::re_exports::sea_orm::DbErr),
|
||||
|
||||
#[error("Reqwest error")]
|
||||
Reqwest(#[from] reqwest::Error),
|
||||
|
||||
@@ -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,downloader=trace,local_db=warn,reqwest-backoff=warn",
|
||||
"sea_orm=warn,sea_orm_migration=warn,sqlx=warn,twba_downloader=trace,local_db=warn,twba_reqwest_backoff=warn",
|
||||
)
|
||||
.init();
|
||||
info!("Hello, world!");
|
||||
@@ -40,11 +40,11 @@ async fn run() -> Result<()> {
|
||||
DownloaderError::LoadConfig(e.into())
|
||||
})?;
|
||||
|
||||
let db = local_db::open_database(Some(&conf.db_url)).await?;
|
||||
local_db::migrate_db(&db).await?;
|
||||
let db = twba_local_db::open_database(Some(&conf.db_url)).await?;
|
||||
twba_local_db::migrate_db(&db).await?;
|
||||
// local_db::print_db(&db).await?;
|
||||
|
||||
// dbg!(&conf);
|
||||
dbg!(&conf);
|
||||
let twitch_client = twitch::TwitchClient::new(conf);
|
||||
let client = client::DownloaderClient::new(twitch_client, db);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use futures_util::{StreamExt, TryStreamExt};
|
||||
use twba_reqwest_backoff::ReqwestClient;
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
@@ -9,6 +8,7 @@ use tokio::io::AsyncWriteExt;
|
||||
use tokio::process::Command;
|
||||
use tokio::time::Instant;
|
||||
use tracing::instrument;
|
||||
use twba_reqwest_backoff::ReqwestClient;
|
||||
|
||||
use crate::errors::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
Reference in New Issue
Block a user