Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
from converter import JsonListItemConverter
from functools import wraps
from twitch import TwitchTV, TwitchVideoResolver, Keys, TwitchException
from xbmcswift2 import Plugin  # @UnresolvedImport
import urllib2, json, sys

ITEMS_PER_PAGE = 20
LINE_LENGTH = 60

PLUGIN = Plugin()
CONVERTER = JsonListItemConverter(PLUGIN, LINE_LENGTH)
TWITCHTV = TwitchTV(PLUGIN.log)


def managedTwitchExceptions(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except TwitchException as error:
            handleTwitchException(error)

    return wrapper


def handleTwitchException(exception):
    codeTranslations = {
        TwitchException.NO_STREAM_URL: 30023,
        TwitchException.STREAM_OFFLINE: 30021,
        TwitchException.HTTP_ERROR: 30020,
Ejemplo n.º 2
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
from converter import JsonListItemConverter
from functools import wraps
from twitch import TwitchTV, TwitchVideoResolver, Keys, TwitchException
from xbmcswift2 import Plugin  # @UnresolvedImport
import sys

ITEMS_PER_PAGE = 20
LINE_LENGTH = 60

PLUGIN = Plugin()
CONVERTER = JsonListItemConverter(PLUGIN, LINE_LENGTH)
TWITCHTV = TwitchTV()


def managedTwitchExceptions(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except TwitchException as error:
            handleTwitchException(error)

    return wrapper


def handleTwitchException(exception):
    codeTranslations = {
        TwitchException.NO_STREAM_URL: 32004,
        TwitchException.STREAM_OFFLINE: 32002,