Compare commits
2
Commits
0009db0ea9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a643aea7bf | ||
|
|
5be6e317ad |
+6
-1
@@ -1,5 +1,5 @@
|
|||||||
use crate::args::ArgsConfig;
|
use crate::args::ArgsConfig;
|
||||||
use crate::types::{Playlist, Video, VideoDownloadQuality};
|
use crate::types::{Playlist, Queues, Video, VideoDownloadQuality};
|
||||||
use eframe::egui::{Context, Ui};
|
use eframe::egui::{Context, Ui};
|
||||||
use eframe::{CreationContext, Frame, Storage};
|
use eframe::{CreationContext, Frame, Storage};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -10,6 +10,8 @@ pub(crate) struct Application {
|
|||||||
layers: Vec<Box<dyn crate::layer::Layer>>,
|
layers: Vec<Box<dyn crate::layer::Layer>>,
|
||||||
pub(crate) data: Data,
|
pub(crate) data: Data,
|
||||||
pub(crate) data_dir: String,
|
pub(crate) data_dir: String,
|
||||||
|
pub(crate) progress_percent: f32,
|
||||||
|
pub(crate) progress_info: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
@@ -23,6 +25,7 @@ pub struct AppSettings {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
pub(crate) struct Data {
|
pub(crate) struct Data {
|
||||||
|
pub(crate) queues: Queues,
|
||||||
pub(crate) playlists: Vec<Playlist>,
|
pub(crate) playlists: Vec<Playlist>,
|
||||||
pub(crate) videos: Vec<Video>,
|
pub(crate) videos: Vec<Video>,
|
||||||
pub(crate) root_path: String,
|
pub(crate) root_path: String,
|
||||||
@@ -61,6 +64,8 @@ impl Application {
|
|||||||
layers,
|
layers,
|
||||||
data,
|
data,
|
||||||
data_dir: args_config.data_dir.clone(),
|
data_dir: args_config.data_dir.clone(),
|
||||||
|
progress_percent: 0.0,
|
||||||
|
progress_info: "".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,10 @@ use tracing::warn;
|
|||||||
use yt_dlp::client::LibraryInstaller;
|
use yt_dlp::client::LibraryInstaller;
|
||||||
|
|
||||||
pub(crate) struct Downloader {
|
pub(crate) struct Downloader {
|
||||||
video_queue: Vec<Video>,
|
|
||||||
playlists_queue: Vec<Playlist>,
|
|
||||||
added_queue: Vec<String>,
|
|
||||||
yt_downloader: Option<yt_dlp::Downloader>,
|
yt_downloader: Option<yt_dlp::Downloader>,
|
||||||
|
|
||||||
tokio_handle: Handle,
|
tokio_handle: Handle,
|
||||||
|
|
||||||
yt_dlp_installed: bool,
|
yt_dlp_installed: bool,
|
||||||
rejected_yt_dlp_install: bool,
|
rejected_yt_dlp_install: bool,
|
||||||
|
|
||||||
ffmpeg_installed: bool,
|
ffmpeg_installed: bool,
|
||||||
rejected_ffmpeg_install: bool,
|
rejected_ffmpeg_install: bool,
|
||||||
}
|
}
|
||||||
@@ -37,9 +31,6 @@ impl Downloader {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let yt_downloader = None;
|
let yt_downloader = None;
|
||||||
Self {
|
Self {
|
||||||
video_queue: Vec::new(),
|
|
||||||
playlists_queue: Vec::new(),
|
|
||||||
added_queue: Vec::new(),
|
|
||||||
yt_downloader,
|
yt_downloader,
|
||||||
tokio_handle: Handle::current(),
|
tokio_handle: Handle::current(),
|
||||||
yt_dlp_installed: false,
|
yt_dlp_installed: false,
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
use crate::app::Application;
|
||||||
|
use crate::layer::Layer;
|
||||||
|
use eframe::egui::Ui;
|
||||||
|
use eframe::emath::{Pos2, Rect};
|
||||||
|
use eframe::{Frame, egui};
|
||||||
|
use tracing::warn;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub(crate) struct LeftPanel {
|
||||||
|
show_panel: bool,
|
||||||
|
url_bar: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Layer for LeftPanel {
|
||||||
|
fn ui(&mut self, application: &mut Application, ui: &mut Ui, _frame: &mut Frame) {
|
||||||
|
let window_size = ui.input(|i| i.viewport().outer_rect).unwrap_or_else(|| {
|
||||||
|
warn!("Failed to get window size");
|
||||||
|
Rect {
|
||||||
|
min: Pos2 { x: 0., y: 0. },
|
||||||
|
max: Pos2 { x: 1., y: 1. },
|
||||||
|
}
|
||||||
|
});
|
||||||
|
egui::panel::Panel::left("left_panel")
|
||||||
|
.min_size(window_size.width() / 5.)
|
||||||
|
.max_size((window_size.width() / 5.) + 2.)
|
||||||
|
.show_collapsible(ui, &mut self.show_panel, |ui| {
|
||||||
|
// TODO: Display a list of videos and playlists
|
||||||
|
|
||||||
|
// Progress bar and status info
|
||||||
|
egui::Panel::bottom("bottom_panel").show(ui, |ui| {
|
||||||
|
ui.vertical_centered(|ui| {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.text_edit_singleline(&mut self.url_bar);
|
||||||
|
if ui.button("Download").clicked() {
|
||||||
|
// TODO: Add check for if link is valid
|
||||||
|
application
|
||||||
|
.data
|
||||||
|
.queues
|
||||||
|
.added_queue
|
||||||
|
.push(self.url_bar.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.separator();
|
||||||
|
ui.label(format!("{}", application.progress_info));
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label(format!("{:.1}%", application.progress_percent * 100.));
|
||||||
|
ui.add(egui::ProgressBar::new(application.progress_percent));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::left_panel::LeftPanel;
|
||||||
use crate::top_bar_layer::TopBarLayer;
|
use crate::top_bar_layer::TopBarLayer;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -11,6 +12,7 @@ mod layer;
|
|||||||
mod logging;
|
mod logging;
|
||||||
mod top_bar_layer;
|
mod top_bar_layer;
|
||||||
mod types;
|
mod types;
|
||||||
|
mod left_panel;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@@ -34,6 +36,7 @@ async fn main() {
|
|||||||
|
|
||||||
let mut layers: Vec<Box<dyn layer::Layer>> = Vec::new();
|
let mut layers: Vec<Box<dyn layer::Layer>> = Vec::new();
|
||||||
layers.push(Box::new(TopBarLayer::default()));
|
layers.push(Box::new(TopBarLayer::default()));
|
||||||
|
layers.push(Box::new(LeftPanel::default()));
|
||||||
layers.push(Box::new(downloader::Downloader::new()));
|
layers.push(Box::new(downloader::Downloader::new()));
|
||||||
|
|
||||||
let mut options = eframe::NativeOptions::default();
|
let mut options = eframe::NativeOptions::default();
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ pub(crate) struct Playlist {
|
|||||||
pub(crate) num_videos: usize,
|
pub(crate) num_videos: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
pub(crate) struct Queues {
|
||||||
|
pub(crate) video_queue: Vec<Video>,
|
||||||
|
pub(crate) playlists_queue: Vec<Playlist>,
|
||||||
|
pub(crate) added_queue: Vec<String>,
|
||||||
|
}
|
||||||
#[derive(Deserialize, Serialize, PartialEq, Default)]
|
#[derive(Deserialize, Serialize, PartialEq, Default)]
|
||||||
pub enum VideoDownloadQuality {
|
pub enum VideoDownloadQuality {
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
Reference in New Issue
Block a user