Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
👽 Better thumbnail handling from tf-extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmiddiii committed Oct 6, 2021
1 parent b833387 commit 8d21d51
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
47 changes: 16 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ reqwest = "0.11.4"
log = "0.4.14"
env_logger = "0.9.0"

tf_core = { package = "tf_core", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_join = { package = "tf_join", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_filter = { package = "tf_filter", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_observer = { package = "tf_observer", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_playlist = { package = "tf_playlist", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_yt = { package = "tf_platform_youtube", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_pt = { package = "tf_platform_peertube", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
tf_lbry = { package = "tf_platform_lbry", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "a8016af0b418b8605f23ac86561b1cc170c9bb1d" }
image = "0.23.14"

tf_core = { package = "tf_core", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_join = { package = "tf_join", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_filter = { package = "tf_filter", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_observer = { package = "tf_observer", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_playlist = { package = "tf_playlist", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_yt = { package = "tf_platform_youtube", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_pt = { package = "tf_platform_peertube", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
tf_lbry = { package = "tf_platform_lbry", git = "https://github.com/Tubefeeder/tubefeeder-extractor.git", rev = "1656676ebd89ecbe6f3eeca651f73ba1c9c3855f" }
30 changes: 20 additions & 10 deletions src/gui/feed/thumbnail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
*
*/

use std::sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
use std::{
convert::TryInto,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
};

use gdk_pixbuf::{Colorspace, Pixbuf};
Expand All @@ -30,12 +33,18 @@ use relm_derive::{widget, Msg};
use tf_core::Video;
use tf_join::AnyVideo;

const WIDTH: i32 = 120;
const HEIGHT: i32 = 90;
const WIDTH: u32 = 120;
const HEIGHT: u32 = 90;

pub fn default_pixbuf() -> Pixbuf {
let pixbuf =
Pixbuf::new(Colorspace::Rgb, true, 8, WIDTH, HEIGHT).expect("Could not create empty");
let pixbuf = Pixbuf::new(
Colorspace::Rgb,
true,
8,
WIDTH.try_into().unwrap_or(1),
HEIGHT.try_into().unwrap_or(1),
)
.expect("Could not create empty");
pixbuf.fill(0);

pixbuf
Expand Down Expand Up @@ -101,9 +110,10 @@ impl Widget for Thumbnail {
let path = user_data_dir;

if !path.exists() {
video
.thumbnail_with_client(&client, path.clone(), WIDTH, HEIGHT)
.await;
let image = video.thumbnail_with_client(&client).await;
let resized =
image.resize_to_fill(WIDTH, HEIGHT, image::imageops::FilterType::Triangle);
let _ = resized.save(&path);
}

if !deleted.lock().unwrap().load(Ordering::Relaxed) {
Expand Down

0 comments on commit 8d21d51

Please sign in to comment.