Fix URL parsing

This commit is contained in:
Edgar P. Burkhart 2024-04-10 13:44:49 +02:00
parent d739df71a4
commit 0f92053046
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -2,6 +2,7 @@ import logging
import random import random
import re import re
import sys import sys
from urllib.parse import urlparse, parse_qs
from datetime import datetime from datetime import datetime
logger = logging.getLogger("musik.list") logger = logging.getLogger("musik.list")
@ -28,7 +29,7 @@ def generate_list(args):
logger.debug("Lecture de la liste") logger.debug("Lecture de la liste")
with q.open() as f: with q.open() as f:
_raw_musiks = [ _raw_musiks = [
(re.compile(r"[\?\&]v=(\w+)").search(_musik) or ("", _musik))[1] parse_qs(urlparse(_musik).query).get("v", [None])[0] or _musik
for _musik in f.read().splitlines() for _musik in f.read().splitlines()
] ]
_musiks = list(set(filter(lambda _m: _m not in blacklist, _raw_musiks))) _musiks = list(set(filter(lambda _m: _m not in blacklist, _raw_musiks)))