Compare commits
No commits in common. "f9e7958120571b85a5b8e5075dc148e856f28258" and "af493395170a5267af48fe0b7a8d3e787a6a0543" have entirely different histories.
f9e7958120
...
af49339517
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
|||
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,8 +1,7 @@
|
|||
use gio::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Orientation;
|
||||
use std::env::args;
|
||||
use std::process::Command;
|
||||
use gtk::Orientation;
|
||||
|
||||
const SPACING: i32 = 16;
|
||||
|
||||
|
@ -15,45 +14,25 @@ fn build_ui(application: >k::Application) {
|
|||
window.set_default_size(400, 100);
|
||||
|
||||
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
||||
let input_url = gtk::Entry::new();
|
||||
let url = gtk::Entry::new();
|
||||
let horizontal = gtk::Box::new(Orientation::Horizontal, SPACING);
|
||||
let convert_to_mp3 = gtk::CheckButton::with_label("convert to mp3");
|
||||
let button = gtk::Button::with_label("Go!");
|
||||
|
||||
input_url.set_placeholder_text(Some("Enter URL here"));
|
||||
url.set_placeholder_text(Some("Enter URL here"));
|
||||
|
||||
horizontal.set_spacing(SPACING);
|
||||
horizontal.set_homogeneous(true);
|
||||
|
||||
window.add(&vertical);
|
||||
|
||||
vertical.add(&input_url);
|
||||
vertical.add(&url);
|
||||
vertical.add(&horizontal);
|
||||
|
||||
horizontal.add(&convert_to_mp3);
|
||||
horizontal.add(&button);
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue