Create downloader layer + manage library installation
This commit is contained in:
+21
-33
@@ -1,13 +1,16 @@
|
||||
use crate::args::ArgsConfig;
|
||||
use crate::types::{Playlist, Video};
|
||||
use crate::video_quality::VideoDownloadQuality;
|
||||
use eframe::egui::{Context, Ui};
|
||||
use eframe::{CreationContext, Frame, Storage};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use yt_dlp::model::VideoQuality;
|
||||
|
||||
pub(crate) struct Application {
|
||||
pub settings: AppSettings,
|
||||
pub(crate) settings: AppSettings,
|
||||
layers: Vec<Box<dyn crate::layer::Layer>>,
|
||||
data: Data,
|
||||
pub(crate) data: Data,
|
||||
pub(crate) data_dir: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
@@ -15,42 +18,22 @@ pub struct AppSettings {
|
||||
pub(crate) use_firefox_cookies: bool,
|
||||
pub(crate) use_chrome_cookies: bool,
|
||||
pub(crate) save_thumbnails: bool,
|
||||
pub(crate) video_download_quality: crate::video_quality::VideoDownloadQuality,
|
||||
pub(crate) video_download_quality: VideoDownloadQuality,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
struct Data {
|
||||
playlists: Vec<Playlist>,
|
||||
videos: Vec<Video>,
|
||||
root_path: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
struct Video {
|
||||
name: String,
|
||||
uuid: String,
|
||||
original_url: String,
|
||||
video_path: String,
|
||||
has_thumbnail: bool,
|
||||
thumbnail_path: String,
|
||||
thumbnail_path_low_quality: String,
|
||||
video_quality: VideoQuality,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
struct Playlist {
|
||||
name: String,
|
||||
uuid: String,
|
||||
original_url: String,
|
||||
videos: Vec<Video>,
|
||||
creator: String,
|
||||
has_thumbnail: bool,
|
||||
thumbnail_path: String,
|
||||
thumbnail_path_low_quality: String,
|
||||
pub(crate) struct Data {
|
||||
pub(crate) playlists: Vec<Playlist>,
|
||||
pub(crate) videos: Vec<Video>,
|
||||
pub(crate) root_path: String,
|
||||
}
|
||||
|
||||
impl Application {
|
||||
pub fn new(cc: &CreationContext, layers: Vec<Box<dyn crate::layer::Layer>>) -> Self {
|
||||
pub fn new(
|
||||
cc: &CreationContext,
|
||||
layers: Vec<Box<dyn crate::layer::Layer>>,
|
||||
args_config: &ArgsConfig,
|
||||
) -> Self {
|
||||
let mut settings = AppSettings::default();
|
||||
if let Some(storage) = cc.storage {
|
||||
if let Some(stored_str) = storage.get_string("app_settings") {
|
||||
@@ -69,10 +52,15 @@ impl Application {
|
||||
}
|
||||
}
|
||||
|
||||
if data.root_path.is_empty() {
|
||||
data.root_path = args_config.data_dir.clone() + "/data";
|
||||
}
|
||||
|
||||
Self {
|
||||
settings,
|
||||
layers,
|
||||
data,
|
||||
data_dir: args_config.data_dir.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user