Compare commits
10
Commits
0abe9a8206
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a643aea7bf | ||
|
|
5be6e317ad | ||
|
|
0009db0ea9 | ||
|
|
1e13df0d6f | ||
|
|
c307f4c5d1 | ||
|
|
1f67b5010c | ||
|
|
88005f9a0d | ||
|
|
866575d7a0 | ||
|
|
ea2244d6b5 | ||
|
|
1719e47684 |
@@ -0,0 +1,40 @@
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Release Binary (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
binary_path: target/release/yt-offline
|
||||
- os: windows-latest
|
||||
binary_path: target/release/yt-offline.exe
|
||||
|
||||
steps:
|
||||
- name: Install Rust Toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v2
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
target/
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release
|
||||
|
||||
- name: Upload binary artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: yt-offline-${{ matrix.os }}
|
||||
path: ${{ matrix.binary_path }}
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JsonSchemaMappingsProjectConfiguration">
|
||||
<state>
|
||||
<map>
|
||||
<entry key="GitHub Workflow">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
<option name="name" value="GitHub Workflow" />
|
||||
<option name="relativePathToSchema" value="https://www.schemastore.org/github-workflow.json" />
|
||||
<option name="applicationDefined" value="true" />
|
||||
<option name="patterns">
|
||||
<list>
|
||||
<Item>
|
||||
<option name="path" value=".gitea/workflows/build.yml" />
|
||||
</Item>
|
||||
</list>
|
||||
</option>
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</state>
|
||||
</component>
|
||||
</project>
|
||||
+1
-1
@@ -11,7 +11,7 @@ egui-sharkplayer = "0.5.1"
|
||||
serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_json = "1.0.151"
|
||||
tokio = { version = "1.53.1", features = ["macros", "rt-multi-thread"] }
|
||||
tracing = "0.1.44"
|
||||
tracing = { version = "0.1.44", features = ["log"] }
|
||||
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
||||
webbrowser = "1.2.4"
|
||||
yt-dlp = "2.8.3"
|
||||
|
||||
+26
-33
@@ -1,13 +1,17 @@
|
||||
use crate::args::ArgsConfig;
|
||||
use crate::types::{Playlist, Queues, Video, 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,
|
||||
pub(crate) progress_percent: f32,
|
||||
pub(crate) progress_info: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
@@ -15,42 +19,24 @@ 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) reencode_videos: bool,
|
||||
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) queues: Queues,
|
||||
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 +55,17 @@ 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(),
|
||||
progress_percent: 0.0,
|
||||
progress_info: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// TODO: Remove once downloader is done
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused)]
|
||||
|
||||
use crate::app::Application;
|
||||
use crate::layer::Layer;
|
||||
use crate::types::{Playlist, Video};
|
||||
use eframe::egui::{Context, Ui};
|
||||
use eframe::{Frame, egui};
|
||||
use std::path::PathBuf;
|
||||
use tokio::runtime::Handle;
|
||||
use tracing::warn;
|
||||
use yt_dlp::client::LibraryInstaller;
|
||||
|
||||
pub(crate) struct Downloader {
|
||||
yt_downloader: Option<yt_dlp::Downloader>,
|
||||
tokio_handle: Handle,
|
||||
yt_dlp_installed: bool,
|
||||
rejected_yt_dlp_install: bool,
|
||||
ffmpeg_installed: 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 {
|
||||
pub fn new() -> Self {
|
||||
let yt_downloader = None;
|
||||
Self {
|
||||
yt_downloader,
|
||||
tokio_handle: Handle::current(),
|
||||
yt_dlp_installed: false,
|
||||
rejected_yt_dlp_install: false,
|
||||
ffmpeg_installed: false,
|
||||
rejected_ffmpeg_install: false,
|
||||
}
|
||||
}
|
||||
|
||||
async fn install_yt_dlp(data_dir: String) -> Result<(), String> {
|
||||
let libraries_dir = PathBuf::from(format!("{}/libs", &data_dir));
|
||||
let installer = LibraryInstaller::new(libraries_dir);
|
||||
if let Err(e) = installer.install_youtube(None).await {
|
||||
warn!("Failed to install yt-dlp: {}", e);
|
||||
return Err(e.to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn install_ffmpeg(data_dir: String) -> Result<(), String> {
|
||||
let libraries_dir = PathBuf::from(format!("{}/libs", &data_dir));
|
||||
let installer = LibraryInstaller::new(libraries_dir);
|
||||
if let Err(e) = installer.install_ffmpeg(None).await {
|
||||
warn!("Failed to install yt-dlp: {}", e);
|
||||
return Err(e.to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn create_new_yt_downloader(application: &Application) -> Option<yt_dlp::Downloader> {
|
||||
Err("Not implemented".to_string()).expect("Soon")
|
||||
}
|
||||
|
||||
fn check_yt_dlp(data_dir: String) -> bool {
|
||||
let path = PathBuf::from(format!("{}/libs/yt-dlp", &data_dir));
|
||||
path.exists()
|
||||
}
|
||||
|
||||
fn check_ffmpeg(data_dir: String) -> bool {
|
||||
let path = PathBuf::from(format!("{}/libs/ffmpeg", &data_dir));
|
||||
path.exists()
|
||||
}
|
||||
}
|
||||
|
||||
impl Layer for Downloader {
|
||||
fn logic(&mut self, application: &mut Application, ctx: &Context, frame: &mut Frame) {
|
||||
if !self.yt_dlp_installed {
|
||||
if Downloader::check_yt_dlp(application.data_dir.clone()) {
|
||||
self.yt_dlp_installed = true;
|
||||
}
|
||||
}
|
||||
if !self.ffmpeg_installed {
|
||||
if Downloader::check_ffmpeg(application.data_dir.clone()) {
|
||||
self.ffmpeg_installed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, frame: &mut Frame) {
|
||||
if !self.yt_dlp_installed && !self.rejected_yt_dlp_install {
|
||||
egui::Window::new("Missing yt-dlp").show(ui, |ui| {
|
||||
ui.label("yt-dlp is not installed. Would you like to install it?");
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Yes").clicked() {
|
||||
self.tokio_handle
|
||||
.spawn(Self::install_yt_dlp(application.data_dir.clone()));
|
||||
}
|
||||
if ui.button("No").clicked() {
|
||||
self.rejected_yt_dlp_install = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if !self.ffmpeg_installed && !self.rejected_ffmpeg_install {
|
||||
egui::Window::new("Missing ffmpeg").show(ui, |ui| {
|
||||
ui.label("ffmpeg is not installed. Would you like to install it?");
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Yes").clicked() {
|
||||
self.tokio_handle
|
||||
.spawn(Self::install_ffmpeg(application.data_dir.clone()));
|
||||
}
|
||||
if ui.button("No").clicked() {
|
||||
self.rejected_ffmpeg_install = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-12
@@ -1,19 +1,13 @@
|
||||
use eframe::{egui, Frame};
|
||||
use crate::app::Application;
|
||||
use eframe::{Frame, egui};
|
||||
use egui::Context;
|
||||
use egui::Ui;
|
||||
use crate::app::Application;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub trait Layer {
|
||||
fn logic(&mut self, application: &mut Application, ctx: &Context, frame: &mut Frame) {
|
||||
fn logic(&mut self, application: &mut Application, ctx: &Context, frame: &mut Frame) {}
|
||||
|
||||
}
|
||||
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, frame: &mut Frame) {
|
||||
|
||||
}
|
||||
|
||||
fn on_exit(&mut self, application: &mut Application) {
|
||||
|
||||
}
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, frame: &mut Frame) {}
|
||||
|
||||
fn on_exit(&mut self, application: &mut Application) {}
|
||||
}
|
||||
@@ -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));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -1,3 +1,4 @@
|
||||
use crate::left_panel::LeftPanel;
|
||||
use crate::top_bar_layer::TopBarLayer;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
@@ -6,12 +7,15 @@ use tracing::{debug, error};
|
||||
|
||||
mod app;
|
||||
mod args;
|
||||
mod downloader;
|
||||
mod layer;
|
||||
mod logging;
|
||||
mod top_bar_layer;
|
||||
mod video_quality;
|
||||
mod types;
|
||||
mod left_panel;
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let args = args::parse_args();
|
||||
logging::init(args.verbose);
|
||||
debug!("Using args: \n{:#?}\n", args);
|
||||
@@ -32,6 +36,8 @@ fn main() {
|
||||
|
||||
let mut layers: Vec<Box<dyn layer::Layer>> = Vec::new();
|
||||
layers.push(Box::new(TopBarLayer::default()));
|
||||
layers.push(Box::new(LeftPanel::default()));
|
||||
layers.push(Box::new(downloader::Downloader::new()));
|
||||
|
||||
let mut options = eframe::NativeOptions::default();
|
||||
options.persistence_path = Some(
|
||||
@@ -42,7 +48,7 @@ fn main() {
|
||||
eframe::run_native(
|
||||
"yt-offline",
|
||||
options,
|
||||
Box::new(|cc| Ok(Box::new(app::Application::new(cc, layers)))),
|
||||
Box::new(|cc| Ok(Box::new(app::Application::new(cc, layers, &args)))),
|
||||
)
|
||||
.expect("TODO: panic message");
|
||||
}
|
||||
|
||||
+25
-11
@@ -1,7 +1,7 @@
|
||||
use crate::app::Application;
|
||||
use crate::layer::Layer;
|
||||
use crate::video_quality::VideoDownloadQuality;
|
||||
use eframe::egui::{Context, Ui};
|
||||
use crate::types::VideoDownloadQuality;
|
||||
use eframe::egui::Ui;
|
||||
use eframe::{Frame, egui};
|
||||
use tracing::warn;
|
||||
|
||||
@@ -12,9 +12,7 @@ pub struct TopBarLayer {
|
||||
}
|
||||
|
||||
impl Layer for TopBarLayer {
|
||||
fn logic(&mut self, application: &mut Application, ctx: &Context, frame: &mut Frame) {}
|
||||
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, frame: &mut Frame) {
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, _frame: &mut Frame) {
|
||||
egui::MenuBar::new().ui(ui, |ui: &mut Ui| {
|
||||
ui.menu_button("File", |ui: &mut Ui| {
|
||||
if ui.button("Settings").clicked() {
|
||||
@@ -41,6 +39,8 @@ impl Layer for TopBarLayer {
|
||||
if self.show_settings_window {
|
||||
egui::Window::new("Settings")
|
||||
.open(&mut self.show_settings_window)
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ui, |ui: &mut Ui| {
|
||||
if ui
|
||||
.checkbox(
|
||||
@@ -65,31 +65,35 @@ impl Layer for TopBarLayer {
|
||||
}
|
||||
};
|
||||
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.radio_value(
|
||||
&mut application.settings.video_download_quality,
|
||||
VideoDownloadQuality::Best,
|
||||
"Best",
|
||||
"Best (Highest available)",
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut application.settings.video_download_quality,
|
||||
VideoDownloadQuality::High,
|
||||
"High",
|
||||
"High (Target 1080p)",
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut application.settings.video_download_quality,
|
||||
VideoDownloadQuality::Medium,
|
||||
"Medium",
|
||||
"Medium (Target 720p)",
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut application.settings.video_download_quality,
|
||||
VideoDownloadQuality::Low,
|
||||
"Low",
|
||||
"Low (Target 480p)",
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut application.settings.video_download_quality,
|
||||
VideoDownloadQuality::Worst,
|
||||
"Worst",
|
||||
"Worst (Lowest available)",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -98,10 +102,12 @@ impl Layer for TopBarLayer {
|
||||
if self.show_about_window {
|
||||
egui::Window::new("About")
|
||||
.open(&mut self.show_about_window)
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ui, |ui: &mut Ui| {
|
||||
ui.heading("yt-offline");
|
||||
ui.label("A simple unified offline YouTube downloader + viewer");
|
||||
ui.label("Created by Lyra in Rust <3");
|
||||
ui.label("Fully human generated by Lyra in Rust <3");
|
||||
ui.separator();
|
||||
ui.label("Honorable mentions:");
|
||||
ui.horizontal(|ui| {
|
||||
@@ -112,6 +118,14 @@ impl Layer for TopBarLayer {
|
||||
ui.label("egui");
|
||||
ui.hyperlink("https://github.com/emilk/egui");
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("egui-sharkplayer");
|
||||
ui.hyperlink("https://codeberg.org/sharkyshark/egui-sharkplayer");
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("The yt-dlp crate");
|
||||
ui.hyperlink("https://github.com/boul2gom/yt-dlp")
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yt_dlp::cache::VideoQuality;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub(crate) struct Video {
|
||||
pub(crate) meta_data: MetaData,
|
||||
pub(crate) video_path: String,
|
||||
pub(crate) video_quality: VideoDownloadQuality,
|
||||
pub(crate) downloaded: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub(crate) struct MetaData {
|
||||
pub(crate) title: String,
|
||||
pub(crate) author: String,
|
||||
pub(crate) description: String,
|
||||
pub(crate) original_url: String,
|
||||
pub(crate) has_thumbnail: bool,
|
||||
pub(crate) thumbnail_path: String,
|
||||
pub(crate) thumbnail_path_low_quality: String,
|
||||
pub(crate) downloaded: bool,
|
||||
pub(crate) date_downloaded: String,
|
||||
pub(crate) date_published: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub(crate) struct Playlist {
|
||||
pub(crate) meta_data: MetaData,
|
||||
pub(crate) videos: Vec<Video>,
|
||||
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)]
|
||||
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,34 +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 {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
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