pytwitcher.models.QtStream

class pytwitcher.models.QtStream(session, cache, game, channel, twitchid, viewers, preview)[source]

Bases: pytwitcherapi.models.Stream

A class for twitch.tv Stream.

Automatically loads pictures.

__init__(session, cache, game, channel, twitchid, viewers, preview)[source]

Initialize a new stream

Parameters:
  • session (pytwitcher.session.QtTwitchSession) – The session that is used for Twitch API requests
  • cache (pytwitcher.cache.PixmapLoader) – The picture cache to use
  • game (str) – name of the game
  • channel (Channel) – the channel that is streaming
  • twitchid (int) – the internal twitch id
  • viewers (int) – the viewer count
  • preview (dict) – a dict with preview picture links of the stream
Raises:

None

Methods

__init__(session, cache, game, channel, ...) Initialize a new stream
from_stream(session, cache, stream) Create a QtStream from a pytwitcherapi.models.Stream
get_preview(size) Get a pixmap of the box logo in the requested size
play([quality]) Play the stream in the specified quality
wrap_get_stream(response) Wrap the response from getting a stream into an instance
wrap_json(json) Create a Stream instance for the given json
wrap_search(response) Wrap the response from a stream search into instances

Attributes

quality_options Return a list with available quality options
classmethod from_stream(session, cache, stream)[source]

Create a QtStream from a pytwitcherapi.models.Stream

Parameters:
Returns:

a QtStream

Return type:

pytwitcher.models.QtStream

Raises:

None

session = None

The session that is used for Twitch API requests

cache = None

The picture cache to use

get_preview(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.
quality_options[source]

Return a list with available quality options

Possible values in the list:

  • source
  • high
  • medium
  • low
  • mobile
  • audio
Returns:a list with options
Return type:list of str
Raises:requests.HTTPError if channel is offline and you call it the first time
play(quality=None)[source]

Play the stream in the specified quality

If no quality is specified, the highest available is used.

Parameters:quality (str) – the quality. See QtStream.quality_options()
Returns:the subprocess running livestreamer
Return type:subprocess.POpen
Raises:None