pytwitcher.models.QtGame

class pytwitcher.models.QtGame(session, cache, name, box, logo, twitchid, viewers=None, channels=None)[source]

Bases: pytwitcherapi.models.Game

A class for twitch.tv Games.

Automatically loads pictures and stores the topstreams.

__init__(session, cache, name, box, logo, twitchid, viewers=None, channels=None)[source]

Initialize a new game

Parameters:
  • session (pytwitcher.session.QtTwitchSession) – The session that is used for Twitch API requests
  • cache (pytwitcher.cache.PixmapLoader) – The picture cache to use
  • name (str) – The name of the game
  • box (dict) – Links for the box logos
  • logo (dict) – Links for the game logo
  • twitchid (int) – The id used by twitch
  • viewers (int) – The current amount of viewers
  • channels (int) – The current amount of channels
Raises:

None

Methods

__init__(session, cache, name, box, logo, ...) Initialize a new game
from_game(session, cache, game) Create a QtGame from a pytwitcherapi.models.Game
get_box(size) Get a pixmap of the box logo in the requested size
get_logo(size) Get a pixmap of the game logo in the requested size
top_streams([limit, force_refresh]) Get the top streams of this game
wrap_json(json[, viewers, channels]) Create a Game instance for the given json
wrap_search(response) Wrap the response from a game search into instances
wrap_topgames(response) Wrap the response from quering the top games into instances
classmethod from_game(session, cache, game)[source]

Create a QtGame from a pytwitcherapi.models.Game

Parameters:
Returns:

a QtGame

Return type:

pytwitcher.models.QtGame

Raises:

None

session = None

The session that is used for Twitch API requests

cache = None

The picture cache to use

get_box(size)[source]

Get a pixmap of the box logo in the requested size

Parameters:size (str) – The size of the pixmap. Available values are "large", "medium", "small".
Returns:the box logo
Return type:QtGui.QPixmap
Raises:KeyError if size is wrong.

Get a pixmap of the game logo in the requested size

Parameters:size (str) – The size of the pixmap. Available values are "large", "medium", "small".
Returns:the game logo
Return type:QtGui.QPixmap
Raises:KeyError if size is wrong.
top_streams(limit=25, force_refresh=False)[source]

Get the top streams of this game

Top streams are cached and loaded the first time you call this function. You can force a refresh of those streams. If the limit is smaller than the amount of stored streams, only the amount of limit is returned. If the limit is bigger than the amount ofstored streams, it will not trigger a refresh to load more streams!! You have to specify explicitly to refresh.

Parameters:
  • limit (int) – the maximum number of streams to return
  • force_refresh (bool) – If True, refresh all values.
Returns:

a list of top streams

Return type:

list of QtStream

Raises:

None