pauli2406 / xtream_code_client

MIT License
3 stars 3 forks source link

fix: Type Mismatch Issues with `vodCategories` and `vodItems` Functions #5

Closed fvdf closed 2 months ago

fvdf commented 4 months ago

Description I've encountered type mismatch issues with two functions: vodCategories() and vodItems(category: vodCategories.first). These seem related to how data types are handled in comparison to the API responses I receive from an Xtream API.

  1. vodCategories Type Mismatch When calling vodCategories(), I receive a TypeError indicating a mismatch between expected String and received int type for categoryId.

    Error Message:

    Error: TypeError: 583: type 'int' is not a subtype of type 'String'

    Relevant Code:

    /// The ID of the category.
    @JsonKey(name: 'category_id')
    String categoryId;

    API Response:

    {"category_id":583,"category_name":"NETFLIX","parent_id":0}

    The API clearly returns category_id as an int whereas the library expects a String.

  2. vodItems Type Mismatch and Missing Fields When using vodItems(category: vodCategories.first), I encounter an issue where the library expects certain types that don't match the API's responses, and it also seems to be missing handling for some fields (e.g., tmdb_id).

    Error Message:

    Error:  type 'String' is not a subtype of type '?num'

    API Response Example:

    {"num":2204,"name":"FR| XXX (2024)","stream_type":"movie","stream_id":7439,"stream_icon":"http://xxx.org:8080/images/movies/xxxx.jpg","rating":"4.7","rating5_based":0,"added":"1709822875","category_id":"5","container_extension":"mkv","direct_source":"","custom_sid":null,"tmdb_id":"10290"}

    Issues Identified:

    • rating is expected to be a double but comes as a String.
    • Missing handling for tmdb_id.

Expected Behavior The library should accurately parse the API's responses, accommodating for the actual data types returned by the API, including handling int where it expects String and vice versa, and it should not omit fields like tmdb_id.

Suggested Fixes

Environment

Conclusion Although I would be keen to help solve these issues directly, I must admit that my current technical abilities do not quite match the level needed for such tasks. I want to express my gratitude to the developer for their efforts in creating this library. Although it hasn't fully met my needs yet, I recognize the potential it has to significantly aid my projects with the right adjustments. I hope my feedback will be useful in further refining the library, and I look forward to any guidance or updates that might help address these issues. Thank you for considering my suggestions.

pauli2406 commented 2 months ago

Should be fixed by https://github.com/pauli2406/xtream_code_client/pull/10