Compare commits
2 Commits
af49339517
...
f9e7958120
Author | SHA1 | Date |
---|---|---|
Max Bradbury | f9e7958120 | |
Max Bradbury | 6970d71164 |
|
@ -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
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