feat: add ffmpeg plugin and update plugin interface to support temporary directories and context-dependent metrics
Release / check-release (push) Successful in 15s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m31s
CI / Build Linux (push) Successful in 1m47s
Release / check-release (push) Successful in 15s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m31s
CI / Build Linux (push) Successful in 1m47s
This commit is contained in:
1 parent
e46696c521
commit
b97a108d1e
10 files changed
+705
-134
No files matched your search
+32
-2
@@ -1,11 +1,37 @@
|
||||
// Copyright (C) 2026 Elias Wendland <eliaswendland@pm.me>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 3 exclusively.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
pub fn identify_format(path: &str) -> Option<&'static str> {
|
||||
let p = Path::new(path);
|
||||
let ext = p.extension().and_then(|s| s.to_str()).unwrap_or(path).to_lowercase();
|
||||
let ext = p
|
||||
.extension()
|
||||
.and_then(|s| s.to_str())
|
||||
.unwrap_or(path)
|
||||
.to_lowercase();
|
||||
match ext.as_str() {
|
||||
"jpg" | "jpeg" => Some("jpeg"),
|
||||
"png" => Some("png"),
|
||||
"mp4" => Some("mp4"),
|
||||
"webm" => Some("webm"),
|
||||
"mkv" => Some("mkv"),
|
||||
"avi" => Some("avi"),
|
||||
"mov" => Some("mov"),
|
||||
"wmv" => Some("wmv"),
|
||||
"flv" => Some("flv"),
|
||||
"gif" => Some("gif"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -35,7 +61,11 @@ mod tests {
|
||||
test_ident!(test_identify_format_10, "test.bmp", None);
|
||||
test_ident!(test_identify_format_11, "file.JPEG", Some("jpeg"));
|
||||
test_ident!(test_identify_format_12, "file.PNG", Some("png"));
|
||||
test_ident!(test_identify_format_13, "complex.file.name.jpg", Some("jpeg"));
|
||||
test_ident!(
|
||||
test_identify_format_13,
|
||||
"complex.file.name.jpg",
|
||||
Some("jpeg")
|
||||
);
|
||||
test_ident!(test_identify_format_14, ".hidden.png", Some("png"));
|
||||
test_ident!(test_identify_format_15, "jpg", Some("jpeg")); // "jpg" passed without dot, treats as ext if no dot in path but path is "jpg", ext becomes "jpg"
|
||||
test_ident!(test_identify_format_16, "a.jpg.txt", None);
|
||||
|
||||
Reference in new issue
Block a user