Compare commits
2 commits
733c7767a3
...
295a44fbaa
Author | SHA1 | Date | |
---|---|---|---|
295a44fbaa | |||
1c92be85d1 |
3 changed files with 8 additions and 15 deletions
|
@ -1,16 +1,8 @@
|
||||||
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")
|
||||||
|
@ -40,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",
|
||||||
|
@ -97,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 ---")
|
||||||
|
|
|
@ -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: 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")
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue