From 10328263a014e5692b2790c784c0e3ef5ded6b27 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 26 Jan 2023 20:03:04 +0300 Subject: [PATCH] Parse uuid via regexp from url --- src/mpv_control.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mpv_control.py b/src/mpv_control.py index fdcf67c..cf53451 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -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: