From 89a8133de790874ffe34fe13b7d61d0269635f6d Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 25 Jul 2024 19:00:21 +0300 Subject: [PATCH] get duration track if exists --- funkwlplay.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/funkwlplay.py b/funkwlplay.py index 539961c..35af3ab 100755 --- a/funkwlplay.py +++ b/funkwlplay.py @@ -72,7 +72,6 @@ def filter_tracks(tracks): return filtred_tracks - def search_tracks_on_instance(instance, tag='', query='', recursion=args.recursion): r = requests.get(f'https://{instance}/api/v1/tracks', params={'tag': tag, 'q': query, 'local': True, 'playable': True, @@ -117,6 +116,8 @@ with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor: except Exception as E: print(E) for track in tracks_stor: - artist, album, title, play_url = track['artist']['name'], track['album']['title'], track['title'], track['listen_url'] - playlist_files.append(f'#EXTINF:-1,{artist} - {album} - {title}\n{play_url}') + artist, album, title, play_url, track_duration = track['artist']['name'], track['album']['title'], track['title'], track['listen_url'], track.get('duration') + if not track_duration: + track_duration = -1 + playlist_files.append(f'#EXTINF:{track_duration},{artist} - {album} - {title}\n{play_url}') create_playlist_file(playlist_files)