#![allow(unused, incomplete_features)] use std::error::Error; use std::fmt::Debug; use std::path::Path; use google_bigquery; use google_bigquery::{BigDataTable, BigqueryClient}; use google_youtube::scopes; use google_youtube::YoutubeClient; use nameof::name_of; use simplelog::*; use tokio::fs::File; use twitch_data::{ convert_twitch_video_to_twitch_data_video, get_client, TwitchClient, Video, VideoQuality, }; use downloader::data::{Streamers, VideoMetadata}; use downloader::start_backup; //region constants const SERVICE_ACCOUNT_PATH: &str = "auth/bigquery_service_account.json"; const YOUTUBE_CLIENT_SECRET: &str = "auth/youtube_client_secret.json"; const PROJECT_ID: &str = "twitchbackup-v1"; const DATASET_ID: &str = "backup_data"; //endregion #[tokio::main] async fn main() -> Result<(), Box> { let log_folder = "downloader/logs/"; tokio::fs::create_dir_all(log_folder).await?; let timestamp = chrono::Utc::now().format("%Y-%m-%d_%H-%M-%S").to_string(); CombinedLogger::init(vec![ // SimpleLogger::new(LevelFilter::Info, Config::default()), TermLogger::new( LevelFilter::Info, Config::default(), TerminalMode::Mixed, ColorChoice::Auto, ), WriteLogger::new( LevelFilter::Info, Config::default(), File::create(format!("{}downloader_{}.log", log_folder, timestamp)) .await? .into_std() .await, ), WriteLogger::new( LevelFilter::Trace, Config::default(), File::create(format!("{}trace_{}.log", log_folder, timestamp)) .await? .into_std() .await, ), ]) .unwrap(); println!("Hello, world!"); start_backup().await?; // sample().await?; Ok(()) } pub async fn sample() -> Result<(), Box> { println!("Hello from the downloader lib!"); let client = BigqueryClient::new(PROJECT_ID, DATASET_ID, Some(SERVICE_ACCOUNT_PATH)).await?; sample_bigquery(&client).await?; /* let youtube_client = YoutubeClient::new(Some(YOUTUBE_CLIENT_SECRET), vec![scopes::YOUTUBE_UPLOAD, scopes::YOUTUBE_READONLY, scopes::YOUTUBE], Some("NopixelVODs")).await?; sample_youtube(&youtube_client).await?; */ /* let twitch_client = get_client().await?; sample_twitch(&twitch_client).await?; */ Ok(()) } async fn sample_twitch<'a>(client: &TwitchClient<'a>) -> Result<(), Box> { println!("\n\nGetting videos..."); let res = client.get_channel_info_from_login("burn").await?; println!("got channel info: {:?}", res); let channel_id = res.unwrap().broadcaster_id; let videos: Vec