@@ -2,11 +2,17 @@ use crate::util::make_string_fs_safe;
22
33use chrono:: { Datelike , TimeZone , Utc } ;
44use serde:: { self , Deserialize } ;
5- use serde_aux:: prelude:: deserialize_string_from_number;
65use std:: { collections:: HashMap , path:: Path } ;
76
87const FORMAT : & str = "%d %b %Y %T %Z" ;
98
9+ #[ derive( Clone , Deserialize , Debug ) ]
10+ #[ serde( untagged) ]
11+ pub enum ArtId {
12+ Str ( String ) ,
13+ Num ( i64 ) ,
14+ }
15+
1016#[ derive( Clone , Deserialize , Debug ) ]
1117pub struct DigitalItem {
1218 pub downloads : HashMap < String , DigitalItemDownload > ,
@@ -16,23 +22,22 @@ pub struct DigitalItem {
1622 pub download_type : Option < String > ,
1723 pub download_type_str : String ,
1824 pub item_type : String ,
19- #[ serde( deserialize_with = "deserialize_string_from_number" ) ]
20- pub art_id : String ,
25+ pub art_id : Option < ArtId > ,
2126}
2227
2328#[ derive( Clone , Deserialize , Debug ) ]
2429pub struct DigitalItemDownload {
25- pub size_mb : String ,
30+ // pub size_mb: Option< String> ,
2631 pub description : String ,
2732 pub encoding_name : String , // Download is chosen by comparing this field and the `format` option.
2833 pub url : String ,
2934}
3035
3136impl DigitalItem {
32- pub fn cover_url ( & self ) -> String {
33- let art_id = & self . art_id ;
34- format ! ( "https://f4.bcbits.com/img/a{art_id}" )
35- }
37+ // pub fn cover_url(&self) -> String {
38+ // let art_id = &self.art_id;
39+ // format!("https://f4.bcbits.com/img/a{art_id}")
40+ // }
3641
3742 pub fn is_single ( & self ) -> bool {
3843 ( self . download_type . is_some ( ) && self . download_type . as_ref ( ) . unwrap ( ) == "t" )
0 commit comments