Compare commits
No commits in common. "b2ef1d3d3dc8f6813988e81e66bf2501804c0f8e" and "4ba8e3e3eec01daf8e652b72498e840295384216" have entirely different histories.
b2ef1d3d3d
...
4ba8e3e3ee
27
default.nix
Normal file
27
default.nix
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> {
|
||||||
|
overlays = [
|
||||||
|
(import (builtins.fetchTarball
|
||||||
|
"https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
rust = pkgs.rust-bin.stable.latest.rust.override {
|
||||||
|
extensions = [ "rust-src" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
in with pkgs;
|
||||||
|
pkgs.mkShell rec {
|
||||||
|
name = "rust";
|
||||||
|
buildInputs = [
|
||||||
|
openssl
|
||||||
|
pkg-config
|
||||||
|
cargo
|
||||||
|
rust
|
||||||
|
rustfmt
|
||||||
|
rust-analyzer
|
||||||
|
wasm-pack
|
||||||
|
wasm-bindgen-cli
|
||||||
|
nodePackages.rollup
|
||||||
|
];
|
||||||
|
}
|
||||||
18
src/lib.rs
18
src/lib.rs
@ -320,18 +320,6 @@ pub struct Movie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Movie {
|
impl Movie {
|
||||||
fn min_pixel_count(&self) -> Option<usize> {
|
|
||||||
if self.files.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(self.files.iter().fold(usize::max_value(), |acc, (_, cmd)| {
|
|
||||||
let min = cmd.video.iter().fold(usize::max_value(), |acc, v| {
|
|
||||||
std::cmp::min(acc, v.width * v.height)
|
|
||||||
});
|
|
||||||
std::cmp::min(acc, min)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn min_bit_rate(&self) -> Option<usize> {
|
fn min_bit_rate(&self) -> Option<usize> {
|
||||||
if self.files.is_empty() {
|
if self.files.is_empty() {
|
||||||
None
|
None
|
||||||
@ -379,8 +367,6 @@ impl Movies {
|
|||||||
let parent = clean_path_parent(path)
|
let parent = clean_path_parent(path)
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_ascii_lowercase()
|
.to_ascii_lowercase()
|
||||||
.replace("-", " ")
|
|
||||||
.replace("'", "")
|
|
||||||
.to_string();
|
.to_string();
|
||||||
if date_re.is_match(&parent) {
|
if date_re.is_match(&parent) {
|
||||||
movie_counter.entry(parent).or_insert(Vec::new()).push(m);
|
movie_counter.entry(parent).or_insert(Vec::new()).push(m);
|
||||||
@ -402,8 +388,8 @@ impl Movies {
|
|||||||
|
|
||||||
for (_parent, mut movies) in movie_counter.into_iter() {
|
for (_parent, mut movies) in movie_counter.into_iter() {
|
||||||
if movies.len() > 1 {
|
if movies.len() > 1 {
|
||||||
// Sort, lowest resolution movie first
|
// Sort, lowest bit_rate movie first
|
||||||
movies.sort_by(|a, b| a.min_pixel_count().cmp(&b.min_pixel_count()));
|
movies.sort_by(|a, b| a.min_bit_rate().cmp(&b.min_bit_rate()));
|
||||||
// Flip order, we care about the largest.
|
// Flip order, we care about the largest.
|
||||||
movies.reverse();
|
movies.reverse();
|
||||||
// Take the largest image, return the rest for removal.
|
// Take the largest image, return the rest for removal.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user