mirror of
https://github.com/narrrl/ytd-rs.git
synced 2026-11-03 16:41:27 +01:00
added option for multiple link
This commit is contained in:
1 parent
c0b1347351
commit
964845f084
2 files changed
+15
-9
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ytd-rs"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Nils Pukropp <nils.pukropp@outlook.de>"]
|
||||
edition = "2018"
|
||||
license-file ="LICENSE"
|
||||
|
||||
+14
-8
@@ -89,7 +89,7 @@ impl Display for Arg {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct YoutubeDL {
|
||||
path: PathBuf,
|
||||
link: String,
|
||||
links: Vec<String>,
|
||||
args: Vec<Arg>,
|
||||
}
|
||||
|
||||
@@ -146,7 +146,11 @@ impl YoutubeDL {
|
||||
/// and finally a link that can be `""` if no video should be downloaded
|
||||
///
|
||||
/// The path gets canonicalized and the directory gets created by the constructor
|
||||
pub fn new(dl_path: &str, args: Vec<Arg>, link: &str) -> Result<YoutubeDL, String> {
|
||||
pub fn new_multiple_links(
|
||||
dl_path: &str,
|
||||
args: Vec<Arg>,
|
||||
links: Vec<String>,
|
||||
) -> Result<YoutubeDL, String> {
|
||||
// create path
|
||||
let path = Path::new(dl_path);
|
||||
|
||||
@@ -169,15 +173,15 @@ impl YoutubeDL {
|
||||
// absolute path
|
||||
match canonicalize(dl_path) {
|
||||
// return new youtube-dl job
|
||||
Ok(path) => Ok(YoutubeDL {
|
||||
path,
|
||||
link: link.to_string(),
|
||||
args,
|
||||
}),
|
||||
Ok(path) => Ok(YoutubeDL { path, links, args }),
|
||||
Err(why) => Err(format!("Error creating YouTubeDL: {:?}", why)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(dl_path: &str, args: Vec<Arg>, link: &str) -> Result<YoutubeDL, String> {
|
||||
YoutubeDL::new_multiple_links(dl_path, args, vec![link.to_string()])
|
||||
}
|
||||
|
||||
/// Starts the download and returns when finished the result as [`YoutubeDLResult`].
|
||||
pub fn download(&self) -> YoutubeDLResult {
|
||||
let pr_result = self.spawn_youtube_dl();
|
||||
@@ -215,7 +219,9 @@ impl YoutubeDL {
|
||||
};
|
||||
}
|
||||
|
||||
cmd.arg(&self.link);
|
||||
for link in self.links.iter() {
|
||||
cmd.arg(&link);
|
||||
}
|
||||
|
||||
let pr = match cmd.spawn() {
|
||||
Err(why) => {
|
||||
|
||||
Reference in new issue
Block a user