mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 22:59:19 +02:00
Fix radio generator too many requests; logging some parts
This commit is contained in:
parent
ae1cba2e98
commit
74f9a732ef
|
@ -1,6 +1,6 @@
|
||||||
from src.fw_api import select_instance
|
from src.fw_api import select_instance
|
||||||
from src.fw_radios import list_radios
|
from src.fw_radios import list_radios
|
||||||
import json
|
import json, sys
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ fzf = FzfPrompt()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logger.remove()
|
logger.remove()
|
||||||
|
logger.add(sys.stderr, filter='src.fw_api')
|
||||||
|
logger.add(sys.stderr, filter='src.fw_radios')
|
||||||
while True:
|
while True:
|
||||||
menu = ('Radios', 'Switch instance' )
|
menu = ('Radios', 'Switch instance' )
|
||||||
ids = fzf.prompt(menu)
|
ids = fzf.prompt(menu)
|
||||||
|
|
|
@ -64,6 +64,10 @@ def post_radio_session(requested_radio):
|
||||||
|
|
||||||
def get_track_radio(radio_session):
|
def get_track_radio(radio_session):
|
||||||
r = s.post(f'https://{instance}/api/v1/radios/tracks/',json=radio_session)
|
r = s.post(f'https://{instance}/api/v1/radios/tracks/',json=radio_session)
|
||||||
|
try:
|
||||||
|
r.raise_for_status()
|
||||||
return r.json()
|
return r.json()
|
||||||
|
except:
|
||||||
|
logger.exception('Radio: get next track failed')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ def radio_generator(radio_session_id):
|
||||||
break
|
break
|
||||||
count_t += 1
|
count_t += 1
|
||||||
if count_t >= 60:
|
if count_t >= 60:
|
||||||
|
count_t = 0
|
||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
logger.info('Radio generator stopped')
|
logger.info('Radio generator stopped')
|
||||||
|
|
||||||
|
@ -100,7 +101,8 @@ def radio_load(id_radio=None, type_radio='custom'):
|
||||||
|
|
||||||
def radio_get_track(radio_session_id):
|
def radio_get_track(radio_session_id):
|
||||||
radio_context = get_track_radio({'session': radio_session_id})
|
radio_context = get_track_radio({'session': radio_session_id})
|
||||||
|
if not radio_context:
|
||||||
|
return
|
||||||
if radio_context == "Radio doesn't have more candidates":
|
if radio_context == "Radio doesn't have more candidates":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue