Skip to content

Commit 9453544

Browse files
authored
Merge pull request #22 from anxdpanic/dev
add language parameter to clips, disable cert verify in python <2.7.9
2 parents af279df + 82f2438 commit 9453544

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta5" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta6" provider-name="A Talented Community">
33
<requires>
44
<import addon="xbmc.python" version="2.1.0"/>
55
<import addon="script.module.six" version="1.9.0"/>

resources/lib/twitch/api/v5/clips.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://dev.twitch.tv/docs/v5/reference/clips/
33

44
from twitch import keys
5-
from twitch.api.parameters import Boolean, ClipPeriod, Cursor
5+
from twitch.api.parameters import Boolean, ClipPeriod, Cursor, Language
66
from twitch.queries import V5Query as Qry
77
from twitch.queries import query
88

@@ -17,22 +17,25 @@ def by_slug(slug):
1717

1818
# required scope: None
1919
@query
20-
def get_top(channels=None, games=None, period=ClipPeriod.WEEK, trending=Boolean.FALSE, cursor='MA==', limit=10):
20+
def get_top(channels=None, games=None, period=ClipPeriod.WEEK, trending=Boolean.FALSE,
21+
language=Language.ALL, cursor='MA==', limit=10):
2122
q = Qry('clips/top')
2223
q.add_param(keys.CHANNEL, channels, None)
2324
q.add_param(keys.GAME, games, None)
2425
q.add_param(keys.PERIOD, ClipPeriod.validate(period), ClipPeriod.WEEK)
2526
q.add_param(keys.TRENDING, Boolean.validate(trending), Boolean.FALSE)
27+
q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL)
2628
q.add_param(keys.LIMIT, limit, 10)
2729
q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==')
2830
return q
2931

3032

3133
# required scope: user_read
3234
@query
33-
def get_followed(trending=Boolean.FALSE, cursor='MA==', limit=10):
35+
def get_followed(trending=Boolean.FALSE, language=Language.ALL, cursor='MA==', limit=10):
3436
q = Qry('clips/followed')
3537
q.add_param(keys.TRENDING, Boolean.validate(trending), Boolean.FALSE)
38+
q.add_param(keys.LANGUAGE, Language.validate(language), Language.ALL)
3639
q.add_param(keys.LIMIT, limit, 10)
3740
q.add_param(keys.CURSOR, Cursor.validate(cursor), 'MA==')
3841
return q

resources/lib/twitch/scraper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- encoding: utf-8 -*-
2+
import sys
23
import requests
34
# import six
45
from six.moves.urllib.error import URLError
@@ -15,6 +16,10 @@
1516
except:
1617
import simplejson as json # @UnresolvedImport
1718

19+
SSL_VERIFICATION = True
20+
if sys.version_info <= (2, 7, 9):
21+
SSL_VERIFICATION = False
22+
1823
MAX_RETRIES = 5
1924

2025

@@ -51,7 +56,7 @@ def download(baseurl, parameters={}, headers={}, data={}, method=methods.GET):
5156
for _ in range(MAX_RETRIES):
5257
try:
5358
headers.update({USER_AGENT: USER_AGENT_STRING})
54-
response = requests.request(method=method, url=url, headers=headers, data=data)
59+
response = requests.request(method=method, url=url, headers=headers, data=data, verify=SSL_VERIFICATION)
5560
content = response.content
5661
if not content:
5762
content = '{"status": %d}' % response.status_code

0 commit comments

Comments
 (0)