Teekeks / pyTwitchAPI

A Python 3.7 compatible implementation of the Twitch API, EventSub, PubSub and Chat
https://pytwitchapi.dev
MIT License
254 stars 38 forks source link

Missing/differing fields from API in SearchChannelResult and ChannelInformation #309

Closed mxywes closed 3 months ago

mxywes commented 4 months ago

It seems some fields are not returned from the upstream API despite being included in the response body of the search channels endpoint : https://dev.twitch.tv/docs/api/reference/#search-channels The code from ‎Twitch.search_channels‎ (in twitch.py) is returning a SearchChannelResult which is subclass of ChannelInformation.

However according to Twitch API docs the response bodies of these 2 endpoints are not exactly the same:

Get Channel Information (get_channel_information in twitch.py)

broadcaster_id    String  An ID that uniquely identifies the broadcaster.
broadcaster_name  String  The broadcaster’s display name.

Search Channels (search_channels in twitch.py)

id    String  An ID that uniquely identifies the channel (this is the broadcaster’s ID).
display_name  String  The broadcaster’s display name.
thumbnail_url     String  A URL to a thumbnail of the broadcaster’s profile image.

So maybe we should have:

class ChannelInformation(TwitchObject):
    broadcaster_id: str
    broadcaster_name: str
   ...

class SearchChannelResult(ChannelInformation):
    id: str
    display_name: str
    thumbnail_url: str
   ...

Instead of the current SearchChannelResult which only return a subset of the fields it could because of variable naming differences. The current class for reference:

class SearchChannelResult(ChannelInformation):
    is_live: bool
    tags_ids: List[str]
    started_at: datetime

If needed maybe I can provide a fix? I didn't see any contributing guidelines anywhere on the repository, or if pull requests are welcome here.

Teekeks commented 4 months ago

PR's are welcome here (ideally: sign your commits), I really should add contributing guidelines.