mirror of
https://github.com/OMGeeky/twba.splitter.git
synced 2025-12-26 17:02:35 +01:00
extract stuff to common crate & processing limit
This commit is contained in:
@@ -6,8 +6,9 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
twba-backup-config = { version = "0.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-backup-config = { version = "0.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-common = { version = "0.1", git = "https://github.com/OMGeeky/twba.common.git" }
|
||||
|
||||
tokio = "1.33"
|
||||
tracing = "0.1"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
use crate::errors::SplitterError;
|
||||
use crate::prelude::*;
|
||||
use twba_backup_config::Conf;
|
||||
use chrono::Duration;
|
||||
use twba_local_db::prelude::{Status, Videos, VideosColumn, VideosModel};
|
||||
use twba_local_db::re_exports::sea_orm::{
|
||||
ActiveModelTrait, ActiveValue, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||
QueryFilter,
|
||||
};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Instant;
|
||||
use tokio::fs;
|
||||
use twba_backup_config::Conf;
|
||||
use twba_local_db::prelude::{Status, Videos, VideosColumn, VideosModel};
|
||||
use twba_local_db::re_exports::sea_orm::{
|
||||
ActiveModelTrait, ActiveValue, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||
QueryFilter, QuerySelect,
|
||||
};
|
||||
|
||||
mod utils;
|
||||
use utils::ffmpeg::run_ffmpeg_split;
|
||||
@@ -43,7 +43,10 @@ impl SplitterClient {
|
||||
video.clone().update(&self.db).await?;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Could not split video with id: {} because of err: {:?}", id, err);
|
||||
error!(
|
||||
"Could not split video with id: {} because of err: {:?}",
|
||||
id, err
|
||||
);
|
||||
video.status = ActiveValue::Set(Status::SplitFailed);
|
||||
video.clone().update(&self.db).await?;
|
||||
return Err(err);
|
||||
@@ -120,6 +123,7 @@ impl SplitterClient {
|
||||
info!("Splitting videos");
|
||||
let videos = Videos::find()
|
||||
.filter(VideosColumn::Status.eq(Status::Downloaded))
|
||||
.limit(self.conf.max_items_to_process)
|
||||
.all(&self.db)
|
||||
.await?;
|
||||
|
||||
|
||||
13
src/main.rs
13
src/main.rs
@@ -8,12 +8,7 @@ pub mod errors;
|
||||
pub mod prelude;
|
||||
#[tokio::main]
|
||||
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_splitter=trace,twba_local_db=warn,other=warn",
|
||||
)
|
||||
.init();
|
||||
let _guard = twba_common::init_tracing("twba_splitter");
|
||||
info!("Hello, world!");
|
||||
|
||||
run().await?;
|
||||
@@ -22,11 +17,7 @@ async fn main() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
async fn run() -> Result<()> {
|
||||
let conf = Conf::builder()
|
||||
.env()
|
||||
.file("./settings.toml")
|
||||
.file(shellexpand::tilde("~/twba/config.toml").into_owned())
|
||||
.file(std::env::var("TWBA_CONFIG").unwrap_or_else(|_| "~/twba/config.toml".to_string()))
|
||||
let conf = twba_backup_config::get_default_builder()
|
||||
.load()
|
||||
.map_err(|e| SplitterError::LoadConfig(e.into()))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user