Skip to content

Commit

Permalink
Merge pull request #62 from anxdpanic/dev
Browse files Browse the repository at this point in the history
2.0.6
  • Loading branch information
anxdpanic authored Mar 1, 2019
2 parents 38fde39 + b3b5b87 commit dd5ff25
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 12 deletions.
6 changes: 2 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.5" provider-name="A Talented Community">
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.6" provider-name="A Talented Community">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
<import addon="script.module.six" version="1.11.0"/>
Expand All @@ -9,9 +9,7 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<news>
[add] add frame rate and resolution to returned stream information
[upd] update usher parameters
[upd] use SPDX license identifiers
[add] add missing helix api endpoints
</news>
<assets>
<icon>icon.png</icon>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.0.6
[add] add missing helix api endpoints

2.0.5
[add] add frame rate and resolution to returned stream information
[upd] update usher parameters
Expand Down
7 changes: 5 additions & 2 deletions resources/lib/twitch/api/helix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
"""
Reference: https://dev.twitch.tv/docs/
Copyright (C) 2016-2018 script.module.python.twitch
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
SPDX-License-Identifier: GPL-3.0-only
See LICENSES/GPL-3.0-only for more information.
"""

__all__ = ['analytics', 'bits', 'clips', 'entitlements', 'games', 'streams', 'users', 'videos', 'webhooks']
__all__ = ['analytics', 'bits', 'clips', 'entitlements', 'games', 'streams',
'subscriptions', 'tags', 'users', 'videos', 'webhooks']

from . import analytics # NOQA
from . import bits # NOQA
from . import clips # NOQA
from . import entitlements # NOQA
from . import games # NOQA
from . import streams # NOQA
from . import subscriptions # NOQA
from . import tags # NOQA
from . import users # NOQA
from . import videos # NOQA
from . import webhooks # NOQA
27 changes: 25 additions & 2 deletions resources/lib/twitch/api/helix/entitlements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
"""
Reference: https://dev.twitch.tv/docs/api/reference
Copyright (C) 2016-2018 script.module.python.twitch
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
SPDX-License-Identifier: GPL-3.0-only
See LICENSES/GPL-3.0-only for more information.
"""

from ..parameters import EntitlementType
from ..parameters import EntitlementType, ItemCount
from ... import keys
from ... import methods
from ...queries import HelixQuery as Qry
from ...queries import query

Expand All @@ -25,3 +26,25 @@ def upload(manifest_id, entitlement_type=EntitlementType.BULK_DROPS_GRANT):
q.add_param(keys.TYPE, EntitlementType.validate(entitlement_type))

return q


# required scope: none
# requires app access token
@query
def get_code_status(code, user_id):
q = Qry('entitlements/codes', use_app_token=True, method=methods.GET)
q.add_param(keys.CODE, ItemCount(max_items=20).validate(code), list())
q.add_param(keys.USER_ID, user_id)

return q


# required scope: none
# requires app access token
@query
def redeem_code(code, user_id):
q = Qry('entitlements/codes', use_app_token=True, method=methods.POST)
q.add_param(keys.CODE, ItemCount(max_items=20).validate(code), list())
q.add_param(keys.USER_ID, user_id)

return q
26 changes: 25 additions & 1 deletion resources/lib/twitch/api/helix/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Reference: https://dev.twitch.tv/docs/api/reference
Copyright (C) 2016-2018 script.module.python.twitch
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
Expand All @@ -12,6 +12,7 @@

from ... import keys
from ...api.parameters import Cursor, Language, IntRange, ItemCount
from ... import methods
from ...queries import HelixQuery as Qry
from ...queries import query

Expand Down Expand Up @@ -58,3 +59,26 @@ def get_metadata(community_id=list(), game_id=list(), user_id=list(),
q.add_param(keys.LANGUAGE, Language.validate(language), '')

return q


# required scope: user:edit:broadcast
@query
def create_stream_marker(user_id, description=''):
q = Qry('streams/markers', use_app_token=False, method=methods.POST)
q.add_param(keys.USER_ID, user_id)
q.add_param(keys.DESCRIPTION, description, '')

return q


# required scope: user:read:broadcast
@query
def get_stream_markers(user_id, video_id, after='MA==', before='MA==', first=20):
q = Qry('streams/markers', use_app_token=False, method=methods.GET)
q.add_param(keys.USER_ID, user_id)
q.add_param(keys.VIDEO_ID, video_id)
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
q.add_param(keys.BEFORE, Cursor.validate(before), 'MA==')
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)

return q
35 changes: 35 additions & 0 deletions resources/lib/twitch/api/helix/subscriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- encoding: utf-8 -*-
"""
Reference: https://dev.twitch.tv/docs/api/reference
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
SPDX-License-Identifier: GPL-3.0-only
See LICENSES/GPL-3.0-only for more information.
"""

from ..parameters import ItemCount
from ... import keys, methods
from ...queries import HelixQuery as Qry
from ...queries import query


# required scope: channel:read:subscriptions
@query
def get_broadcaster_subscriptions(broadcaster_id):
q = Qry('subscriptions', use_app_token=False, method=methods.GET)
q.add_param(keys.BROADCASTER_ID, broadcaster_id)

return q


# required scope: channel:read:subscriptions
@query
def get_user_subscriptions(broadcaster_id, user_id):
q = Qry('subscriptions', use_app_token=False, method=methods.GET)
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
q.add_param(keys.USER_ID, ItemCount().validate(user_id), list())

return q
48 changes: 48 additions & 0 deletions resources/lib/twitch/api/helix/tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- encoding: utf-8 -*-
"""
Reference: https://dev.twitch.tv/docs/api/reference
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
SPDX-License-Identifier: GPL-3.0-only
See LICENSES/GPL-3.0-only for more information.
"""

from ..parameters import Cursor, IntRange, ItemCount
from ... import keys, methods
from ...queries import HelixQuery as Qry
from ...queries import query


# required scope: none
# requires app access token
@query
def get_all_stream_tags(tag_id, after='MA==', first=20):
q = Qry('tags/streams', use_app_token=True, method=methods.GET)
q.add_param(keys.TAG_ID, ItemCount().validate(tag_id), list())
q.add_param(keys.AFTER, Cursor.validate(after), 'MA==')
q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20)

return q


# required scope: none
# requires app access token
@query
def get_stream_tags(broadcaster_id):
q = Qry('streams/tags', use_app_token=True, method=methods.GET)
q.add_param(keys.BROADCASTER_ID, broadcaster_id)

return q


# required scope: user:edit:broadcast
@query
def replace_stream_tags(broadcaster_id, tag_ids=list()):
q = Qry('tags/streams', use_app_token=False, method=methods.PUT)
q.add_param(keys.BROADCASTER_ID, broadcaster_id)
q.add_param(keys.TAG_IDS, ItemCount().validate(tag_ids), list())

return q
4 changes: 2 additions & 2 deletions resources/lib/twitch/api/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
See LICENSES/GPL-3.0-only for more information.
"""

from six.moves import xrange
from six.moves import range

from base64 import b64decode

Expand Down Expand Up @@ -223,7 +223,7 @@ class IntRange(_Parameter):

@classmethod
def __init__(cls, first, last):
cls._valid = [i for i in xrange(first, last + 1)]
cls._valid = [i for i in range(first, last + 1)]


class ItemCount(object):
Expand Down
5 changes: 4 additions & 1 deletion resources/lib/twitch/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
string constants
Copyright (C) 2012-2016 python-twitch (https://github.com/ingwinlu/python-twitch)
Copyright (C) 2016-2018 script.module.python.twitch
Copyright (C) 2016-2019 script.module.python.twitch
This file is part of script.module.python.twitch
Expand All @@ -29,6 +29,7 @@
CHANNEL_FEED_ENABLED = 'channel_feed_enabled'
CHANNEL_ID = 'channel_id'
CLIP = 'clip'
CODE = 'code'
COLLECTION_ID = 'collection_id'
COMMENT_ID = 'comment_id'
COMMENTS = 'comments'
Expand Down Expand Up @@ -100,6 +101,8 @@
STATUS = 'status'
STREAM_TYPE = 'stream_type'
SUMMARY = 'summary'
TAG_ID = 'tag_id'
TAG_IDS = 'tag_ids'
TAG_LIST = 'tag_list'
TARGET_ID = 'target_id'
TEAM = 'team'
Expand Down

0 comments on commit dd5ff25

Please sign in to comment.