Parse uuid via regexp from url

This commit is contained in:
localhost_frssoft 2023-01-26 20:03:04 +03:00
parent 10ccbecd9e
commit 10328263a0

View file

@ -7,6 +7,7 @@ from shutil import get_terminal_size
import mpv
import time
import sys
import re
fzf = FzfPrompt()
@ -25,11 +26,15 @@ class player_fw_storage:
@logger.catch
def track_url_to_uuid(listen_url=None):
'''Attempt get uuid from track listen url or current playing url'''
hex = '[0-9a-fA-F]+'
find_uuid = f'{hex}-{hex}-{hex}-{hex}-{hex}'
if listen_url:
uuid = listen_url.split(r'/')[-2]
uuid = re.findall(find_uuid, listen_url)
else:
uuid = player.stream_open_filename.split(r'/')[-2]
return uuid
uuid = re.findall(find_uuid, player.stream_open_filename)
return uuid[0]
if track_activity_history: