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