<commit_before>import credentials
import requests

class Twitch():
    __api_base = "https://api.twitch.tv/kraken/{}"

    __headers = {
        "Accept": "application/vnd.twitchtv.v5+json",
        "Client-ID": credentials.twitch_client_id
    }

    @classmethod
    def __get(cls, path, *params):
        
        data = None

        url = Twitch.__api_base.format(path)

        try:
            if len(params) != 1 or params[0] == None:
                data = requests.get(url, headers = Twitch.__headers)
            else:
                data = requests.get(url, params = params[0], headers = Twitch.__headers)

            data.raise_for_status()
            data = data.json()
            return data

        except (HTTPError, ValueError) as e:
            print(e)
            return None

    @classmethod
    def __get_id(cls, channel_name):

        data = Twitch.__get("search/channels", {
            "query": channel_name,
            "limit": "1"
        })

        if data is not None:
            channels = data["channels"]
            if len(channels) == 0:
                print("Failed to get id for ", format(channel_name))
                return None

            else:
                id = channels[0]["_id"]
                return id

        else:
            return data # (None)
        
    @classmethod<commit_msg>Twitch: Use user-agent string, fix channel id error formatting<commit_after>import const
import credentials
import requests

class Twitch():
    __api_base = "https://api.twitch.tv/kraken/{}"

    __headers = {
        "Accept": "application/vnd.twitchtv.v5+json",
        "Client-ID": credentials.twitch_client_id,
        "User-Agent": const.user_agent
    }

    @classmethod
    def __get(cls, path, *params):

        data = None

        url = Twitch.__api_base.format(path)

        try:
            if len(params) != 1 or params[0] == None:
                data = requests.get(url, headers = Twitch.__headers)
            else:
                data = requests.get(url, params = params[0], headers = Twitch.__headers)

            data.raise_for_status()
            data = data.json()
            return data

        except (HTTPError, ValueError) as e:
            print(e)
            return None

    @classmethod
    def __get_id(cls, channel_name):

        data = Twitch.__get("search/channels", {
            "query": channel_name,
            "limit": "1"
        })

        if data is not None:
            channels = data["channels"]
            if len(channels) == 0:
                print("Failed to get id for {}".format(channel_name))
                return None

            else:
                id = channels[0]["_id"]
                return id

        else:
            return data # (None)
        
    @classmethod
{'fraction_non_alphanumeric': 0.10840787119856887, 'fraction_numerical': 0.005008944543828265, 'mean_word_length': 1.6130841121495327, 'pattern_counts': {'":': 9, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4567808', 'n_tokens_mistral': 813, 'n_tokens_neox': 774, 'n_words': 193}