Skip to main content

flix_fs/scanner/
mod.rs

1//! This module contains all of the filesystem scanner modules
2//!
3//! The most common scanner to use is [generic::Scanner] which will
4//! automatically detect and use the appropriate scanner.
5
6use flix_model::id::{CollectionId, MovieId, ShowId};
7use flix_model::numbers::{EpisodeNumbers, SeasonNumber};
8
9pub mod library;
10
11pub mod generic;
12
13pub mod collection;
14
15pub mod movie;
16
17pub mod episode;
18pub mod season;
19pub mod show;
20
21/// A reference to a piece of media
22#[derive(Debug, Clone)]
23pub enum MediaRef<ID> {
24	/// An explicit ID
25	Id(ID),
26	/// A filesystem slug
27	Slug(String),
28}
29
30impl<ID> MediaRef<ID> {
31	/// Get the slug if it exists
32	pub fn into_slug(self) -> Option<String> {
33		match self {
34			MediaRef::Id(_) => None,
35			MediaRef::Slug(slug) => Some(slug),
36		}
37	}
38}
39
40/// A scanned collection
41#[derive(Debug)]
42pub struct CollectionScan {
43	/// The ID of the parent collection (if any)
44	pub parent_ref: Option<MediaRef<CollectionId>>,
45	/// The ID of the collection
46	pub id_ref: MediaRef<CollectionId>,
47	/// The file name of the poster file
48	pub poster_file_name: Option<String>,
49}
50
51/// A scanned movie
52#[derive(Debug)]
53pub struct MovieScan {
54	/// The ID of the parent collection (if any)
55	pub parent_ref: Option<MediaRef<CollectionId>>,
56	/// The ID of the movie
57	pub id_ref: MediaRef<MovieId>,
58	/// The file name of the media file
59	pub media_file_name: String,
60	/// The file name of the poster file
61	pub poster_file_name: Option<String>,
62}
63
64/// A scanned show
65#[derive(Debug)]
66pub struct ShowScan {
67	/// The ID of the parent collection (if any)
68	pub parent_ref: Option<MediaRef<CollectionId>>,
69	/// The ID of the show
70	pub id_ref: MediaRef<ShowId>,
71	/// The file name of the poster file
72	pub poster_file_name: Option<String>,
73}
74
75/// A scanned season
76#[derive(Debug)]
77pub struct SeasonScan {
78	/// The ID of the show this season belongs to
79	pub show_ref: MediaRef<ShowId>,
80	/// The season this episode belongs to
81	pub season: SeasonNumber,
82	/// The file name of the poster file
83	pub poster_file_name: Option<String>,
84}
85
86/// A scanned episode
87#[derive(Debug)]
88pub struct EpisodeScan {
89	/// The ID of the show this episode belongs to
90	pub show_ref: MediaRef<ShowId>,
91	/// The season this episode belongs to
92	pub season: SeasonNumber,
93	/// The number(s) of this episode
94	pub episode: EpisodeNumbers,
95	/// The file name of the media file
96	pub media_file_name: String,
97	/// The file name of the poster file
98	pub poster_file_name: Option<String>,
99}