mirror of
https://github.com/OMGeeky/twba_downloader.git
synced 2026-01-10 04:39:34 +01:00
rename crate local-db to twba-local-db
This commit is contained in:
29
Cargo.lock
generated
29
Cargo.lock
generated
@@ -1145,19 +1145,6 @@ version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
|
||||
[[package]]
|
||||
name = "local-db"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/OMGeeky/twitch_backup.local_db.git#0a15447f4d5e5093c27aa89936ecedfa9961e5be"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"sea-orm",
|
||||
"sea-orm-migration",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.11"
|
||||
@@ -2951,7 +2938,6 @@ dependencies = [
|
||||
"chrono",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"local-db",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2959,12 +2945,27 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"twba-local-db",
|
||||
"twba-reqwest-backoff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "twba-local-db"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/OMGeeky/twitch_backup.local_db.git#7ad57a8bea84f2889b21ac337de8e36194d2fee7"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"sea-orm",
|
||||
"sea-orm-migration",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "twba-reqwest-backoff"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/OMGeeky/twba_reqwest_backoff.git#916e98a2e6cfda593b23bc4e76b137cb92660463"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"reqwest",
|
||||
|
||||
@@ -6,9 +6,9 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
backup-config = {version = "0.1.1", git = "https://github.com/OMGeeky/backup_config.git" }
|
||||
local-db = {version = "0.2", git = "https://github.com/OMGeeky/twitch_backup.local_db.git"}
|
||||
twba-reqwest-backoff = {version = "0.1", git = "https://github.com/OMGeeky/twba_reqwest_backoff.git"}
|
||||
backup-config = { version = "0.1.1", git = "https://github.com/OMGeeky/backup_config.git" }
|
||||
twba-local-db = { version = "0.2", git = "https://github.com/OMGeeky/twitch_backup.local_db.git" }
|
||||
twba-reqwest-backoff = { version = "0.1", git = "https://github.com/OMGeeky/twba_reqwest_backoff.git" }
|
||||
|
||||
|
||||
tracing-subscriber = "0.3"
|
||||
|
||||
@@ -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