mirror of
https://github.com/glomatico/gamdl.git
synced 2025-01-22 11:18:39 +00:00
update update_playlist_file
This commit is contained in:
parent
d97445ec9e
commit
66556eac0a
18
gamdl/cli.py
18
gamdl/cli.py
@ -746,12 +746,18 @@ def main(
|
||||
downloader.apply_tags(remuxed_path, tags, cover_url)
|
||||
logger.debug(f'Moving to "{final_path}"')
|
||||
downloader.move_to_output_path(remuxed_path, final_path)
|
||||
if save_playlist and download_queue.playlist_attributes:
|
||||
playlist_file_path = downloader.get_playlist_file_path(tags)
|
||||
logger.debug(
|
||||
f'Updating M3U8 playlist from "{playlist_file_path}"'
|
||||
)
|
||||
downloader.update_playlist_file(playlist_file_path, final_path)
|
||||
if (
|
||||
not synced_lyrics_only
|
||||
and save_playlist
|
||||
and download_queue.playlist_attributes
|
||||
):
|
||||
playlist_file_path = downloader.get_playlist_file_path(tags)
|
||||
logger.debug(f'Updating M3U8 playlist from "{playlist_file_path}"')
|
||||
downloader.update_playlist_file(
|
||||
playlist_file_path,
|
||||
final_path,
|
||||
playlist_track,
|
||||
)
|
||||
except Exception as e:
|
||||
error_count += 1
|
||||
logger.error(
|
||||
|
@ -283,6 +283,7 @@ class Downloader:
|
||||
self,
|
||||
playlist_file_path: Path,
|
||||
final_path: Path,
|
||||
playlist_track: int,
|
||||
):
|
||||
playlist_file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
playlist_file_path_parent_parts_len = len(playlist_file_path.parent.parts)
|
||||
@ -291,8 +292,18 @@ class Downloader:
|
||||
("../" * (playlist_file_path_parent_parts_len - output_path_parts_len)),
|
||||
*final_path.parts[output_path_parts_len:],
|
||||
)
|
||||
with playlist_file_path.open("a", encoding="utf8") as playlist_file:
|
||||
playlist_file.write(final_path_relative.as_posix() + "\n")
|
||||
playlist_file_lines = (
|
||||
playlist_file_path.open("r", encoding="utf8").readlines()
|
||||
if playlist_file_path.exists()
|
||||
else []
|
||||
)
|
||||
if len(playlist_file_lines) < playlist_track:
|
||||
playlist_file_lines.extend(
|
||||
"\n" for _ in range(playlist_track - len(playlist_file_lines))
|
||||
)
|
||||
playlist_file_lines[playlist_track - 1] = final_path_relative.as_posix() + "\n"
|
||||
with playlist_file_path.open("w", encoding="utf8") as playlist_file:
|
||||
playlist_file.writelines(playlist_file_lines)
|
||||
|
||||
@staticmethod
|
||||
def millis_to_min_sec(millis):
|
||||
|
Loading…
Reference in New Issue
Block a user