basic functionality
This commit is contained in:
parent
6970d71164
commit
f9e7958120
29
src/main.rs
29
src/main.rs
|
@ -1,7 +1,8 @@
|
||||||
use gio::prelude::*;
|
use gio::prelude::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use std::env::args;
|
|
||||||
use gtk::Orientation;
|
use gtk::Orientation;
|
||||||
|
use std::env::args;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
const SPACING: i32 = 16;
|
const SPACING: i32 = 16;
|
||||||
|
|
||||||
|
@ -14,25 +15,45 @@ fn build_ui(application: >k::Application) {
|
||||||
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"));
|
||||||
|
|
||||||
horizontal.set_spacing(SPACING);
|
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() {
|
||||||
|
|
Loading…
Reference in New Issue