Initial commit
This commit is contained in:
parent
5b76c12482
commit
61dd7242b1
|
@ -1,3 +1,7 @@
|
|||
# LoL-Twitch-Stream-Sniper
|
||||
|
||||
Ein Tool um automatisch herauszufinden, ob ein Gegner bei League of Legends auf Twitch streamt.
|
||||
Ein Tool um automatisch herauszufinden, ob ein Gegner bei League of Legends auf Twitch streamt.
|
||||
|
||||
Dieses Tool ist rein experimentell und soll nicht dazu genutzt werden einen unfairen Vorteil zu erlangen.
|
||||
|
||||
This tool is purely educational and should not be used to gain an unfair advantage.
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
riot_server = "XX"
|
||||
riot_api_key = "RGAPI-XX"
|
||||
twitch_clientid = "XX"
|
||||
twitch_clientsecret = "XX"
|
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/env python
|
||||
from pantheon import pantheon
|
||||
import asyncio
|
||||
import requests
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
import config as cfg
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Get streaming enemies in lol games')
|
||||
parser.add_argument('summonername', metavar='NAME', type=str, help='the name of the summoner')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def gettwitchaccesstoken(clientid, clientsecret):
|
||||
response = requests.post("https://id.twitch.tv/oauth2/token?client_id=%s&client_secret=%s&grant_type=client_credentials" % (clientid, clientsecret))
|
||||
if response.status_code == 200:
|
||||
return response.json()['access_token']
|
||||
else:
|
||||
raise Exception(response.message)
|
||||
|
||||
def getchannelsbyname(name, acess_token, clientid):
|
||||
channellist = []
|
||||
headers = {
|
||||
"Authorization": "Bearer " + access_token,
|
||||
"Client-Id": clientid
|
||||
}
|
||||
response = requests.get('https://api.twitch.tv/helix/search/channels?query=%s&first=10&live_only=true' % (name), headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
channels = response.json()['data']
|
||||
for channel in channels:
|
||||
if channel['display_name'].casefold() == name.casefold():
|
||||
channellist.append({'name': channel['display_name'], 'title': channel['title']})
|
||||
return channellist
|
||||
else:
|
||||
raise Exception(response.message)
|
||||
|
||||
def requestsLog(url, status, headers):
|
||||
print(url)
|
||||
print(status)
|
||||
print(headers)
|
||||
|
||||
panth = pantheon.Pantheon(cfg.riot_server, cfg.riot_api_key, errorHandling=True, requestsLoggingFunction=requestsLog, debug=True)
|
||||
|
||||
async def getSummonerId(name):
|
||||
try:
|
||||
data = await panth.getSummonerByName(name)
|
||||
return (data['id'],data['accountId'])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
async def getCurrentGame(accountId):
|
||||
try:
|
||||
data = await panth.getCurrentGame(accountId)
|
||||
return data
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
(summonerId, accountId) = loop.run_until_complete(getSummonerId(args.summonername))
|
||||
game = loop.run_until_complete(getCurrentGame(summonerId))
|
||||
if game == None:
|
||||
print('%s is currently not in a game' % (args.summonername))
|
||||
exit()
|
||||
players = game['participants']
|
||||
for player in players:
|
||||
if player['summonerName'] == args.summonername:
|
||||
team = player['teamId']
|
||||
playerlist = []
|
||||
for player in players:
|
||||
if player['teamId'] != team:
|
||||
playerlist.append(player['summonerName'])
|
||||
|
||||
pprint(playerlist)
|
||||
|
||||
access_token = gettwitchaccesstoken(cfg.twitch_clientid, cfg.twitch_clientsecret)
|
||||
channellist = []
|
||||
for player in playerlist:
|
||||
channellist.extend(getchannelsbyname(player, access_token, clientid))
|
||||
|
||||
print("Currently streaming enemies are (channelname, title):")
|
||||
for channel in channellist:
|
||||
print('%s - %s' % (channel['name'], channel['title']))
|
Loading…
Reference in New Issue