+22
-7
src-tauri/src/frontend_calls/load_photos.rs
+22
-7
src-tauri/src/frontend_calls/load_photos.rs
···
30
30
if p.metadata().unwrap().is_file() {
31
31
let fname = p.path();
32
32
33
-
let re1 = Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap();
34
-
let re2 = Regex::new(
35
-
r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap();
36
-
let re3 = Regex::new("VRChat_[0-9]{4}x[0-9]{4}_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}.png").unwrap();
37
-
38
33
let name = p.file_name();
39
34
let name = name.to_str().unwrap();
40
35
41
-
let re3_match = re3.is_match(name);
36
+
// I know this is janky
37
+
// i'm sorry
38
+
39
+
// All regex's are doubled up as some resolutions have shorter names
40
+
41
+
// This is an old format VRChat used for naming photos
42
+
let re3_match =
43
+
Regex::new("VRChat_[0-9]{4}x[0-9]{4}_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}.png").unwrap().is_match(name) ||
44
+
Regex::new("VRChat_[0-9]{4}x[0-9]{3}_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}.png").unwrap().is_match(name);
45
+
46
+
let re = vec![
47
+
// This is the current format used by VRChat
48
+
Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap().is_match(name),
49
+
Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{3}.png").unwrap().is_match(name),
42
50
43
-
if re1.is_match(name) || re2.is_match(name) || re3_match {
51
+
// This is the format VRCX uses if you enable renaming photos
52
+
Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap().is_match(name),
53
+
Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{3}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap().is_match(name),
54
+
55
+
re3_match
56
+
];
57
+
58
+
if re.iter().any(| &x | x) {
44
59
let path = fname.to_path_buf().clone();
45
60
let metadata = fs::metadata(&path).unwrap();
46
61