feat(indexer): tvsearch with season and episode tags (#78)
This commit was merged in pull request #78.
This commit is contained in:
@@ -159,37 +159,10 @@ fn is_audio_family(t: &str) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// `S01`, `S01E02`, `S01E01E02`, `S01-E02`, `1x02`.
|
||||
/// `S01`, `S01E02`, `S01E01E02`, `S01-E02`, `1x02`, `S01-S03`, an air
|
||||
/// date. Anything that ends the title region on a TV tag.
|
||||
pub(crate) fn is_season_episode(t: &str) -> bool {
|
||||
fn digits(s: &str) -> (usize, &str) {
|
||||
let n = s.bytes().take_while(u8::is_ascii_digit).count();
|
||||
(n, &s[n..])
|
||||
}
|
||||
if let Some(rest) = t.strip_prefix('s') {
|
||||
let (n, mut rest) = digits(rest);
|
||||
if !(1..=2).contains(&n) {
|
||||
return false;
|
||||
}
|
||||
while !rest.is_empty() {
|
||||
let Some(r) = rest.strip_prefix('e').or_else(|| rest.strip_prefix("-e")) else {
|
||||
return false;
|
||||
};
|
||||
let (m, r2) = digits(r);
|
||||
if !(1..=3).contains(&m) {
|
||||
return false;
|
||||
}
|
||||
rest = r2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let (n, rest) = digits(t);
|
||||
if (1..=2).contains(&n) {
|
||||
if let Some(r) = rest.strip_prefix('x') {
|
||||
let (m, r2) = digits(r);
|
||||
return (2..=3).contains(&m) && r2.is_empty();
|
||||
}
|
||||
}
|
||||
false
|
||||
crate::episodes::tag_of(t).is_some()
|
||||
}
|
||||
|
||||
/// A plausible release year: four digits, 1900–2099.
|
||||
|
||||
Reference in New Issue
Block a user