feat: add basic interface and cleanup
This commit is contained in:
parent
573429acd2
commit
c8abb8943e
4 changed files with 211 additions and 53 deletions
|
@ -25,11 +25,15 @@ class DownloadService:
|
|||
def download(self, url: str) -> Track:
|
||||
info = self.ydl.extract_info(url, download=True)
|
||||
|
||||
try:
|
||||
filepath = info["requested_downloads"][-1]["filepath"] # type: ignore
|
||||
except KeyError:
|
||||
raise ValueError("Could not ")
|
||||
track = Track(
|
||||
artist=info["artists"][0], # type: ignore
|
||||
title=info["title"], # type: ignore
|
||||
duration=info["duration"], # type: ignore
|
||||
filepath=info["requested_downloads"][-1]["filepath"], # type: ignore
|
||||
artist=info.get("artist", None), # type: ignore
|
||||
title=info.get("title", None), # type: ignore
|
||||
duration=info.get("duration", None), # type: ignore
|
||||
filepath=filepath, # type: ignore
|
||||
)
|
||||
|
||||
print(f"Finished processing {track}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue