From a9b3fddffe78b95b3ddd325f244ac68e6f13642c Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 25 Jul 2024 17:52:15 +0300 Subject: [PATCH] improved filter count tracks --- funkwlplay.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/funkwlplay.py b/funkwlplay.py index 5332974..539961c 100755 --- a/funkwlplay.py +++ b/funkwlplay.py @@ -40,7 +40,6 @@ def filter_tracks(tracks): except: return 0 with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor: - before = len(tracks) res = [executor.submit(remove_unreach_tracks, track) for track in tracks] concurrent.futures.wait(res) avalaible = [] @@ -49,8 +48,6 @@ def filter_tracks(tracks): if is_avalaible == 1: avalaible.append(track) tracks = avalaible - after = before - len(tracks) - print(f'-{after} unreach tracks') Path('filter_tags').touch() Path('filter_artists').touch() @@ -63,7 +60,7 @@ def filter_tracks(tracks): with open('filter_raw_urls') as raw_urls_file: block_raw_urls = raw_urls_file.read().strip().split('\n') - + filtred_tracks = [] for i in tracks: if [tag.lower() for tag in i['tags']] in block_tags: continue @@ -71,7 +68,8 @@ def filter_tracks(tracks): continue if i['listen_url'].lower() in block_raw_urls: continue - tracks_stor.append(i) + filtred_tracks.append(i) + return filtred_tracks @@ -111,7 +109,11 @@ with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor: for idx, instance in enumerate(instances): try: tracks = res[idx].result() - filter_tracks(tracks['results']) + before_filter = len(tracks['results']) + filtred_tracks = filter_tracks(tracks['results']) + after_filter = before_filter - len(filtred_tracks) + print(f'{after_filter} tracks filtred on {instance}') + tracks_stor = filtred_tracks except Exception as E: print(E) for track in tracks_stor: