From c9e1c22ee1d57c414b2f05720fb6d72be302451e Mon Sep 17 00:00:00 2001 From: DJDoubleD <34967020+DJDoubleD@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:33:56 +0200 Subject: [PATCH] Update Qobuz interpreter url support - Get artist ID directly from Qobuz interpreter url --- rip/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rip/utils.py b/rip/utils.py index dcf1a5f..c97b934 100644 --- a/rip/utils.py +++ b/rip/utils.py @@ -6,6 +6,9 @@ from typing import Tuple from streamrip.constants import AGENT from streamrip.utils import gen_threadsafe_session +interpreter_artist_id_regex = re.compile( + r"https?://www\.qobuz\.com/\w\w-\w\w/interpreter/[-\w]+/(?P[0-9]+)" +) interpreter_artist_regex = re.compile(r"getSimilarArtist\(\s*'(\w+)'") @@ -13,9 +16,14 @@ def extract_interpreter_url(url: str) -> str: """Extract artist ID from a Qobuz interpreter url. :param url: Urls of the form "https://www.qobuz.com/us-en/interpreter/{artist}/download-streaming-albums" + or "https://www.qobuz.com/us-en/interpreter/the-last-shadow-puppets/{artistId}}" :type url: str :rtype: str """ + urlMatch = interpreter_artist_id_regex.search(url) + if urlMatch: + return urlMatch.group('artistId') + session = gen_threadsafe_session({"User-Agent": AGENT}) r = session.get(url) match = interpreter_artist_regex.search(r.text)