1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Parse a set of related filenames together, using what is invariant across
//! the set to disambiguate what a single filename cannot.
//!
//! Each input is parsed on its own, then two passes run: [`segment`] suppresses
//! per-file directory noise, and [`diff`] reconciles each parse against what
//! varies across the set.
use crateElement;
use crateOptions;
/// Parse a single filename that may carry a directory prefix, so the result
/// describes the file rather than the folder.
///
/// [`parse`](crate::parse) treats its input as one flat string, matching
/// upstream, so a path leaves separators and duplicated folder text in the
/// title. This strips a real directory prefix first and recovers a title that
/// lives only in the parent folder. Both `/` and `\` work on every platform,
/// including UNC and drive-letter roots.
///
/// Without a directory prefix this is exactly [`parse`](crate::parse), and a
/// separator inside a title (`Fate/stay night`) is left alone.
///
/// ```
/// let elements = anitomy_ng::parse_path(
/// "Frieren (01-12) [Batch]/Frieren - 05 [1080p].mkv",
/// anitomy_ng::Options::default(),
/// );
/// let title = elements.iter().find(|e| e.kind == anitomy_ng::ElementKind::Title);
/// assert_eq!(title.map(|e| e.value.as_str()), Some("Frieren"));
/// ```
///
/// For a set of related files, prefer [`parse_together`], which additionally
/// uses what varies across the set.
/// Parse related filenames together, order-preserving (result `i` is for
/// `inputs[i]`); an unrelated or single-item list is left as its per-file parse.