Skip to content

Commit

Permalink
- Version 0.8.8
Browse files Browse the repository at this point in the history
- Fixing volume display for python 3 MPV, before a Title is received
- Finalizing \p command
  • Loading branch information
s-n-g committed Dec 10, 2020
1 parent 26992bb commit fe41bfa
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 98 deletions.
7 changes: 5 additions & 2 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
2020-12-06 s-n-g
* Starting 0.8.8-beta7
2020-12-10 s-n-g
* Starting 0.8.8
* Implementing "Paste to playlist" (\p) command
* Implementing "Create Playlist" (\n)
* Addind \u (show Unnamed Register) command
* Fixing volume display for MPV on python3 before a
valid Title has been received
* Revert to stations playlist if default one (set by
config) does not exist
* Second level config windows will not be displayed
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# New stable version: ''
# Beta version: 'betax', x=1,2,3...
# RC version: 'RCx', x=1,23...
app_state = 'beta7'
app_state = ''

__version__ = version = '.'.join(map(str, version_info))
__project__ = __name__
Expand Down
1 change: 0 additions & 1 deletion pyradio/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ def get_data_dict(data):
callback(my_data, ret)
lock.release()


def probeBrowsers(a_browser_url):
base_url = a_browser_url.split('/')[2]
logger.error('DE base_url = ' + base_url)
Expand Down
65 changes: 36 additions & 29 deletions pyradio/config_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ def refresh_win(self, set_encoding=True):
curses.color_pair(4))
for i in range(1, self.maxX - 1):
try:
self._win.addch(self.maxY -4, i, '─', curses.color_pair(3))
self._win.addch(self.maxY - 4, i, '─', curses.color_pair(3))
except:
self._win.addstr(self.maxY -4 , i, u'─'.encode('utf-8'), curses.color_pair(3))
self._win.addstr(self.maxY - 4, i, u'─'.encode('utf-8'), curses.color_pair(3))
try:
self._win.addch(self.maxY - 4, 0, '├', curses.color_pair(3))
self._win.addch(self.maxY - 4, self.maxX - 1, '┤', curses.color_pair(3))
Expand Down Expand Up @@ -981,6 +981,7 @@ def __init__(self, parent, config_path, default_playlist, include_registers=Fals
#self._include_registers = True
if self._include_registers:
self._title = ' Paste: Select target '
self._playlist_in_editor = self._selected_playlist
self.init_window()

def __del__(self):
Expand All @@ -992,10 +993,6 @@ def init_window(self):
self.maxY = self._num_of_items + 2
if self.maxY > self._parent_maxY - 2:
self.maxY = self._parent_maxY - 2
#elif self.maxY < 12:
# self.maxY = 12
#if self.maxY < 7:
# self.maxY = 7
self._calculate_width()
self._win = None
Y = int((self._parent_maxY - self.maxY) / 2) + self._parent_Y
Expand All @@ -1007,7 +1004,6 @@ def refresh_and_resize(self, parent_maxYX):
self._parent_maxX = parent_maxYX[1]
self.init_window()
self.refresh_win(resizing=True)
self._resize()

def _calculate_width(self):
self.maxX = self._max_len + 5 + len(str(self._num_of_items))
Expand All @@ -1018,15 +1014,16 @@ def _calculate_width(self):
self.maxX = self._parent_maxX - 4

def refresh_win(self, resizing=False):
""" set_encoding is False when resizing """
#self.init_window(set_encoding)
self._win.bkgdset(' ', curses.color_pair(3))
self._win.erase()
self._win.box()
self._win.addstr(0,
int((self.maxX - len(self._title)) / 2),
self._win.addstr(
0, int((self.maxX - len(self._title)) / 2),
self._title,
curses.color_pair(4))
curses.color_pair(4)
)
if resizing:
self._resize()
self.refresh_selection(resizing)

def refresh_selection(self, resizing=False):
Expand All @@ -1036,13 +1033,13 @@ def refresh_selection(self, resizing=False):
#logger.error('de i = {0}, startPos = {1}'.format(i, self.startPos))
if i + self.startPos < self._num_of_items:
line, pad = self._format_line(i, pad)
col = self._get_color(i)
self._win.hline(i + 1, 1, ' ', self.maxX - 2, col)
self._win.addstr(i + 1, 1, line[:self.maxX - 3], col)
colour = self._get_color(i)
self._win.hline(i + 1, 1, ' ', self.maxX - 2, colour)
self._win.addstr(i + 1, 1, line[:self.maxX - 3], colour)
else:
break
self._win.refresh()
if not resizing:
self._win.refresh()
if self._select_playlist_error > -2:
self.print_select_playlist_error()

Expand All @@ -1051,13 +1048,12 @@ def _resize(self):
self.startPos = 0
else:
self._fix_startPos()
self.refresh_selection()

def _get_color(self, i):
col = curses.color_pair(5)
if self._items[i + self.startPos] == self._orig_playlist:
if i + self.startPos == self._selected_playlist_id:
col =curses.color_pair(9)
col = curses.color_pair(9)
else:
col = curses.color_pair(4)
elif i + self.startPos == self._selected_playlist_id:
Expand All @@ -1066,12 +1062,13 @@ def _get_color(self, i):

def _format_line(self, i, pad):
""" PyRadioSelectPlaylist format line """
line = '{0}. {1}'.format(str(i + self.startPos + 1).rjust(pad),
self._items[i + self.startPos])
line = '{0}. {1}'.format(
str(i + self.startPos + 1).rjust(pad),
self._items[i + self.startPos]
)
return line, pad

def _read_items(self):
to_del = -1
self._items = []
self._items = glob.glob(path.join(self._config_path, '*.csv'))
if len(self._items) > 0:
Expand All @@ -1088,20 +1085,22 @@ def _read_items(self):
return 0, -1
for i, an_item in enumerate(self._items):
if self._include_registers:
self._items[i] = an_item.replace(self._registers_path + sep, '').replace('.csv', '').replace('register_', 'Register: ')
self._items[i] = an_item.replace(self._registers_path + sep, '').replace('.csv', '').replace('register_', 'Register: ')
self._items[i] = self._items[i].replace(self._config_path + sep, '')
if self._items[i] == self._selected_playlist:
to_del = i
else:
self._items[i] = an_item.replace(self._config_path + sep, '').replace('.csv', '')
""" get already loaded playlist id """
if not self._include_registers:
if self._include_registers:
""" Remove playlist in editor """
try:
self._items.remove(self._playlist_in_editor)
except ValueError:
pass
else:
""" get already loaded playlist id """
for i, a_playlist in enumerate(self._items):
if a_playlist ==self._selected_playlist:
self._selected_playlist_id = i
break
if to_del >= 0:
del self._items[to_del]
self._max_len = cjklen(max(self._items, key=cjklen))
self._num_of_items = len(self._items)

Expand Down Expand Up @@ -1144,7 +1143,7 @@ def _get_result(self):
ret = self._items[self._selected_playlist_id].replace('Register: ', 'register_')
ret = path.join(self._config_path, '.registers', ret + '.csv')
else:
ret = path.join(self._config_path, self._items[self._selected_playlist_id], ret + '.csv')
ret = path.join(self._config_path, self._items[self._selected_playlist_id] + '.csv')
if platform == 'win32':
ret.replace('.registers', '_registers')
return 0, ret
Expand Down Expand Up @@ -1215,6 +1214,14 @@ def _fix_startPos(self):
self.startPos = self._selected_playlist_id - int((self.maxY - 2) / 2)

def keypress(self, char):
""" Return restlt from playlist selection window
Results are:
-1, '' - Continue in window
0, station title - selected station title (for config window)
0, station path - selected station path (for paste window)
1, '' - Cancel
"""
if self._select_playlist_error == -1 or \
self._select_playlist_error == 0:
self._error_win = None
Expand Down
19 changes: 11 additions & 8 deletions pyradio/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,7 @@ def _set_mpv_playback_is_on(self, stop):
self.outputStream.write(msg=new_input, counter='')
if self.oldUserInput['Title'] == '':
self.oldUserInput['Input'] = new_input
else:
self.oldUserInput['Title'] = new_input
self.oldUserInput['Title'] = new_input
self.playback_is_on = True
if stop():
return False
Expand Down Expand Up @@ -1107,12 +1106,17 @@ def play(self, name, streamUrl, encoding = ''):
stdout=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
t = threading.Thread(target=self.updateMPVStatus, args=(lambda: self.stop_mpv_status_update_thread, ))
t = threading.Thread(
target=self.updateMPVStatus,
args=(lambda: self.stop_mpv_status_update_thread, )
)
else:
self.process = subprocess.Popen(opts, shell=False,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT)
self.process = subprocess.Popen(
opts, shell=False,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT
)
t = threading.Thread(target=self.updateStatus, args=())
t.start()
# start playback check timer thread
Expand Down Expand Up @@ -1156,7 +1160,6 @@ def close(self):
self._no_mute_on_stop_playback()

# First close the subprocess
logger.error('DE self._stop()')
self._stop()
# Here is fallback solution and cleanup
self.stop_timeout_counter_thread = True
Expand Down
Loading

0 comments on commit fe41bfa

Please sign in to comment.