mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Fallback to path and modified date if there is no unique id
This commit is contained in:
parent
1dd3e37a37
commit
34e4036f66
@ -1,8 +1,8 @@
|
|||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{hash_map::DefaultHasher, HashMap},
|
||||||
fs, io,
|
hash::{Hash, Hasher},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::Stdio,
|
process::Stdio,
|
||||||
str::{self, FromStr},
|
str::{self, FromStr},
|
||||||
@ -146,7 +146,15 @@ pub async fn identify(path: String) -> Result<MediaInfo, std::io::Error> {
|
|||||||
.find(|x| x["@type"] == "General")
|
.find(|x| x["@type"] == "General")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let sha = general["UniqueID"].to_string();
|
let sha = general["UniqueID"]
|
||||||
|
.as_str()
|
||||||
|
.map(|x| x.to_string())
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
path.hash(&mut hasher);
|
||||||
|
general["File_Modified_Date"].to_string().hash(&mut hasher);
|
||||||
|
format!("{hash:x}", hash = hasher.finish())
|
||||||
|
});
|
||||||
|
|
||||||
let subs: Vec<Subtitle> = output["media"]["track"]
|
let subs: Vec<Subtitle> = output["media"]["track"]
|
||||||
.members()
|
.members()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user