Skip to content

Commit

Permalink
Misc fixes/optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
nathom committed Aug 13, 2021
1 parent 246d69c commit 6cfd068
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion rip/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class DownloadCommand(Command):

def handle(self):
global outdated
global newest_version

# Use a thread so that it doesn't slow down startup
update_check = threading.Thread(target=is_outdated, daemon=True)
Expand Down Expand Up @@ -102,7 +103,7 @@ def handle(self):
)

md_header = re.compile(r"#\s+(.+)")
bullet_point = re.compile(r"-\s*(.+)")
bullet_point = re.compile(r"-\s+(.+)")
code = re.compile(r"`([^`]+)`")
issue_reference = re.compile(r"(#\d+)")

Expand Down
4 changes: 2 additions & 2 deletions rip/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def parse_urls(self, url: str) -> List[Tuple[str, str, str]]:
for item, url in zip(soundcloud_items, soundcloud_urls)
)

logger.debug(f"Parsed urls: {parsed}")
logger.debug("Parsed urls: %s", parsed)

return parsed

Expand Down Expand Up @@ -501,7 +501,7 @@ def handle_lastfm_urls(self, urls: str):
# This will match somthing like "Test (Person Remix]" though, so its not perfect
banned_words_plain = re.compile(r"(?i)(?:(?:re)?mix|live|karaoke)")
banned_words = re.compile(
rf"(?i)[\(\[][^\)\]]*?(?:(?:re)?mix|live|karaoke)[^\)\]]*[\]\)]"
r"(?i)[\(\[][^\)\]]*?(?:(?:re)?mix|live|karaoke)[^\)\]]*[\]\)]"
)

def search_query(title, artist, playlist) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion rip/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create(self):
)
command = f"CREATE TABLE {self.name} ({params})"

logger.debug(f"executing {command}")
logger.debug("executing %s", command)

conn.execute(command)

Expand Down
2 changes: 1 addition & 1 deletion streamrip/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def get_file_url(meta_id: Union[str, int], quality: int = 2):
"""
quality = min(DeezloaderClient.max_quality, quality)
url = f"{DEEZER_DL}/{get_quality(quality, 'deezloader')}/{DEEZER_BASE}/track/{meta_id}"
logger.debug(f"Download url {url}")
logger.debug("Download url %s", url)
return {"url": url}


Expand Down
12 changes: 6 additions & 6 deletions streamrip/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def _progress_desc(self) -> str:
def download_cover(self, width=999999, height=999999):
"""Download the cover art, if cover_url is given."""
self.cover_path = os.path.join(gettempdir(), f"cover{hash(self.cover_url)}.jpg")
logger.debug(f"Downloading cover from {self.cover_url}")
logger.debug("Downloading cover from %s", self.cover_url)

if not os.path.exists(self.cover_path):
_cover_download(self.cover_url, self.cover_path)
Expand Down Expand Up @@ -1193,7 +1193,7 @@ def convert(self, codec="ALAC", **kwargs):
kwargs["sampling_rate"],
)
else:
logger.debug(f"Downsampling to {sr/1000}kHz")
logger.debug("Downsampling to %skHz", sr / 1000)

for track in self:
track.convert(codec, **kwargs)
Expand Down Expand Up @@ -1430,7 +1430,7 @@ def _prepare_download(self, **kwargs):
# choose optimal cover size and download it
cover_path = os.path.join(gettempdir(), f"cover_{hash(self)}.jpg")
embed_cover_size = kwargs.get("embed_cover_size", "large")
secho(f"Downloading {embed_cover_size} cover art", bold=True)
secho(f"Downloading cover art ({embed_cover_size})", bold=True)

assert (
embed_cover_size in self.cover_urls
Expand Down Expand Up @@ -1775,7 +1775,7 @@ def meta_args(track):
)
)

logger.debug(f"Loaded {len(self)} tracks from playlist {self.name}")
logger.debug("Loaded %d tracks from playlist %s", len(self), self.name)

def _prepare_download(self, parent_folder: str = "StreamripDownloads", **kwargs):
if kwargs.get("folder_format"):
Expand Down Expand Up @@ -1978,8 +1978,8 @@ def _prepare_download(
self.folder = parent_folder

logger.debug("Artist folder: %s", folder)
logger.debug(f"Length of tracklist {len(self)}")
logger.debug(f"Filters: {filters}")
logger.debug("Length of tracklist %d", len(self))
logger.debug("Filters: %s", filters)

final: Iterable
if "repeats" in filters:
Expand Down

0 comments on commit 6cfd068

Please sign in to comment.