Compare commits

..

No commits in common. "295a44fbaa7619cd15a5b82705b10ef5f4f48359" and "733c7767a3a4c65ad9f8ddff3128ac4a67195da1" have entirely different histories.

3 changed files with 15 additions and 8 deletions

View file

@ -1,8 +1,16 @@
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
ROOT_PATH = Path("./lists") ROOT_PATH = Path("./lists")
BLACKLIST = Path("./blacklists") BLACKLIST = Path("./blacklists")
RESULTS = Path("./results") RESULTS = Path("./results")
@ -32,7 +40,7 @@ parser.add_argument(
"--number", "--number",
type=int, type=int,
default=NUM_MUS, default=NUM_MUS,
help="Modifier le nombre de musiques par joueur", help=f"Modifier le nombre de musiques par joueur",
) )
parser.add_argument( parser.add_argument(
"--lists", "--lists",
@ -89,6 +97,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(USERS, MUSIK, args.blacklists) write_blacklist(args.blacklists)
print("--- FIN ---") print("--- FIN ---")

View file

@ -1,6 +1,6 @@
from datetime import datetime
import random import random
import re import re
from datetime import datetime
def bl_path(BLACKLIST, user): def bl_path(BLACKLIST, user):
@ -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: _m not in blacklist, _raw_musiks)) _musiks = list(filter(lambda _m: not _m 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(USERS, MUSIK, BLACKLIST): def write_blacklist(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,8 +29,7 @@ def create_playlist(MUSIK):
) )
pl_response = pl_request.execute() pl_response = pl_request.execute()
print( print(
"> > Playlist créée :", f"> > Playlist créée : https://www.youtube.com/playlist?list={pl_response['id']}"
f"https://www.youtube.com/playlist?list={pl_response['id']}"
) )
# Insertion des musiques dans la playlist # Insertion des musiques dans la playlist
@ -52,5 +51,5 @@ def create_playlist(MUSIK):
} }
}, },
) )
request.execute() response = request.execute()
print() print()