mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 04:11:29 +00:00
Some visual changes in mpv console osd
This commit is contained in:
parent
07d137f72d
commit
4aa1476a81
|
@ -8,6 +8,7 @@ from pyfzf.pyfzf import FzfPrompt
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
@ -84,7 +85,8 @@ def radio_generator(radio_session_id):
|
||||||
player.playlist_current_pos
|
player.playlist_current_pos
|
||||||
if playlist_remaining <= 2:
|
if playlist_remaining <= 2:
|
||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
logger.info('Radio generator stopped')
|
sys.stdout.write('\rRadio generator stopped')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
radio_event_gen = threading.Event()
|
radio_event_gen = threading.Event()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import src.fw_api
|
import src.fw_api
|
||||||
from src.utils import download_track
|
from src.utils import download_track, print_there
|
||||||
from src.settings import get_config
|
from src.settings import get_config
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
@ -58,9 +58,22 @@ def osd_observer(_name, value):
|
||||||
for i in value.items():
|
for i in value.items():
|
||||||
if i[0] in ('Artist', 'Album', 'Title'):
|
if i[0] in ('Artist', 'Album', 'Title'):
|
||||||
osd_message.append(i[1])
|
osd_message.append(i[1])
|
||||||
sys.stdout.write('\r ')
|
print_there(0, 0, '\r ')
|
||||||
sys.stdout.write('\r'+' — '.join(osd_message))
|
print_there(0, 0, '\r'+' — '.join(osd_message))
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
|
@player.property_observer('percent-pos')
|
||||||
|
@logger.catch
|
||||||
|
def universal_observer(_name, value):
|
||||||
|
if value:
|
||||||
|
if player.audio_bitrate:
|
||||||
|
kbps = round(player.audio_bitrate/1024, 1)
|
||||||
|
else:
|
||||||
|
kbps = '?'
|
||||||
|
percent = int(value)
|
||||||
|
track_size = round(player.file_size/1024/1024, 1)
|
||||||
|
print_there(2, 2, f'\r{kbps} kbps | {percent}% | {track_size}Mb')
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
def set_http_header(headers=[]):
|
def set_http_header(headers=[]):
|
||||||
|
|
|
@ -37,3 +37,9 @@ def download_track(url, name=None):
|
||||||
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)))
|
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def print_there(x, y, text):
|
||||||
|
'''Print at position x, y caption in terminal (? Linux only)'''
|
||||||
|
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
Loading…
Reference in a new issue