coherence.backends.twitch_storage (module)

A backend to access twitch.tv streams.

To enable personalized features (e.g. ‘Following’ streams), add ‘access_token’ key into your config file:

  1. Click the link below to automatically request an access token for your account:

    Go twitch’s ‘get access token’ page

  2. After authorization you will be redirected to http://localhost with access token in fragment part, e.g:

    http://localhost/#access_token= <YOUR_ACCESS_TOKEN_IS_HERE> &scope=user_read

  3. Copy the token and paste in TwitchStore section of your config file:

    access_token = <YOUR_ACCESS_TOKEN (step 2)>

class LiveStreamerProxyResource(url, stream_id, content_type='video/mpeg')[source]

Bases: twisted.web.resource.Resource, coherence.log.LogAble

logCategory = 'twitch_store'
render_GET(request)[source]
class TwitchLazyContainer(parent, title, limit=None, **kwargs)[source]

Bases: coherence.backend.LazyContainer

logCategory = 'twitch_store'
result_handler(result, **kwargs)[source]
_retrieve_children(parent=None, **kwargs)[source]
_got_page(result)[source]
_got_error(error)[source]
class GamesContainer(parent, title='Games', description=None, limit=None, children_limit=None, **kwargs)[source]

Bases: coherence.backends.twitch_storage.TwitchLazyContainer

result_handler(result, **kwargs)[source]
class StreamsContainer(parent, title, viewers=0, channels=0, streams_url='%s/streams/', cover_url=None, **kwargs)[source]

Bases: coherence.backends.twitch_storage.TwitchLazyContainer

URL = '%s/streams/'
result_handler(result, **kwargs)[source]
class TwitchStreamItem(title, url, status=None, viewers=0, created_at=None, preview_url=None)[source]

Bases: coherence.backend.BackendItem

logCategory = 'twitch_store'
get_item()[source]

Called by the CDS and the MediaServer web.

Returns

  • an UPnP ContentDirectoryServer DIDLLite object

  • or a Deferred

get_id()[source]
get_url()[source]
replace_by(item)[source]
class TwitchStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'twitch_store'
implements = ['MediaServer']
wmc_mapping = {'16': 1000}
description = ('twitch.tv', 'twitch.tv', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'twitch.tv', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'access_token', 'text': 'OAuth Access Token:', 'type': 'string', 'default': '', 'help': 'access token to show personalized list of followed streams'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'default': 'twitch_tv', 'help': 'the unique (UPnP) identifier for this MediaServer', 'level': 'advance'}]
upnp_init()[source]

This method gets called after the device is fired, here all initializations of service related state variables should happen, as the services aren’t available before that point.

json_loads(data)[source]