mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-13 06:34:45 -04:00
Update Qobuz interpreter url support
- Get artist ID directly from Qobuz interpreter url
This commit is contained in:
parent
12db8e001a
commit
c9e1c22ee1
1 changed files with 8 additions and 0 deletions
|
@ -6,6 +6,9 @@ from typing import Tuple
|
||||||
from streamrip.constants import AGENT
|
from streamrip.constants import AGENT
|
||||||
from streamrip.utils import gen_threadsafe_session
|
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<artistId>[0-9]+)"
|
||||||
|
)
|
||||||
interpreter_artist_regex = re.compile(r"getSimilarArtist\(\s*'(\w+)'")
|
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.
|
"""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"
|
: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
|
:type url: str
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
|
urlMatch = interpreter_artist_id_regex.search(url)
|
||||||
|
if urlMatch:
|
||||||
|
return urlMatch.group('artistId')
|
||||||
|
|
||||||
session = gen_threadsafe_session({"User-Agent": AGENT})
|
session = gen_threadsafe_session({"User-Agent": AGENT})
|
||||||
r = session.get(url)
|
r = session.get(url)
|
||||||
match = interpreter_artist_regex.search(r.text)
|
match = interpreter_artist_regex.search(r.text)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue