Skip to content
Snippets Groups Projects
Commit 3edae900 authored by TheJoKlLa's avatar TheJoKlLa
Browse files

Added more complete songs

parent e3dffea7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -15,8 +15,9 @@ SESSION = "ies6q9otiqktbo1ohc0d1nfhn3"
@click.option("--force-build", is_flag=True, default=False)
@click.option("--force-download", is_flag=True, default=False)
@click.option("--only-complete", is_flag=True, default=False)
@click.option("--only-not-complete", is_flag=True, default=False)
@click.option("--skip-not-buildable", is_flag=True, default=False)
def main(action, debug, db, cache, out, session, force_build, force_download, only_complete, skip_not_buildable):
def main(action, debug, db, cache, out, session, force_build, force_download, only_complete, only_not_complete, skip_not_buildable):
""" ACTION: check|download|build|all """
#DEBUG
#force_build = True
......@@ -27,15 +28,15 @@ def main(action, debug, db, cache, out, session, force_build, force_download, on
usdb = USDB(db = db, cache=cache, out=out, session=session, force_build=force_build, force_download=force_download, skip_not_buildable=skip_not_buildable)
if action == "check":
usdb.check(only_complete)
usdb.check(only_complete=only_complete, only_not_complete=only_not_complete)
elif action == "download":
usdb.download(only_complete)
usdb.download(only_complete=only_complete, only_not_complete=only_not_complete)
elif action == "build":
usdb.build(only_complete)
usdb.build(only_complete=only_complete, only_not_complete=only_not_complete)
else:
usdb.check(only_complete)
usdb.download(only_complete)
usdb.build(only_complete)
usdb.check(only_complete=only_complete, only_not_complete=only_not_complete)
usdb.download(only_complete=only_complete, only_not_complete=only_not_complete)
usdb.build(only_complete=only_complete, only_not_complete=only_not_complete)
def setup_log(debug):
if debug:
......
......@@ -44,19 +44,19 @@ class TXTDownloader:
txt.artist = song.artist_name
txt.title = song.track_name
if not(type(song.gap) == float and str(song.gap) == "nan"):
if song.gap != None:
txt.gap = song.gap
if not(type(song.video_gap) == float and str(song.video_gap) == "nan"):
if song.video_gap != None:
txt.videogap = song.video_gap
if not(type(song.start) == float and str(song.start) == "nan"):
if song.start != None:
txt.start = song.start
if not(type(song.gap) == float and str(song.gap) == "nan"):
if song.gap != None:
txt.end = song.end
if not(type(song.gap) == float and str(song.gap) == "nan"):
if song.language != None:
txt.language = song.language
if song.release_date != datetime.date.min:
......
......@@ -34,16 +34,19 @@ class USDB:
self.cache = cache
self.out = out
def check(self, only_complete):
def check(self, only_complete: bool, only_not_complete: bool):
for song in self.songs:
if only_complete and not song.isComplete():
continue
if only_not_complete and song.isComplete():
continue
valid, errors = song.isValid()
if not valid:
logging.error(f"USDB Entry is invalid ({song.uri}): {song.artist_name} - {song.track_name} --- Errors {','.join(errors)}")
def download(self, only_complete):
def download(self, only_complete: bool, only_not_complete: bool):
if self.session == None:
logging.fatal("Session key is missing")
......@@ -56,6 +59,8 @@ class USDB:
for song in self.songs:
if only_complete and not song.isComplete():
continue
if only_not_complete and song.isComplete():
continue
vaild, errors = song.isBuildable()
if vaild:
......@@ -84,13 +89,15 @@ class USDB:
except Exception as e:
logging.exception(f"Downloading failed: {song.artist_name} - {song.track_name}")
def build(self, only_complete):
def build(self, only_complete: bool, only_not_complete: bool):
if self.force_build:
shutil.rmtree(self.out, ignore_errors=True)
for song in self.songs:
if only_complete and not song.isComplete():
continue
if only_not_complete and song.isComplete():
continue
vaild, errors = song.isBuildable()
if vaild:
......@@ -118,6 +125,10 @@ class USDB:
if (Path(self.cache) / "audio" / f"{song.getFileName_Hash_MP3()}.mp3").is_file():
shutil.copy2(Path(self.cache) / "audio" / f"{song.getFileName_Hash_MP3()}.mp3", new_path / f"{song.getFileName()}.mp3")
else:
logging.error(f"Download is missing ({song.uri}): {song.artist_name} - {song.track_name} --- MP3")
return
if song.video_link != None and (Path(self.cache) / "video" / f"{song.getFileName_Hash_Video()}.mp4").is_file():
shutil.copy2(Path(self.cache) / "video" / f"{song.getFileName_Hash_Video()}.mp4", new_path / f"{song.getFileName()}.mp4")
if song.cover_link != None and (Path(self.cache) / "covers" / f"{song.getFileName_Hash_Cover()}.jpg").is_file():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment