Merge video_quality to types + prevent downloader from throwing warnings while im working in it + add todos + tweak the about and settings windows
This commit is contained in:
+2
-2
@@ -1,6 +1,5 @@
|
|||||||
use crate::args::ArgsConfig;
|
use crate::args::ArgsConfig;
|
||||||
use crate::types::{Playlist, Video};
|
use crate::types::{Playlist, Video, VideoDownloadQuality};
|
||||||
use crate::video_quality::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};
|
||||||
@@ -18,6 +17,7 @@ pub struct AppSettings {
|
|||||||
pub(crate) use_firefox_cookies: bool,
|
pub(crate) use_firefox_cookies: bool,
|
||||||
pub(crate) use_chrome_cookies: bool,
|
pub(crate) use_chrome_cookies: bool,
|
||||||
pub(crate) save_thumbnails: bool,
|
pub(crate) save_thumbnails: bool,
|
||||||
|
pub(crate) reencode_videos: bool,
|
||||||
pub(crate) video_download_quality: VideoDownloadQuality,
|
pub(crate) video_download_quality: VideoDownloadQuality,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
// TODO: Remove once downloader is done
|
||||||
|
#![allow(dead_code)]
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
use crate::app::Application;
|
use crate::app::Application;
|
||||||
use crate::layer::Layer;
|
use crate::layer::Layer;
|
||||||
use crate::types::{Playlist, Video};
|
use crate::types::{Playlist, Video};
|
||||||
@@ -11,6 +15,7 @@ use yt_dlp::client::LibraryInstaller;
|
|||||||
pub(crate) struct Downloader {
|
pub(crate) struct Downloader {
|
||||||
video_queue: Vec<Video>,
|
video_queue: Vec<Video>,
|
||||||
playlists_queue: Vec<Playlist>,
|
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,
|
||||||
@@ -22,12 +27,19 @@ pub(crate) struct Downloader {
|
|||||||
rejected_ffmpeg_install: bool,
|
rejected_ffmpeg_install: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Create a queue manager
|
||||||
|
// TODO: Create task to download videos
|
||||||
|
// TODO: Create task to process playlists
|
||||||
|
// TODO: Create task to process added urls
|
||||||
|
// TODO: Create function to recreate the yt_dlp::Downloader
|
||||||
|
|
||||||
impl Downloader {
|
impl Downloader {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let yt_downloader = None;
|
let yt_downloader = None;
|
||||||
Self {
|
Self {
|
||||||
video_queue: Vec::new(),
|
video_queue: Vec::new(),
|
||||||
playlists_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,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ mod layer;
|
|||||||
mod logging;
|
mod logging;
|
||||||
mod top_bar_layer;
|
mod top_bar_layer;
|
||||||
mod types;
|
mod types;
|
||||||
mod video_quality;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::app::Application;
|
use crate::app::Application;
|
||||||
use crate::layer::Layer;
|
use crate::layer::Layer;
|
||||||
use crate::video_quality::VideoDownloadQuality;
|
use crate::types::VideoDownloadQuality;
|
||||||
use eframe::egui::Ui;
|
use eframe::egui::Ui;
|
||||||
use eframe::{Frame, egui};
|
use eframe::{Frame, egui};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
@@ -39,6 +39,8 @@ impl Layer for TopBarLayer {
|
|||||||
if self.show_settings_window {
|
if self.show_settings_window {
|
||||||
egui::Window::new("Settings")
|
egui::Window::new("Settings")
|
||||||
.open(&mut self.show_settings_window)
|
.open(&mut self.show_settings_window)
|
||||||
|
.collapsible(false)
|
||||||
|
.resizable(false)
|
||||||
.show(ui, |ui: &mut Ui| {
|
.show(ui, |ui: &mut Ui| {
|
||||||
if ui
|
if ui
|
||||||
.checkbox(
|
.checkbox(
|
||||||
@@ -63,6 +65,10 @@ impl Layer for TopBarLayer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
ui.checkbox(&mut application.settings.save_thumbnails, "Save thumbnails");
|
ui.checkbox(&mut application.settings.save_thumbnails, "Save thumbnails");
|
||||||
|
ui.checkbox(
|
||||||
|
&mut application.settings.reencode_videos,
|
||||||
|
"Re-encode videos",
|
||||||
|
);
|
||||||
ui.menu_button("Video download quality", |ui: &mut Ui| {
|
ui.menu_button("Video download quality", |ui: &mut Ui| {
|
||||||
ui.radio_value(
|
ui.radio_value(
|
||||||
&mut application.settings.video_download_quality,
|
&mut application.settings.video_download_quality,
|
||||||
@@ -96,6 +102,8 @@ impl Layer for TopBarLayer {
|
|||||||
if self.show_about_window {
|
if self.show_about_window {
|
||||||
egui::Window::new("About")
|
egui::Window::new("About")
|
||||||
.open(&mut self.show_about_window)
|
.open(&mut self.show_about_window)
|
||||||
|
.collapsible(false)
|
||||||
|
.resizable(false)
|
||||||
.show(ui, |ui: &mut Ui| {
|
.show(ui, |ui: &mut Ui| {
|
||||||
ui.heading("yt-offline");
|
ui.heading("yt-offline");
|
||||||
ui.label("A simple unified offline YouTube downloader + viewer");
|
ui.label("A simple unified offline YouTube downloader + viewer");
|
||||||
|
|||||||
+35
-1
@@ -1,5 +1,5 @@
|
|||||||
use crate::video_quality::VideoDownloadQuality;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use yt_dlp::cache::VideoQuality;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
pub(crate) struct Video {
|
pub(crate) struct Video {
|
||||||
@@ -29,3 +29,37 @@ pub(crate) struct Playlist {
|
|||||||
pub(crate) videos: Vec<Video>,
|
pub(crate) videos: Vec<Video>,
|
||||||
pub(crate) num_videos: usize,
|
pub(crate) num_videos: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, PartialEq, Default)]
|
||||||
|
pub enum VideoDownloadQuality {
|
||||||
|
#[default]
|
||||||
|
Best,
|
||||||
|
High,
|
||||||
|
Medium,
|
||||||
|
Low,
|
||||||
|
Worst,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VideoDownloadQuality {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn to_ytdlp(&self) -> VideoQuality {
|
||||||
|
match self {
|
||||||
|
VideoDownloadQuality::Best => VideoQuality::Best,
|
||||||
|
VideoDownloadQuality::High => VideoQuality::High,
|
||||||
|
VideoDownloadQuality::Medium => VideoQuality::Medium,
|
||||||
|
VideoDownloadQuality::Low => VideoQuality::Low,
|
||||||
|
VideoDownloadQuality::Worst => VideoQuality::Worst,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn to_string(&self) -> String {
|
||||||
|
match self {
|
||||||
|
VideoDownloadQuality::Best => "best".to_string(),
|
||||||
|
VideoDownloadQuality::High => "high".to_string(),
|
||||||
|
VideoDownloadQuality::Medium => "medium".to_string(),
|
||||||
|
VideoDownloadQuality::Low => "low".to_string(),
|
||||||
|
VideoDownloadQuality::Worst => "worst".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use yt_dlp::model::VideoQuality;
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, PartialEq, Default)]
|
|
||||||
pub enum VideoDownloadQuality {
|
|
||||||
#[default]
|
|
||||||
Best,
|
|
||||||
High,
|
|
||||||
Medium,
|
|
||||||
Low,
|
|
||||||
Worst,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl VideoDownloadQuality {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn to_ytdlp(&self) -> VideoQuality {
|
|
||||||
match self {
|
|
||||||
VideoDownloadQuality::Best => VideoQuality::Best,
|
|
||||||
VideoDownloadQuality::High => VideoQuality::High,
|
|
||||||
VideoDownloadQuality::Medium => VideoQuality::Medium,
|
|
||||||
VideoDownloadQuality::Low => VideoQuality::Low,
|
|
||||||
VideoDownloadQuality::Worst => VideoQuality::Worst,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn to_string(&self) -> String {
|
|
||||||
match self {
|
|
||||||
VideoDownloadQuality::Best => "best".to_string(),
|
|
||||||
VideoDownloadQuality::High => "high".to_string(),
|
|
||||||
VideoDownloadQuality::Medium => "medium".to_string(),
|
|
||||||
VideoDownloadQuality::Low => "low".to_string(),
|
|
||||||
VideoDownloadQuality::Worst => "worst".to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user