refactor: add recently stations in favourites
This commit is contained in:
parent
107ce5c0fa
commit
a0cba1449e
3 changed files with 11 additions and 10 deletions
|
@ -4,8 +4,9 @@ import os
|
|||
import yaml
|
||||
|
||||
VAR_PATH = os.path.expanduser("~") + '/.ycast'
|
||||
MAX_ENTRIES = 15
|
||||
|
||||
config_file = VAR_PATH + '/lastheared.yml'
|
||||
config_file = VAR_PATH + '/recently.yml'
|
||||
|
||||
def signalStationSelected(name,url,icon):
|
||||
logging.debug(" %s:%s|%s",name,url,icon)
|
||||
|
@ -23,8 +24,8 @@ def signalStationSelected(name,url,icon):
|
|||
piped_icon = '|' + icon
|
||||
|
||||
list_heared_stations.insert(1,' '+name+': '+url+piped_icon+'\n')
|
||||
if len(list_heared_stations) > 11:
|
||||
# remove last
|
||||
if len(list_heared_stations) > MAX_ENTRIES+1:
|
||||
# remove last (oldest) entry
|
||||
list_heared_stations.pop()
|
||||
|
||||
set_stations_yaml(list_heared_stations)
|
||||
|
@ -58,7 +59,7 @@ def get_stations_list():
|
|||
return []
|
||||
return heared_stations
|
||||
|
||||
def get_last_stations_yaml():
|
||||
def get_recently_stations_yaml():
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
my_stations = yaml.safe_load(f)
|
|
@ -44,8 +44,8 @@ def get_station_by_id(uid):
|
|||
|
||||
|
||||
def get_stations_yaml():
|
||||
from ycast.my_lastheard import get_last_stations_yaml
|
||||
my_last_station = get_last_stations_yaml()
|
||||
from ycast.my_recentlystation import get_recently_stations_yaml
|
||||
my_recently_station = get_recently_stations_yaml()
|
||||
my_stations = None
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
|
@ -57,10 +57,10 @@ def get_stations_yaml():
|
|||
logging.error("Station configuration format error: %s", e)
|
||||
|
||||
if my_stations:
|
||||
if my_last_station:
|
||||
my_stations.append(my_last_station)
|
||||
if my_recently_station:
|
||||
my_stations.append(my_recently_station)
|
||||
else:
|
||||
return my_last_station
|
||||
return my_recently_station
|
||||
return my_stations
|
||||
|
||||
def get_category_directories():
|
||||
|
|
|
@ -8,7 +8,7 @@ import ycast.radiobrowser as radiobrowser
|
|||
import ycast.my_stations as my_stations
|
||||
import ycast.generic as generic
|
||||
import ycast.station_icons as station_icons
|
||||
from ycast.my_lastheard import signalStationSelected
|
||||
from ycast.my_recentlystation import signalStationSelected
|
||||
|
||||
PATH_ROOT = 'ycast'
|
||||
PATH_PLAY = 'play'
|
||||
|
|
Loading…
Add table
Reference in a new issue