<commit_before>#!/usr/bin/env python3
import urllib.request
import urllib.parse
import subprocess

LIMIT = 20
CLIENT_ID='jzkbprff40iqj646a697cyrvl0zt2m6'
PLAYER = 'vlc'
GAMES = ['Music', 'Music%20%26%20Performing%20Arts']

while True:
    i = 0
    for game in GAMES:
        print(str(i) + ') ' + urllib.parse.unquote(game))
        i += 1

    choice = len(GAMES)
    while (choice >= len(GAMES)):
        try:
            choice = int(input('Choose a playlist\n'))
        except ValueError:
            pass
    print('\n')

    game = GAMES[choice]
    streams_url = 'https://api.twitch.tv/kraken/streams?limit='+str(LIMIT)+'&offset=0&game='+game
    req = urllib.request.Request(streams_url)
    req.add_header('Accept', 'application/vnd.twitchtv.v5+json')
    req.add_header('Client-ID', CLIENT_ID)
    html = None
    with urllib.request.urlopen(req) as response:
        html = response.read().decode('utf8')

    i = 0
    urls = []
    for line in html.split(','):
        if 'status' in line:
            status = line.split('"')[-2]
            status = ''.join(i for i in status if ord(i)<128) #filter non ascii characters
        if 'display_name' in line:
            name = line.split('"')[-2]
            name = ''.join(i for i in name if ord(i)<128) #filter non ascii characters
            print(str(i) + ') ' + name + ' : ' + status)
            i += 1
        if 'url' in line:
            url = line.split('"')[-2]
            urls.append(url)

    choice = LIMIT
    while (choice >= LIMIT):
        try:
            choice = int(input('Choose a stream\n'))
        except ValueError:
            pass

    cmd = ['livestreamer', '--http-header', 'Client-ID='+str(CLIENT_ID), urls[choice], 'audio,audio_only']
    if PLAYER != 'vlc':
        cmd.append('-p')
        cmd.append(PLAYER)

    subprocess.call(cmd, shell=False)
    print('\n\n\n')<commit_msg>Replace livestreamer with streamlink and skip ads<commit_after>#!/usr/bin/env python3
import urllib.request
import urllib.parse
import subprocess

LIMIT = 20
CLIENT_ID='jzkbprff40iqj646a697cyrvl0zt2m6'
PLAYER = 'vlc'
GAMES = ['Music', 'Music%20%26%20Performing%20Arts']

while True:
    i = 0
    for game in GAMES:
        print(str(i) + ') ' + urllib.parse.unquote(game))
        i += 1

    choice = len(GAMES)
    while (choice >= len(GAMES)):
        try:
            choice = int(input('Choose a playlist\n'))
        except ValueError:
            pass
    print('\n')

    game = GAMES[choice]
    streams_url = 'https://api.twitch.tv/kraken/streams?limit='+str(LIMIT)+'&offset=0&game='+game
    req = urllib.request.Request(streams_url)
    req.add_header('Accept', 'application/vnd.twitchtv.v5+json')
    req.add_header('Client-ID', CLIENT_ID)
    html = None
    with urllib.request.urlopen(req) as response:
        html = response.read().decode('utf8')

    i = 0
    urls = []
    for line in html.split(','):
        if 'status' in line:
            status = line.split('"')[-2]
            status = ''.join(i for i in status if ord(i)<128) #filter non ascii characters
        if 'display_name' in line:
            name = line.split('"')[-2]
            name = ''.join(i for i in name if ord(i)<128) #filter non ascii characters
            print(str(i) + ') ' + name + ' : ' + status)
            i += 1
        if 'url' in line:
            url = line.split('"')[-2]
            urls.append(url)

    choice = LIMIT
    while (choice >= LIMIT):
        try:
            choice = int(input('Choose a stream\n'))
        except ValueError:
            pass

    cmd = ['streamlink', '--http-header', 'Client-ID='+str(CLIENT_ID), urls[choice], 'audio,audio_only', '--twitch-disable-ads']
    if PLAYER != 'vlc':
        cmd.append('-p')
        cmd.append(PLAYER)

    subprocess.call(cmd, shell=False)
    print('\n\n\n')
{'fraction_non_alphanumeric': 0.15584075432163436, 'fraction_numerical': 0.01990570979570456, 'mean_word_length': 2.3617957746478875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '58277', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1323, 'n_words': 290}