mirror of
https://github.com/nathom/streamrip.git
synced 2025-06-02 00:08:24 -04:00
Misc bug fixes
Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
parent
e77182ae6a
commit
835c8d4cc6
5 changed files with 44 additions and 16 deletions
23
rip/cli.py
23
rip/cli.py
|
@ -356,6 +356,19 @@ def config(ctx, **kwargs):
|
||||||
@click.argument("PATH")
|
@click.argument("PATH")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def convert(ctx, **kwargs):
|
def convert(ctx, **kwargs):
|
||||||
|
"""Batch convert audio files.
|
||||||
|
|
||||||
|
This is a tool that is included with the `rip` program that assists with
|
||||||
|
converting audio files. This is essentially a wrapper over ffmpeg
|
||||||
|
that is designed to be easy to use with sensible default options.
|
||||||
|
|
||||||
|
Examples (assuming /my/music is filled with FLAC files):
|
||||||
|
|
||||||
|
$ rip convert MP3 /my/music
|
||||||
|
|
||||||
|
$ rip convert ALAC --sampling-rate 48000 /my/music
|
||||||
|
|
||||||
|
"""
|
||||||
from streamrip import converter
|
from streamrip import converter
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
@ -425,7 +438,15 @@ def convert(ctx, **kwargs):
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def repair(ctx, **kwargs):
|
def repair(ctx, **kwargs):
|
||||||
core.repair()
|
"""Retry failed downloads.
|
||||||
|
|
||||||
|
If the failed downloads database is enabled in the config file (it is by default),
|
||||||
|
when an item is not available for download, it is logged in the database.
|
||||||
|
|
||||||
|
When this command is called, it tries to download those items again. This is useful
|
||||||
|
for times when a temporary server error may miss a few tracks in an album.
|
||||||
|
"""
|
||||||
|
core.repair(max_items=kwargs.get("num_items"))
|
||||||
|
|
||||||
|
|
||||||
def none_chosen():
|
def none_chosen():
|
||||||
|
|
15
rip/core.py
15
rip/core.py
|
@ -230,16 +230,19 @@ class MusicDL(list):
|
||||||
"max_artwork_height": int(artwork["max_height"]),
|
"max_artwork_height": int(artwork["max_height"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
def repair(self, max_items=float("inf")):
|
def repair(self, max_items=None):
|
||||||
print(list(self.failed_db))
|
if max_items is None:
|
||||||
|
max_items = float("inf")
|
||||||
|
|
||||||
if self.failed_db.is_dummy:
|
if self.failed_db.is_dummy:
|
||||||
click.secho(
|
click.secho(
|
||||||
"Failed downloads database must be enabled to repair!", fg="red"
|
"Failed downloads database must be enabled in the config file "
|
||||||
|
"to repair!",
|
||||||
|
fg="red",
|
||||||
)
|
)
|
||||||
exit(1)
|
raise click.Abort
|
||||||
|
|
||||||
for counter, (source, media_type, item_id) in enumerate(self.failed_db):
|
for counter, (source, media_type, item_id) in enumerate(self.failed_db):
|
||||||
# print(f"handling item {source = } {media_type = } {item_id = }")
|
|
||||||
if counter >= max_items:
|
if counter >= max_items:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -293,13 +296,11 @@ class MusicDL(list):
|
||||||
try:
|
try:
|
||||||
item.download(**arguments)
|
item.download(**arguments)
|
||||||
except NonStreamable as e:
|
except NonStreamable as e:
|
||||||
print("caught in core")
|
|
||||||
e.print(item)
|
e.print(item)
|
||||||
self.failed_db.add((item.client.source, item.type, item.id))
|
self.failed_db.add((item.client.source, item.type, item.id))
|
||||||
continue
|
continue
|
||||||
except PartialFailure as e:
|
except PartialFailure as e:
|
||||||
for failed_item in e.failed_items:
|
for failed_item in e.failed_items:
|
||||||
print(f"adding {failed_item} to database")
|
|
||||||
self.failed_db.add(failed_item)
|
self.failed_db.add(failed_item)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,16 @@ class NonStreamable(Exception):
|
||||||
super().__init__(self.message)
|
super().__init__(self.message)
|
||||||
|
|
||||||
def print(self, item):
|
def print(self, item):
|
||||||
|
print(self.print_msg(item))
|
||||||
|
|
||||||
|
def print_msg(self, item) -> str:
|
||||||
|
base_msg = click.style(f"Unable to stream {item!s}.", fg="yellow")
|
||||||
if self.message:
|
if self.message:
|
||||||
click.secho(f"Unable to stream {item!s}. Message: ", nl=False, fg="yellow")
|
base_msg += click.style(" Message: ", fg="yellow") + click.style(
|
||||||
click.secho(self.message, fg="red")
|
self.message, fg="red"
|
||||||
else:
|
)
|
||||||
click.secho(f"Unable to stream {item!s}.", fg="yellow")
|
|
||||||
|
return base_msg
|
||||||
|
|
||||||
|
|
||||||
class InvalidContainerError(Exception):
|
class InvalidContainerError(Exception):
|
||||||
|
|
|
@ -230,6 +230,7 @@ class Track(Media):
|
||||||
:param progress_bar: turn on/off progress bar
|
:param progress_bar: turn on/off progress bar
|
||||||
:type progress_bar: bool
|
:type progress_bar: bool
|
||||||
"""
|
"""
|
||||||
|
# raise NonStreamable
|
||||||
self._prepare_download(
|
self._prepare_download(
|
||||||
quality=quality,
|
quality=quality,
|
||||||
parent_folder=parent_folder,
|
parent_folder=parent_folder,
|
||||||
|
@ -976,16 +977,16 @@ class Tracklist(list):
|
||||||
for future in future_map.keys():
|
for future in future_map.keys():
|
||||||
try:
|
try:
|
||||||
future.result()
|
future.result()
|
||||||
except NonStreamable:
|
except NonStreamable as e:
|
||||||
print("caught in media conc")
|
|
||||||
item = future_map[future]
|
item = future_map[future]
|
||||||
|
e.print(item)
|
||||||
failed_downloads.append(
|
failed_downloads.append(
|
||||||
(item.client.source, item.type, item.id)
|
(item.client.source, item.type, item.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except (KeyboardInterrupt, SystemExit):
|
||||||
executor.shutdown()
|
executor.shutdown()
|
||||||
tqdm.write("Aborted! May take some time to shutdown.")
|
click.echo("Aborted! May take some time to shutdown.")
|
||||||
raise click.Abort
|
raise click.Abort
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -44,7 +44,7 @@ def download_albums():
|
||||||
procs.append(subprocess.run([*rip_url, url]))
|
procs.append(subprocess.run([*rip_url, url]))
|
||||||
|
|
||||||
for p in procs:
|
for p in procs:
|
||||||
print(p)
|
click.echo(p)
|
||||||
|
|
||||||
|
|
||||||
def check_album_dl_success(folder, correct):
|
def check_album_dl_success(folder, correct):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue