Compare commits
17 Commits
af49339517
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b34439cc9a | |||
| f851cdbc30 | |||
| 6d4c5f92dc | |||
| 09d9204ea5 | |||
| 3a7cb6c6a3 | |||
| c4424b806f | |||
| 90155796c6 | |||
| 66f06461a1 | |||
| 8736644435 | |||
| ab77d59e29 | |||
| 6ebce96d96 | |||
| f600ee3692 | |||
| 30167d0eee | |||
| 8e3e04791b | |||
| c7c23dc815 | |||
| f9e7958120 | |||
| 6970d71164 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
|
/.idea/
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "youtube-dl-gtk"
|
name = "media-downloader-gtk"
|
||||||
version = "0.1.0"
|
description = "a simple frontend for youtube-dlc"
|
||||||
|
version = "0.1.5"
|
||||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||||
|
repository = "https://tinybird.dev/max/media-downloader"
|
||||||
|
license = "MIT"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Max Bradbury
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
29
README.md
Normal file
29
README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# media-downloader
|
||||||
|
|
||||||
|
a simple graphical frontend for the `youtube-dl` media downloader.
|
||||||
|
`youtube-dl` must be installed and in your PATH.
|
||||||
|
|
||||||
|
really just an experiment in creating my first desktop program, so don't expect too much.
|
||||||
|
|
||||||
|
uses `gtk-rs`. released under the MIT license.
|
||||||
|
|
||||||
|
## features
|
||||||
|
|
||||||
|
download from any media source that `youtube-dl` supports (e.g. soundcloud, mixcloud, etc.)
|
||||||
|
|
||||||
|
extract audio and convert to mp3
|
||||||
|
|
||||||
|
## known problems
|
||||||
|
|
||||||
|
no validation for URL bar
|
||||||
|
|
||||||
|
no user feedback
|
||||||
|
|
||||||
|
will hang after clicking "go!" due to `youtube-dl` being executed in the same thread.
|
||||||
|
there is no user feedback so this basically looks like the program crashing.
|
||||||
|
|
||||||
|
TODO: investigate using https://crates.io/crates/gtk-future-executor
|
||||||
|
|
||||||
|
would it be possible to add progress bars for in-progress downloads somehow?
|
||||||
|
|
||||||
|
notifications for when downloads finish?
|
||||||
39
src/main.rs
39
src/main.rs
@@ -1,43 +1,66 @@
|
|||||||
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
use gio::prelude::*;
|
use gio::prelude::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{Orientation, InputPurpose};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
use gtk::Orientation;
|
use std::process::Command;
|
||||||
|
|
||||||
const SPACING: i32 = 16;
|
const SPACING: i32 = 16;
|
||||||
|
|
||||||
fn build_ui(application: >k::Application) {
|
fn build_ui(application: >k::Application) {
|
||||||
let window = gtk::ApplicationWindow::new(application);
|
let window = gtk::ApplicationWindow::new(application);
|
||||||
|
|
||||||
window.set_title("youtube-dl");
|
window.set_title("media downloader");
|
||||||
window.set_border_width(10);
|
window.set_border_width(SPACING as u32);
|
||||||
window.set_position(gtk::WindowPosition::Center);
|
window.set_position(gtk::WindowPosition::Center);
|
||||||
window.set_default_size(400, 100);
|
window.set_default_size(400, 100);
|
||||||
|
|
||||||
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
||||||
let url = gtk::Entry::new();
|
let input_url = gtk::Entry::new();
|
||||||
let horizontal = gtk::Box::new(Orientation::Horizontal, SPACING);
|
let horizontal = gtk::Box::new(Orientation::Horizontal, SPACING);
|
||||||
let convert_to_mp3 = gtk::CheckButton::with_label("convert to mp3");
|
let convert_to_mp3 = gtk::CheckButton::with_label("convert to mp3");
|
||||||
let button = gtk::Button::with_label("Go!");
|
let button = gtk::Button::with_label("Go!");
|
||||||
|
|
||||||
url.set_placeholder_text(Some("Enter URL here"));
|
input_url.set_placeholder_text(Some("Enter URL here"));
|
||||||
|
input_url.set_input_purpose(InputPurpose::Url);
|
||||||
|
|
||||||
horizontal.set_spacing(SPACING);
|
|
||||||
horizontal.set_homogeneous(true);
|
horizontal.set_homogeneous(true);
|
||||||
|
|
||||||
window.add(&vertical);
|
window.add(&vertical);
|
||||||
|
|
||||||
vertical.add(&url);
|
vertical.add(&input_url);
|
||||||
vertical.add(&horizontal);
|
vertical.add(&horizontal);
|
||||||
|
|
||||||
horizontal.add(&convert_to_mp3);
|
horizontal.add(&convert_to_mp3);
|
||||||
horizontal.add(&button);
|
horizontal.add(&button);
|
||||||
|
|
||||||
window.show_all();
|
window.show_all();
|
||||||
|
|
||||||
|
button.connect_clicked(move |_| {
|
||||||
|
let url = input_url.get_buffer().get_text();
|
||||||
|
println!("url: {}", url);
|
||||||
|
let mut youtube_dl = Command::new("youtube-dl");
|
||||||
|
|
||||||
|
if convert_to_mp3.get_active() {
|
||||||
|
println!("convert to mp3: true");
|
||||||
|
youtube_dl.arg("--extract-audio");
|
||||||
|
youtube_dl.arg("--audio-format");
|
||||||
|
youtube_dl.arg("mp3");
|
||||||
|
}
|
||||||
|
|
||||||
|
youtube_dl.arg("--output");
|
||||||
|
youtube_dl.arg("~/Downloads/%(title)s.%(ext)s");
|
||||||
|
youtube_dl.arg(url);
|
||||||
|
|
||||||
|
let output = youtube_dl.output().expect("failed to execute process");
|
||||||
|
println!("exit status: {:#?}", output);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let application = gtk::Application::new(
|
let application = gtk::Application::new(
|
||||||
Some("dev.tinybird.max.youtube-dl-gtk"),
|
Some("dev.tinybird.max.media-downloader"),
|
||||||
Default::default()
|
Default::default()
|
||||||
).expect("Initialization failed...");
|
).expect("Initialization failed...");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user