use all flag to check drives

This commit is contained in:
mungai-njoroge 2023-11-14 12:54:28 +03:00
parent 5f1bb28f5d
commit 1d71ba856b
5 changed files with 26 additions and 8 deletions

View File

@ -68,14 +68,24 @@ def get_all_drives(is_win: bool = False):
"""
Returns a list of all the drives on a Windows machine.
"""
drives = psutil.disk_partitions()
drives = psutil.disk_partitions(all=True)
drives = [d.mountpoint for d in drives]
if is_win:
drives = [win_replace_slash(d) for d in drives]
else:
remove = ["/boot", "/boot/efi", "/tmp"]
drives = [d for d in drives if d not in remove]
remove = (
"/boot",
"/tmp",
"/snap",
"/var",
"/sys",
"/proc",
"/etc",
"/run",
"/dev",
)
drives = [d for d in drives if not d.startswith(remove)]
return drives
@ -94,8 +104,6 @@ def list_folders():
req_dir = "$root"
if req_dir == "$root":
# req_dir = settings.USER_HOME_DIR
# if is_win:
return {
"folders": [{"name": d, "path": d} for d in get_all_drives(is_win=is_win)]
}

View File

@ -40,7 +40,7 @@ class AlbumVersionEnum(Enum):
BONUS_EDITION = ("bonus",)
BONUS_TRACK = ("bonus track",)
ORIGINAL = ("original",)
ORIGINAL = ("original", "og")
INTL_VERSION = ("international",)
UK_VERSION = ("uk version",)
US_VERSION = ("us version",)

View File

@ -143,7 +143,11 @@ def get_extras(filepath: str, keys: list[str]):
"""
Get extra tags from an audio file.
"""
tags = TinyTag.get(filepath)
try:
tags = TinyTag.get(filepath)
except Exception:
return [""] * len(keys)
extras = tags.extra
return [extras.get(key, "").strip() for key in keys]

View File

@ -159,6 +159,8 @@ class Album:
"""
return self.title.strip().endswith(" EP")
# TODO: check against number of tracks
def check_is_single(self, tracks: list[Track]):
"""
Checks if the album is a single.

View File

@ -68,7 +68,11 @@ class LyricsProvider(LRCProvider):
t = str(int(time.time() * 1000))
query.append(("t", t))
url = self.ROOT_URL + action
try:
url = self.ROOT_URL + action
except TypeError:
return None
try:
response = self.session.get(url, params=query)