1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
use crate::utils;
use crate::Other;
use strum::EnumProperty;
use strum_macros::{EnumIter, EnumProperty};

/// Group (as defined by [Podcast Taxonomy Project](https://podcasttaxonomy.com)) of [Person](crate::podcast::Person).
#[derive(Debug, PartialEq, Eq, EnumProperty, EnumIter)]
pub enum Group {
    #[strum(props(str = "creative direction"))]
    CreativeDirection,
    #[strum(props(str = "cast"))]
    Cast,
    #[strum(props(str = "writing"))]
    Writing,
    #[strum(props(str = "audio production"))]
    AudioProduction,
    #[strum(props(str = "audio post-production"))]
    AudioPostProduction,
    #[strum(props(str = "administration"))]
    Administration,
    #[strum(props(str = "visuals"))]
    Visuals,
    #[strum(props(str = "community"))]
    Community,
    #[strum(props(str = "misc"))]
    Misc,
    #[strum(props(str = "video production"))]
    VideoProduction,
    #[strum(props(str = "video post-production"))]
    VideoPostProduction,

    Other(Other),
}

impl std::str::FromStr for Group {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match utils::from_str_case_insensitive(s) {
            Some(variant) => Ok(variant),
            None => Ok(Self::Other((
                s.to_string(),
                "should be one of the groups defined at <https://podcasttaxonomy.com>".to_string(),
            ))),
        }
    }
}

impl std::fmt::Display for Group {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Other((s, _)) => write!(f, "{s}"),
            _ => match self.get_str("str") {
                Some(s) => write!(f, "{s}"),
                None => write!(f, "{self:?}"),
            },
        }
    }
}

impl Group {
    pub fn parse(s: &str) -> Self {
        match s.parse::<Self>() {
            Ok(group) => group,
            Err(e) => Self::Other((s.to_string(), e)),
        }
    }
}

/// Role (as defined by [Podcast Taxonomy Project](https://podcasttaxonomy.com/)) of [Person](crate::podcast::Person).
#[derive(Debug, PartialEq, Eq, EnumProperty, EnumIter)]
pub enum Role {
    #[strum(props(str = "director"))]
    Director,
    #[strum(props(str = "assistant director"))]
    AssistantDirector,
    #[strum(props(str = "executive producer"))]
    ExecutiveProducer,
    #[strum(props(str = "senior producer"))]
    SeniorProducer,
    #[strum(props(str = "producer"))]
    Producer,
    #[strum(props(str = "associate producer"))]
    AssociateProducer,
    #[strum(props(str = "development producer"))]
    DevelopmentProducer,
    #[strum(props(str = "creative director"))]
    CreativeDirector,
    #[strum(props(str = "host"))]
    Host,
    #[strum(props(str = "co-host"))]
    CoHost,
    #[strum(props(str = "guest host"))]
    GuestHost,
    #[strum(props(str = "guest"))]
    Guest,
    #[strum(props(str = "voice actor"))]
    VoiceActor,
    #[strum(props(str = "narrator"))]
    Narrator,
    #[strum(props(str = "announcer"))]
    Announcer,
    #[strum(props(str = "reporter"))]
    Reporter,
    #[strum(props(str = "author"))]
    Author,
    #[strum(props(str = "editorial director"))]
    EditorialDirector,
    #[strum(props(str = "co-writer"))]
    CoWriter,
    #[strum(props(str = "writer"))]
    Writer,
    #[strum(props(str = "songwriter"))]
    Songwriter,
    #[strum(props(str = "guest writer"))]
    GuestWriter,
    #[strum(props(str = "story editor"))]
    StoryEditor,
    #[strum(props(str = "managing editor"))]
    ManagingEditor,
    #[strum(props(str = "script editor"))]
    ScriptEditor,
    #[strum(props(str = "script coordinator"))]
    ScriptCoordinator,
    #[strum(props(str = "researcher"))]
    Researcher,
    #[strum(props(str = "editor"))]
    Editor,
    #[strum(props(str = "fact checker"))]
    FactChecker,
    #[strum(props(str = "translator"))]
    Translator,
    #[strum(props(str = "transcriber"))]
    Transcriber,
    #[strum(props(str = "logger"))]
    Logger,
    #[strum(props(str = "studio coordinator"))]
    StudioCoordinator,
    #[strum(props(str = "technical director"))]
    TechnicalDirector,
    #[strum(props(str = "technical manager"))]
    TechnicalManager,
    #[strum(props(str = "audio engineer"))]
    AudioEngineer,
    #[strum(props(str = "remote recording engineer"))]
    RemoteRecordingEngineer,
    #[strum(props(str = "post production engineer"))]
    PostProductionEngineer,
    #[strum(props(str = "audio editor"))]
    AudioEditor,
    #[strum(props(str = "sound designer"))]
    SoundDesigner,
    #[strum(props(str = "foley artist"))]
    FoleyArtist,
    #[strum(props(str = "composer"))]
    Composer,
    #[strum(props(str = "theme music"))]
    ThemeMusic,
    #[strum(props(str = "music production"))]
    MusicProduction,
    #[strum(props(str = "music contributor"))]
    MusicContributor,
    #[strum(props(str = "production coordinator"))]
    ProductionCoordinator,
    #[strum(props(str = "booking coordinator"))]
    BookingCoordinator,
    #[strum(props(str = "production assistant"))]
    ProductionAssistant,
    #[strum(props(str = "content manager"))]
    ContentManager,
    #[strum(props(str = "marketing manager"))]
    MarketingManager,
    #[strum(props(str = "sales representative"))]
    SalesRepresentative,
    #[strum(props(str = "sales manager"))]
    SalesManager,
    #[strum(props(str = "graphic designer"))]
    GraphicDesigner,
    #[strum(props(str = "cover art designer"))]
    CoverArtDesigner,
    #[strum(props(str = "social media manager"))]
    SocialMediaManager,
    #[strum(props(str = "consultant"))]
    Consultant,
    #[strum(props(str = "intern"))]
    Intern,
    #[strum(props(str = "camera operator"))]
    CameraOperator,
    #[strum(props(str = "lighting designer"))]
    LightingDesigner,
    #[strum(props(str = "camera grip"))]
    CameraGrip,
    #[strum(props(str = "assistant camera"))]
    AssistantCamera,
    #[strum(props(str = "assistant editor"))]
    AssistantEditor,

    Other(Other),
}

impl std::str::FromStr for Role {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match utils::from_str_case_insensitive(s) {
            Some(variant) => Ok(variant),
            None => Ok(Self::Other((
                s.to_string(),
                "should be one of the roles defined at <https://podcasttaxonomy.com>".to_string(),
            ))),
        }
    }
}

impl std::fmt::Display for Role {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Other((s, _)) => write!(f, "{s}"),
            _ => match self.get_str("str") {
                Some(s) => write!(f, "{s}"),
                None => write!(f, "{self:?}"),
            },
        }
    }
}

impl Role {
    pub fn parse(s: &str) -> Self {
        match s.parse::<Self>() {
            Ok(role) => role,
            Err(e) => Self::Other((s.to_string(), e)),
        }
    }
}