<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

import requests
import json
from bs4 import BeautifulSoup
import time
from datetime import datetime, timedelta
import gzip
from pytz import timezone


def get_sec(s):
  l = s.split(':')
  return int(l[0]) * 3600 + int(l[1]) * 60 + int(l[2])


def download(link):
  r = requests.get(link)
  print(link)
  return r.text


def download_stats(match_id, timestamp):
  uttz = timezone('UTC')
  vitz = timezone('Europe/Vienna')
  d = datetime.fromtimestamp( timestamp, tz = uttz ).replace(tzinfo = uttz).astimezone( vitz )
  link = "https://api.qlstats.net/api/jsons/" + str(d.year) + "-" + str(d.month).zfill(2) + "-" + str(d.day).zfill(2) + "/" + match_id + ".json"
  data = download(link)
  f = gzip.open(match_id + ".json.gz", 'wb')
  f.write( data.encode('utf-8') )<commit_msg>added path arg to download_stats<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

import requests
import json
from bs4 import BeautifulSoup
import time
from datetime import datetime, timedelta
import gzip
from pytz import timezone


def get_sec(s):
  l = s.split(':')
  return int(l[0]) * 3600 + int(l[1]) * 60 + int(l[2])


def download(link):
  r = requests.get(link)
  print(link)
  return r.text


def download_stats(match_id, timestamp, path = "./"):
  uttz = timezone('UTC')
  vitz = timezone('Europe/Vienna')
  d = datetime.fromtimestamp( timestamp, tz = uttz ).replace(tzinfo = uttz).astimezone( vitz )
  link = "https://api.qlstats.net/api/jsons/" + str(d.year) + "-" + str(d.month).zfill(2) + "-" + str(d.day).zfill(2) + "/" + match_id + ".json"
  data = download(link)
  f = gzip.open(path + match_id + ".json.gz", 'wb')
  f.write( data.encode('utf-8') )
{'fraction_non_alphanumeric': 0.1820826061663758, 'fraction_numerical': 0.017452006980802792, 'mean_word_length': 3.8587570621468927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5773929', 'n_tokens_mistral': 679, 'n_tokens_neox': 653, 'n_words': 150}