Change downloaded number
This commit is contained in:
parent
a7f8e85647
commit
70fa2f1123
1 changed files with 11 additions and 6 deletions
|
@ -93,7 +93,9 @@ class Album:
|
|||
album.dest_path,
|
||||
f"{album.artist} - {album.title} - {tnr + 1:02d} {track['title']}.flac".replace(
|
||||
"/", "-"
|
||||
).replace("\\", "-"),
|
||||
).replace(
|
||||
"\\", "-"
|
||||
),
|
||||
),
|
||||
)
|
||||
for tnr, (tid, track) in enumerate(
|
||||
|
@ -190,17 +192,17 @@ class Qobuz:
|
|||
continue
|
||||
self.download_track(track)
|
||||
|
||||
def search_album(self, query: str) -> Album:
|
||||
def search_album(self, query: str, nr: int) -> Album:
|
||||
print(f'Searching for "{query}"')
|
||||
url = f"{self.api_base}/get-music"
|
||||
result = requests.get(url, params={"q": query, "offset": 0})
|
||||
if result.status_code == 200:
|
||||
first_album_id = result.json()["data"]["albums"]["items"][0]["id"]
|
||||
first_album_id = result.json()["data"]["albums"]["items"][nr - 1]["id"]
|
||||
return self.get_album(first_album_id)
|
||||
raise RuntimeError("No results")
|
||||
|
||||
def search_and_download(self, query: str) -> None:
|
||||
album = self.search_album(query)
|
||||
def search_and_download(self, query: str, nr: int) -> None:
|
||||
album = self.search_album(query, nr)
|
||||
self.download_album(album)
|
||||
|
||||
|
||||
|
@ -232,6 +234,9 @@ def main() -> None:
|
|||
default="album",
|
||||
help="Type of search to perform",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--nr", "-n", type=int, default=1, help="Number of albums to download"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--additional-releases",
|
||||
|
@ -253,7 +258,7 @@ def main() -> None:
|
|||
qb = Qobuz(api_base=base_url, quality=quality)
|
||||
match args.type:
|
||||
case "album":
|
||||
qb.search_and_download(query)
|
||||
qb.search_and_download(query, args.nr)
|
||||
case "discography":
|
||||
mb.set_useragent(
|
||||
"Qobuz-dl-remote",
|
||||
|
|
Loading…
Add table
Reference in a new issue