feat: cleaned downloading
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
8f9858da60
commit
67f475076c
@ -560,7 +560,6 @@ class Artist(Base):
|
|||||||
id3Mapping.ARTIST: [self.name],
|
id3Mapping.ARTIST: [self.name],
|
||||||
id3Mapping.ARTIST_WEBPAGE_URL: self.source_collection.url_list,
|
id3Mapping.ARTIST_WEBPAGE_URL: self.source_collection.url_list,
|
||||||
})
|
})
|
||||||
metadata.merge_many([s.get_artist_metadata() for s in self.source_collection])
|
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
@ -108,6 +108,9 @@ class SourceCollection:
|
|||||||
|
|
||||||
self.extend(data or [])
|
self.extend(data or [])
|
||||||
|
|
||||||
|
def has_source_page(self, *source_pages: SourcePages) -> bool:
|
||||||
|
return any(source_page in self._page_to_source_list for source_page in source_pages)
|
||||||
|
|
||||||
def get_sources(self, *source_pages: List[Source]) -> Generator[Source]:
|
def get_sources(self, *source_pages: List[Source]) -> Generator[Source]:
|
||||||
if not len(source_pages):
|
if not len(source_pages):
|
||||||
source_pages = self.source_pages
|
source_pages = self.source_pages
|
||||||
@ -146,7 +149,7 @@ class SourceCollection:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def url_list(self) -> List[str]:
|
def url_list(self) -> List[str]:
|
||||||
return [source.url for source in self.get_sources(SourcePages.ARTIST)]
|
return [source.url for source in self.get_sources()]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def homepage_list(self) -> List[str]:
|
def homepage_list(self) -> List[str]:
|
||||||
|
@ -419,9 +419,10 @@ class Page:
|
|||||||
if song.target_collection.empty:
|
if song.target_collection.empty:
|
||||||
song.target_collection.append(new_target)
|
song.target_collection.append(new_target)
|
||||||
|
|
||||||
|
if not song.source_collection.has_source_page(self.SOURCE_TYPE):
|
||||||
|
return DownloadResult(error_message=f"No {self.__class__.__name__} source found for {song.option_string}.")
|
||||||
|
|
||||||
sources = song.source_collection.get_sources(self.SOURCE_TYPE)
|
sources = song.source_collection.get_sources(self.SOURCE_TYPE)
|
||||||
if len(sources) == 0:
|
|
||||||
return DownloadResult(error_message=f"No source found for {song.title} as {self.__class__.__name__}.")
|
|
||||||
|
|
||||||
temp_target: Target = Target(
|
temp_target: Target = Target(
|
||||||
relative_to_music_dir=False,
|
relative_to_music_dir=False,
|
||||||
@ -448,14 +449,19 @@ class Page:
|
|||||||
self.LOGGER.info(f"{song.option_string} already exists, thus not downloading again.")
|
self.LOGGER.info(f"{song.option_string} already exists, thus not downloading again.")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
source = sources[0]
|
|
||||||
|
|
||||||
if not found_on_disc:
|
if not found_on_disc:
|
||||||
r = self.download_song_to_target(source=source, target=temp_target, desc=song.option_string)
|
for source in sources:
|
||||||
|
r = self.download_song_to_target(source=source, target=temp_target, desc=song.option_string)
|
||||||
|
|
||||||
if not r.is_fatal_error:
|
if not r.is_fatal_error:
|
||||||
r.merge(self._post_process_targets(song, temp_target,
|
break
|
||||||
[] if found_on_disc else self.get_skip_intervals(song, source)))
|
|
||||||
|
if temp_target.exists:
|
||||||
|
r.merge(self._post_process_targets(
|
||||||
|
song=song,
|
||||||
|
temp_target=temp_target,
|
||||||
|
interval_list=[] if found_on_disc else self.get_skip_intervals(song, source)
|
||||||
|
))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user