1
1
use crate :: common:: Request ;
2
2
use crate :: crunchyroll:: Executor ;
3
+ use crate :: media:: anime:: util:: { fix_empty_episode_versions, fix_empty_season_versions} ;
3
4
use crate :: media:: util:: request_media;
4
5
use crate :: media:: Media ;
5
6
use crate :: { Crunchyroll , Episode , Locale , Result , Series } ;
@@ -21,7 +22,7 @@ pub struct SeasonVersion {
21
22
pub original : bool ,
22
23
23
24
#[ cfg( feature = "__test_strict" ) ]
24
- variant : crate :: StrictValue ,
25
+ pub ( crate ) variant : crate :: StrictValue ,
25
26
}
26
27
27
28
impl SeasonVersion {
@@ -92,6 +93,7 @@ pub struct Season {
92
93
pub availability_notes : String ,
93
94
94
95
/// All versions of this season (same season but each entry has a different language).
96
+ #[ serde( deserialize_with = "crate::internal::serde::deserialize_maybe_null_to_default" ) ]
95
97
pub versions : Vec < SeasonVersion > ,
96
98
97
99
#[ cfg( feature = "__test_strict" ) ]
@@ -125,7 +127,11 @@ impl Season {
125
127
"https://www.crunchyroll.com/content/v2/cms/seasons/{}/episodes" ,
126
128
self . id
127
129
) ;
128
- request_media ( self . executor . clone ( ) , endpoint) . await
130
+ let mut episodes: Vec < Episode > = request_media ( self . executor . clone ( ) , endpoint) . await ?;
131
+ for episode in & mut episodes {
132
+ fix_empty_episode_versions ( episode) ;
133
+ }
134
+ Ok ( episodes)
129
135
}
130
136
131
137
/// Show in which audios this [`Season`] is also available.
@@ -164,15 +170,17 @@ impl Season {
164
170
#[ async_trait:: async_trait]
165
171
impl Media for Season {
166
172
async fn from_id ( crunchyroll : & Crunchyroll , id : impl AsRef < str > + Send ) -> Result < Self > {
167
- Ok ( request_media (
173
+ let mut season : Season = request_media (
168
174
crunchyroll. executor . clone ( ) ,
169
175
format ! (
170
176
"https://www.crunchyroll.com/content/v2/cms/seasons/{}" ,
171
177
id. as_ref( )
172
178
) ,
173
179
)
174
180
. await ?
175
- . remove ( 0 ) )
181
+ . remove ( 0 ) ;
182
+ fix_empty_season_versions ( & mut season) ;
183
+ Ok ( season)
176
184
}
177
185
178
186
async fn __set_executor ( & mut self , executor : Arc < Executor > ) {
0 commit comments