dobecad / mal-rs

MyAnimeList API library written in Rust
https://docs.rs/mal-api/latest/mal_api/
MIT License
5 stars 0 forks source link

Issue w/ parsing light_novel MediaType #3

Closed demeil1 closed 4 months ago

demeil1 commented 4 months ago

When trying to obtain a list of the top 100 "manga" using MangaRankingType::All the api fails to parse the MangaList result.

Error:

Error: MangaApiError {
    message: "Failed to parse MangaList result: unknown variant `light_novel`, expected one of `unknown`, `manga`, `novel`, `oneshot`, `doujinshi`, `manhwa`, `manhua`, `oel` at line 1 column 10787",
}

Code:

    let query = GetMangaRanking::builder(MangaRankingType::All)
        .enable_nsfw()
        .fields(&common_fields)
        .limit(100)
        .build();
    let response = api_client.get_manga_ranking(&query).await;
    if let Err(ref response) = response {
        println!("Error: {:#?}", response)
    }
    if let Ok(response) = response {
        println!("Length: {:#?}", response.data.len());
    }
dobecad commented 4 months ago

Thank you for the issue!

This is just another one of the undocumented media types. I'll release a patch that includes this variant.

For context, I've only implemented the variants I could find from https://myanimelist.net/apiconfig/references/api/v2

dobecad commented 4 months ago

I included the variant in release v2.0.1

demeil1 commented 4 months ago

Manga with the status LightNovel now work with v2.0.1; however, manga with the status 'one_shot' and 'discontinued' don't. I believe this is the same issue as before for the discontinued type. On the other hand, Oneshot is already included but an error is still returned:

 message: "Failed to parse MangaList result: unknown variant `one_shot`, expected one of `unknown`, `manga`, `novel`, `oneshot`, `doujinshi`, `manhwa`, `manhua`, `oel`, `light_novel` at line 1 column 1138",

i think this is due to the snake_case and having to capatalize the s in OneShot

dobecad commented 3 months ago

Ah, gotcha. I'll push another patch with the fix