update width
This commit is contained in:
parent
1d1c49c5fa
commit
70eadeadb2
8 changed files with 104 additions and 40 deletions
|
@ -28,7 +28,10 @@ mod ytdl {
|
|||
|
||||
impl qobject::Ytdl {
|
||||
#[qinvokable]
|
||||
pub fn get_video(mut self: Pin<&mut Self>, url: QUrl) -> bool {
|
||||
pub fn get_video(
|
||||
mut self: Pin<&mut Self>,
|
||||
url: QUrl,
|
||||
) -> bool {
|
||||
if !url.is_valid() {
|
||||
false
|
||||
} else {
|
||||
|
@ -37,7 +40,8 @@ mod ytdl {
|
|||
data_dir.push("librepresenter");
|
||||
data_dir.push("ytdl");
|
||||
if !data_dir.exists() {
|
||||
fs::create_dir(&data_dir).expect("Could not create ytdl dir");
|
||||
fs::create_dir(&data_dir)
|
||||
.expect("Could not create ytdl dir");
|
||||
}
|
||||
println!("{:?}", data_dir);
|
||||
self.as_mut().set_loading(true);
|
||||
|
@ -53,25 +57,34 @@ mod ytdl {
|
|||
.download(true)
|
||||
.run()
|
||||
.unwrap();
|
||||
let output = ytdl.into_single_video().unwrap();
|
||||
let output =
|
||||
ytdl.into_single_video().unwrap();
|
||||
println!("{:?}", output.title);
|
||||
println!("{:?}", output.thumbnail);
|
||||
println!("{:?}", output.url);
|
||||
let title = QString::from(&output.title);
|
||||
let thumbnail = QUrl::from(&output.thumbnail.unwrap_or_default());
|
||||
let thumbnail = QUrl::from(
|
||||
&output.thumbnail.unwrap_or_default(),
|
||||
);
|
||||
let mut file = String::from(output_dirs);
|
||||
file.push_str("/");
|
||||
file.push_str(&output.title);
|
||||
file.push_str(".");
|
||||
file.push_str(&output.ext.unwrap_or_default());
|
||||
file.push_str(
|
||||
&output.ext.unwrap_or_default(),
|
||||
);
|
||||
println!("{:?}", file);
|
||||
|
||||
thread.queue(move |mut qobject_ytdl| {
|
||||
qobject_ytdl.as_mut().set_loaded(true);
|
||||
qobject_ytdl.as_mut().set_loading(false);
|
||||
qobject_ytdl.as_mut().set_title(title);
|
||||
qobject_ytdl.as_mut().set_thumbnail(thumbnail);
|
||||
qobject_ytdl.as_mut().set_file(QUrl::from(&file));
|
||||
qobject_ytdl
|
||||
.as_mut()
|
||||
.set_thumbnail(thumbnail);
|
||||
qobject_ytdl
|
||||
.as_mut()
|
||||
.set_file(QUrl::from(&file));
|
||||
})
|
||||
});
|
||||
true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue