Implement 'shuffle all' and 'play all' (#81)

fix #73: Implement 'shuffle all' and 'play all'
Esse commit está contido em:
howyay
2022-07-21 04:48:52 +00:00
commit de GitHub
commit fd1b9ea84a
4 arquivos alterados com 38 adições e 16 exclusões
+5
Ver Arquivo
@@ -9,6 +9,11 @@ from . import RS, WORD, command
from .search import related, yt_url
from .songlist import plist
@command(r'play all', 'play all')
def play_loaded():
g.model.songs = content.get_last_query()
if g.model.songs:
play_all("", "", "")
@command(r'play\s+(%s|\d+)' % WORD, 'play')
def play_pl(name):
+15 -15
Ver Arquivo
@@ -208,6 +208,16 @@ def shuffle_fn():
g.message = c.y + "Items shuffled" + c.w
g.content = content.generate_songlist_display()
@command(r'shuffle all', 'shuffle all')
def shuffle_playlist():
""" Shuffle entire loaded playlist. """
songs = content.get_last_query()
if songs:
random.shuffle(songs)
paginatesongs(list(songs))
g.message = c.y + "Shuffled entire playlist" + c.w
g.content = content.generate_songlist_display()
@command(r'reverse', 'reverse')
def reverse_songs():
@@ -231,19 +241,9 @@ def reverse_songs_range(lower, upper):
@command(r'reverse all', 'reverse all')
def reverse_playlist():
""" Reverse order of entire loaded playlist. """
# Prevent crash if no last query
if g.last_search_query == (None, None) or \
'func' not in g.last_search_query[1]:
g.content = content.logo()
g.message = "No playlist loaded"
return
songs = content.get_last_query()
songs_list_or_func = g.last_search_query[1]['func']
if callable(songs_list_or_func):
songs = reversed(songs_list_or_func(0,None))
else:
songs = reversed(songs_list_or_func)
paginatesongs(list(songs))
g.message = c.y + "Reversed entire playlist" + c.w
g.content = content.generate_songlist_display()
if songs:
paginatesongs(list(reversed(songs)))
g.message = c.y + "Reversed entire playlist" + c.w
g.content = content.generate_songlist_display()
+16
Ver Arquivo
@@ -259,3 +259,19 @@ def qrcode_display(url):
qr.add_data(url)
qr.print_ascii(out=buf)
return buf.getvalue()
def get_last_query():
# Prevent crash if no last query
if g.last_search_query == (None, None) or \
'func' not in g.last_search_query[1]:
g.content = logo()
g.message = "No playlist loaded"
return
songs_list_or_func = g.last_search_query[1]['func']
if callable(songs_list_or_func):
songs = songs_list_or_func(0,None)
else:
songs = songs_list_or_func
return songs
+2 -1
Ver Arquivo
@@ -93,8 +93,9 @@ def helptext():
{2}mix <number>{1} - show YouTube mix playlist from item in results.
{2}shuffle{1} - Shuffle the displayed results.
{2}shuffle all{1} - Shuffle entire loaded playlist.
{2}reverse{1} or {2}reverse <number>-<number>{1} - Reverse the displayed items or item range.
{2}reverse all{1} - Reverse order of entire loaded playlist
{2}reverse all{1} - Reverse order of entire loaded playlist.
""".format(c.ul, c.w, c.y)),
("download", "Downloading and Playback", """