This commit is contained in:
louiscklaw
2025-01-31 20:05:06 +08:00
parent 2a6f19a43f
commit cd995ed8bd
115 changed files with 7626 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python
import os
import sys
import requests
import json
def getCompetitionsJson():
url = 'https://api.footylogic.com/tournament/competitions'
params = {
'languageId': '19',
'channelId': '1',
'categoryId': '1'
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://footylogic.com/',
'Origin': 'https://footylogic.com',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache'
}
response = requests.get(url, params=params, headers=headers)
response_json = json.loads(response.text)
# from pprint import pprint
# https://footylogic.com/en/tournament/league/{competitionId}/standings
expanded_json = response_json
for data in expanded_json['data']:
for competition in data['competitions']:
competitionId = str(competition['competitionId'])
competition['standing_table_link'] = 'https://footylogic.com/en/tournament/league/' + \
competitionId+'/standings'
with open("./competitions.json", 'w+') as f_out_json:
f_out_json.truncate(0)
json.dump(expanded_json['data'], f_out_json)
return expanded_json['data']
def lookupCompetitionId(competitions_json, competitionName):
for category in competitions_json:
for competition in category['competitions']:
if competition['competitionName'] == competitionName:
return competition['competitionId']
return 'not found'

View File

@@ -0,0 +1,57 @@
#!/usr/bin/env python
import os
import sys
import requests
import json
from pprint import pprint
USE_TEST_URL = int(os.getenv('USE_TEST_URL', False))
# https://api.footylogic.com/tournament/options?
# languageId=19
# &channelId=1
# &competitionId=50019599
# &seasonId=4456
def getOptionsJson(competition_id, season_id):
url = 'https://api.footylogic.com/tournament/options'
test_url = 'http://localhost:8081/tournament/options/options.json'
url = [url, test_url][USE_TEST_URL]
params = {
'languageId': '19',
'channelId': '1',
'competitionId': str(competition_id),
'optionId': '1',
'seasonId': str(season_id),
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://footylogic.com/',
'Origin': 'https://footylogic.com',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache'
}
response = requests.get(url, params=params, headers=headers)
response_json = json.loads(response.text)
response_json_data = response_json['data']
os_cwd = os.getcwd()
json_store_path = os_cwd+'/jsons'
with open(json_store_path+"/options.json", 'w+') as f_out_json:
f_out_json.truncate(0)
json.dump(response_json_data, f_out_json)
print('Options.py: get options done')
return response_json_data

View File

@@ -0,0 +1,69 @@
#!/usr/bin/env python
import os
import sys
import requests
import json
from pprint import pprint
USE_TEST_URL = int(os.getenv('USE_TEST_URL', False))
# https://api.footylogic.com/tournament/standings?
# languageId=19
# &channelId=1
# &competitionId=50016467
# &optionId=1
# &seasonId=4418
# &layoutId=1
# &roundId=13410
# &tabId=1
# &group=all
def getStandingsJson(competition_id, season_id, round_id):
url = 'https://api.footylogic.com/tournament/standings'
test_url = 'http://localhost:8081/tournament/standings/standings.json'
url = [url, test_url][USE_TEST_URL]
params = {
'languageId': '19',
'channelId': '1',
'competitionId': str(competition_id),
'optionId': '1',
'seasonId': str(season_id),
'layoutId': '1',
'roundId': str(round_id),
'tabId': '1',
'group': 'all',
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://footylogic.com/',
'Origin': 'https://footylogic.com',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache'
}
response = requests.get(url, params=params, headers=headers)
response_json = json.loads(response.text)
response_json_data = response_json['data']
os_cwd = os.getcwd()
json_store_path = os_cwd+'/jsons'
with open(json_store_path+"/standings.json", 'w+') as f_out_json:
f_out_json.truncate(0)
json.dump(response_json_data, f_out_json)
print('Standings.py: get standings done')
return response_json_data