coherence.backends.twitch_storage (module) — Cohen3 0.8.0 documentation

# 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')

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

  `logCategory` = 'twitch_store'
  `render_GET`(request)

class `TwitchLazyContainer`(parent, title, limit=None, **kwargs)

  Bases: `coherence.backend.LazyContainer`

  `logCategory` = 'twitch_store'
  `result_handler`(result, **kwargs)
  `_retrieve_children`(parent=None, **kwargs)
  `_got_page`(result)
  `_got_error`(error)

class `GamesContainer`(parent, title='Games', description=None, limit=None, children_limit=None, **kwargs)

  Bases: `coherence.backends.twitch_storage.TwitchLazyContainer`

  `result_handler`(result, **kwargs)

class `StreamsContainer`(parent, title, viewers=0, channels=0, streams_url='%s/streams/', cover_url=None, **kwargs)

  Bases: `coherence.backends.twitch_storage.TwitchLazyContainer`

  `URL` = '%s/streams/'
  `result_handler`(result, **kwargs)

class `TwitchStreamItem`(title, url, status=None, viewers=0, created_at=None, preview_url=None)

  Bases: `coherence.backend.BackendItem`

  `logCategory` = 'twitch_store'
  `get_item`()

    Called by the CDS and the MediaServer web.

    Returns: | an UPnP ContentDirectoryServer DIDLLite object or a Deferred

  `get_id`()
  `get_url`()
  `replace_by`(item)

class `TwitchStore`(server, **kwargs)

  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`()

    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)