<commit_before>#!/usr/bin/env python3
import math
import random
import subprocess
import sys

NORMAL = 0
NIGHTCORE = 1
ANTICORE = 2
RANDOM = -1


def help_and_exit():
    print("Usage: %s [option...] song...")
    print("Options")
    print("  -h, --help                 Print this help message")
    print("  -n, --nightcore-only       Only play at 1.5x speed")
    print("  -a, --anticore-only        Only play at 2/3rds speed")
    print("  -s, --random-speeds        Randomly choose speeds between 0.5 and 1.8")
    print("  -p, --pitch-adjust         Adjust pitch when changing speed")
    print("      --min=[value]          Set the minimum speed when choosing randomly")
    print("      --max=[value]          Set the maximum speed")
    print("      --flags=[value]        Give mpv additional flags")
    exit(0)


def play(songs, options):
    song = random.choice(songs)
    mode = random.choice(options['modes'])

    if mode == NORMAL:
        speed = 1
    elif mode == NIGHTCORE:
        speed = 1.5
    elif mode == ANTICORE:
        speed = 0.67
    elif mode == RANDOM:
        speed = random.random() * (options['max_speed'] - options['min_speed']) + options['min_speed']

    flags = [
        "mpv",
        "--no-video",
        "--speed=%f" % speed,
    ]

    if not options['pitch_adjust']:
        flags.append("--audio-pitch-correction=no")

    if options['extra_flags']:
        flags += options['extra_flags']

    flags.append(song)
    subprocess.run(flags)


if __name__ == '__main__':
    songs = []
    options = {
            'modes': (NORMAL, NIGHTCORE, ANTICORE),
            'pitch_adjust': False,
            'extra_flags': [],
            'min_speed': 0.5,
            'max_speed': 1.8,
    }

    for arg in sys.argv[1:]:
        if arg in ('-h', '--help'):
            help_and_exit()
        elif arg in ('-n', '--nightcore-only'):
            options['modes'] = (NIGHTCORE,)
        elif arg in ('-a', '--anticore-only', '--vaporwave'):
            options['modes'] = (ANTICORE,)
        elif arg in ('-s', '--random-speeds'):
            options['modes'] = (RANDOM,)
        elif arg in ('-p', '--pitch-adjust'):
            options['pitch_adjust'] = True
        elif arg.startswith('--min='):<commit_msg>Use pre-Python 3.5 subprocess construct.<commit_after>#!/usr/bin/env python3
import math
import random
import subprocess
import sys

NORMAL = 0
NIGHTCORE = 1
ANTICORE = 2
RANDOM = -1

def help_and_exit():
    print("Usage: %s [option...] song...")
    print("Options")
    print("  -h, --help                 Print this help message")
    print("  -n, --nightcore-only       Only play at 1.5x speed")
    print("  -a, --anticore-only        Only play at 2/3rds speed")
    print("  -s, --random-speeds        Randomly choose speeds between 0.5 and 1.8")
    print("  -p, --pitch-adjust         Adjust pitch when changing speed")
    print("      --min=[value]          Set the minimum speed when choosing randomly")
    print("      --max=[value]          Set the maximum speed")
    print("      --flags=[value]        Give mpv additional flags")
    exit(0)

def play(songs, options):
    song = random.choice(songs)
    mode = random.choice(options['modes'])

    if mode == NORMAL:
        speed = 1
    elif mode == NIGHTCORE:
        speed = 1.5
    elif mode == ANTICORE:
        speed = 0.67
    elif mode == RANDOM:
        speed = random.random() * (options['max_speed'] - options['min_speed']) + options['min_speed']

    flags = [
        "mpv",
        "--no-video",
        "--speed=%f" % speed,
    ]

    if not options['pitch_adjust']:
        flags.append("--audio-pitch-correction=no")

    if options['extra_flags']:
        flags += options['extra_flags']

    flags.append(song)
    ret = subprocess.call(flags)
    if ret != 0:
        exit(1)

if __name__ == '__main__':
    songs = []
    options = {
            'modes': (NORMAL, NIGHTCORE, ANTICORE),
            'pitch_adjust': False,
            'extra_flags': [],
            'min_speed': 0.5,
            'max_speed': 1.8,
    }

    for arg in sys.argv[1:]:
        if arg in ('-h', '--help'):
            help_and_exit()
        elif arg in ('-n', '--nightcore-only'):
            options['modes'] = (NIGHTCORE,)
        elif arg in ('-a', '--anticore-only', '--vaporwave'):
            options['modes'] = (ANTICORE,)
        elif arg in ('-s', '--random-speeds'):
            options['modes'] = (RANDOM,)
        elif arg in ('-p', '--pitch-adjust'):
            options['pitch_adjust'] = True
        elif arg.startswith('--min='):
{'fraction_non_alphanumeric': 0.16177758318739055, 'fraction_numerical': 0.011821366024518389, 'mean_word_length': 1.974609375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3888629', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1442, 'n_words': 388}