You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ident.rs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. use std::path::Path;
  2. /// Identifier for a particular movie or episode. Doesn't handle different
  3. /// releases of movies or anything like that.
  4. #[derive(Clone, Eq, PartialEq, Hash, Debug)]
  5. pub enum MediaId {
  6. Movie {
  7. /// Name of the movie.
  8. name: String,
  9. /// Year released, to disambiguate.
  10. year: String,
  11. },
  12. /// Episode of some TV show or anime.
  13. Episode {
  14. /// Name of the show.
  15. name: String,
  16. /// Some shows aren't released as seasons, often anime.
  17. season: Option<u32>,
  18. /// Episode with the season, or overall of no seasons.
  19. episode: u32,
  20. /// What kind of TV is it?
  21. cat: TvCategory,
  22. },
  23. }
  24. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
  25. pub enum TvCategory {
  26. /// Regular TV, typically western but mostly everything else.
  27. Tv,
  28. /// Anime, which often is categorized seperately.
  29. Anime,
  30. }
  31. /// Hint to provide to matching engine about content identity.
  32. #[derive(Clone, Eq, PartialEq, Hash, Debug)]
  33. pub enum IdHint {
  34. /// Name of thing, like "Inception", or "Game of Thrones".
  35. Name(String),
  36. /// Year released, usually for movies, like "2010".
  37. Year(String),
  38. /// Season of a show, like "S06".
  39. Season(String),
  40. /// Episode number, usually passed *with* a season, like "E11".
  41. Episode(String),
  42. }
  43. /// Some kind of error that can happen when trying to identify a match.
  44. #[derive(Debug)]
  45. pub enum MatchError {
  46. /// No matches found.
  47. NoMatches,
  48. /// Muliple matches for the file, should handle accordingly.
  49. Multiple(Vec<MediaId>),
  50. /// Error with the network.
  51. NetworkError,
  52. /// File permissions error.
  53. PermissionsError,
  54. /// In case they're using the wrong version of filebot.
  55. NonlibreError,
  56. }
  57. // TODO Decide what we want to be able to do with an engine.
  58. pub trait MatchingEngine {
  59. fn identify(&self, path: &Path) -> Result<MediaId, MatchError>;
  60. }