This commit is contained in:
Edgar P. Burkhart 2024-04-09 22:06:52 +02:00
parent 1c92be85d1
commit 295a44fbaa
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 7 additions and 12 deletions

View file

@ -1,11 +1,5 @@
import argparse import argparse
import itertools
import pathlib
import random
import re
from datetime import date, datetime
from pathlib import Path from pathlib import Path
from urllib import parse, request
from .list import generate_list, write_blacklist, write_results from .list import generate_list, write_blacklist, write_results
@ -38,7 +32,7 @@ parser.add_argument(
"--number", "--number",
type=int, type=int,
default=NUM_MUS, default=NUM_MUS,
help=f"Modifier le nombre de musiques par joueur", help="Modifier le nombre de musiques par joueur",
) )
parser.add_argument( parser.add_argument(
"--lists", "--lists",
@ -95,6 +89,6 @@ write_results(USERS, MUSIK, args.results)
# Écriture de la blacklist # Écriture de la blacklist
if not args.no_blacklist: if not args.no_blacklist:
print("> Écriture de la blacklist") print("> Écriture de la blacklist")
write_blacklist(args.blacklists) write_blacklist(USERS, MUSIK, args.blacklists)
print("--- FIN ---") print("--- FIN ---")

View file

@ -28,7 +28,7 @@ def generate_list(ROOT_PATH, NO_BLACKLIST, NUM_MUS, BLACKLIST):
(re.compile(r"[\?\&]v=(\w+)").search(_musik) or ("", _musik))[1] (re.compile(r"[\?\&]v=(\w+)").search(_musik) or ("", _musik))[1]
for _musik in f.read().splitlines() for _musik in f.read().splitlines()
] ]
_musiks = list(filter(lambda _m: not _m in blacklist, _raw_musiks)) _musiks = list(filter(lambda _m: _m not in blacklist, _raw_musiks))
assert ( assert (
len(_musiks) >= NUM_MUS len(_musiks) >= NUM_MUS
@ -45,7 +45,7 @@ def generate_list(ROOT_PATH, NO_BLACKLIST, NUM_MUS, BLACKLIST):
return zip(*UM) return zip(*UM)
def write_blacklist(BLACKLIST): def write_blacklist(USERS, MUSIK, BLACKLIST):
for user, musik in zip(USERS, MUSIK): for user, musik in zip(USERS, MUSIK):
with bl_path(BLACKLIST, user).open("a") as f: with bl_path(BLACKLIST, user).open("a") as f:
f.write("\n") f.write("\n")

View file

@ -29,7 +29,8 @@ def create_playlist(MUSIK):
) )
pl_response = pl_request.execute() pl_response = pl_request.execute()
print( print(
f"> > Playlist créée : https://www.youtube.com/playlist?list={pl_response['id']}" "> > Playlist créée :",
f"https://www.youtube.com/playlist?list={pl_response['id']}"
) )
# Insertion des musiques dans la playlist # Insertion des musiques dans la playlist
@ -51,5 +52,5 @@ def create_playlist(MUSIK):
} }
}, },
) )
response = request.execute() request.execute()
print() print()