nyantrack_common/
entry.rs

1#![allow(clippy::upper_case_acronyms)]
2
3use std::sync::Arc;
4
5use language_tags::LanguageTag;
6use serde::{Deserialize, Serialize};
7
8use super::{character::Character, staff::Staff, studio::Studio};
9
10#[derive(Debug, Serialize, Deserialize)]
11pub enum Entry {
12    Anime {
13        /// The numeric ID of the entry. Must be unique within the set of
14        /// entries
15        id: u64,
16        /// The title(s) of the anime
17        titles: Titles,
18        /// The format of the anime
19        anime_type: AnimeType,
20        /// The total number of episodes that will air
21        total_episodes: Option<u32>,
22        /// The number of episodes that have aired
23        aired_episodes: u32,
24        /// The description/summary of the anime
25        description: String,
26        /// What type of source material the anime is based on
27        source: Source,
28        /// List of characters in the anime
29        characters: Vec<Character>,
30        /// List of opening theme songs
31        openings: Vec<EntrySong>,
32        /// List of ending theme songs
33        endings: Vec<EntrySong>,
34        /// List of staff who worked on the anime
35        staff: Vec<Staff>,
36        /// List of studios which worked on the anime
37        studios: Vec<Studio>,
38        /// List of related links, e.g. licensed streaming services, youtube
39        /// channels, official websites, etc.
40        links: Vec<Link>,
41        /// The YouTube ID of the anime's PV
42        pv_yt_id: String,
43    },
44    Manga {
45        /// The numeric ID of the entry. Must be unique within the set of
46        /// entries
47        id: u64,
48        titles: Titles,
49        total_chapters: Option<u32>,
50        published_chapters: u32,
51        description: String,
52        characters: Vec<Character>,
53        staff: Vec<Staff>,
54        links: Vec<Link>,
55    },
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct Titles {
60    /// The native title in its native form, e.g. 「進撃の巨人」
61    native: Option<String>,
62    /// The native title transliterated into the latin alphabet, e.g.
63    /// "Shinkegi no Kyojin"
64    romaji: Option<String>,
65    /// The official localized title(s) in other languages, e.g.
66    /// "Attack on Titan", "Ataque a los Titanes"
67    localized: Vec<(LanguageTag, String)>,
68    /// Commonly used shortened form(s) of the title, e.g. "AoT", "SnK"
69    abbreviated: Vec<String>,
70    /// Any other titles
71    other: Vec<String>,
72}
73
74#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
75pub enum AnimeType {
76    TV,
77    Movie,
78    OVA,
79    ONA,
80    Short,
81}
82
83#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
84pub enum Source {
85    Manga,
86    LightNovel,
87    VisualNovel,
88    Original,
89    Novel,
90    VideoGame,
91}
92
93#[derive(Debug, Serialize, Deserialize)]
94pub struct EntrySong {
95    episodes: Vec<u32>,
96    title: Arc<str>,
97    links: Vec<SongLink>,
98}
99
100#[derive(Debug, Serialize, Deserialize)]
101pub enum SongLink {
102    Spotify(String),
103    YouTube(String),
104    Tidal(String),
105    AppleMusic(String),
106    AmazonMusic(String),
107    BandCamp(String),
108    Other(String),
109}
110
111#[derive(Debug, Serialize, Deserialize)]
112pub enum Link {
113    PrimeVideo(String),
114    Netflix(String),
115    Crunchyroll(String),
116    OfficialSite(String),
117    Twitter(String),
118    YouTube(String),
119    BilibiliTV(String),
120    Funimation(String),
121    Hulu(String),
122    Max(String),
123    HiDive(String),
124    Wikipedia(String),
125    BookWalker(String),
126    CONtv(String),
127    DisneyPlus(String),
128    Instagram(String),
129    TikTok(String),
130    Other(String),
131}