From a5c598488054aab76bcbbc5084d1011f73d6bb6b Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Sat, 12 Aug 2023 04:12:50 +0300 Subject: [PATCH] tracks deduplicator --- src/mpv_control.py | 9 ++++++++- src/utils.py | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mpv_control.py b/src/mpv_control.py index db1a62e..6d92cbc 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -1,10 +1,11 @@ import src.fw_api -from src.utils import download_track, print_there, track_info_output +from src.utils import download_track, print_there, track_info_output, indices from src.settings import get_config from loguru import logger from pyfzf.pyfzf import FzfPrompt from shutil import get_terminal_size from shlex import quote +from contextlib import suppress import mpv import time import re @@ -145,6 +146,12 @@ def soft_volume_reduce(): @logger.catch def player_menu(header='', storage={}): + for i in player.playlist_filenames: + count_same_tracks = indices(player.playlist_filenames, i) + while len(count_same_tracks) > 1: + with suppress(SystemError): + player.playlist_remove(count_same_tracks[-1]) + count_same_tracks = indices(player.playlist_filenames, i) player_fw_storage.storage.update(storage) player.volume = get_config("mpv_volume") global shuffle diff --git a/src/utils.py b/src/utils.py index f66fe0a..0023f19 100644 --- a/src/utils.py +++ b/src/utils.py @@ -78,3 +78,8 @@ def track_info_output(track): output.append('Failed get related') output = '\n'.join(output) os.system(f'less <