Compare commits

..

No commits in common. "706d7684dd6ed66ba69c831161dea1b12359d4cb" and "11dba2648d1aaed8dffad960818516aba9aa1e43" have entirely different histories.

3 changed files with 11 additions and 36 deletions

View File

@ -7,7 +7,7 @@ from src.fw_albums import list_albums
from src.fw_tracks import list_tracks from src.fw_tracks import list_tracks
from src.fw_channels import list_channels from src.fw_channels import list_channels
from src.fw_playlists import list_playlists from src.fw_playlists import list_playlists
from src.fw_recents import list_fav_or_history from src.fw_fav_tracks import list_favorites_tracks
import src.settings as settings import src.settings as settings
import src.mpv_control import src.mpv_control
import json import json
@ -44,7 +44,6 @@ def main():
'Channels', 'Channels',
'Playlists', 'Playlists',
'Favorites', 'Favorites',
'Recently listened',
'Search', 'Search',
'Switch instance'] 'Switch instance']
if not current_instance.s.headers.get('Authorization'): if not current_instance.s.headers.get('Authorization'):
@ -69,9 +68,7 @@ def main():
if selected == 'Playlists': if selected == 'Playlists':
list_playlists() list_playlists()
if selected == 'Favorites': if selected == 'Favorites':
list_fav_or_history() list_favorites_tracks()
if selected == 'Recently listened':
list_fav_or_history(is_history_view=True)
if selected == 'Search': if selected == 'Search':
search_type = fzf.prompt(('Federated', 'All types'))[0] search_type = fzf.prompt(('Federated', 'All types'))[0]
if search_type == 'Federated': if search_type == 'Federated':

View File

@ -123,7 +123,7 @@ def get_tracks(page=None, q=None, artist=None, album=None, library=None,
@logger.catch @logger.catch
def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None): def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None):
'''Get favorites tracks (not only for user)''' '''This function get favorites tracks (not only for user)'''
params = { params = {
'page': page, 'page': page,
'q': q, 'q': q,
@ -138,23 +138,6 @@ def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, p
return r.json() return r.json()
@logger.catch
def get_recently_listened(page=None, q=None, scope=None, include_channels=None, pg=None):
'''Get recently listened tracks (not only for user)'''
params = {
'page': page,
'q': q,
'scope': scope,
'include_channels': include_channels
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/history/listenings', params=params)
return r.json()
@logger.catch @logger.catch
def get_artists(page=None, q=None, artist=None, album=None, def get_artists(page=None, q=None, artist=None, album=None,
library=None, favourites=None, refresh=False, pg=None): library=None, favourites=None, refresh=False, pg=None):

View File

@ -1,4 +1,4 @@
from src.fw_api import get_favorires_tracks, get_recently_listened, get_audio_file from src.fw_api import get_favorires_tracks, get_audio_file
from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage
from pyfzf.pyfzf import FzfPrompt from pyfzf.pyfzf import FzfPrompt
from loguru import logger from loguru import logger
@ -7,13 +7,8 @@ fzf = FzfPrompt()
@logger.catch @logger.catch
def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False): def list_favorites_tracks(pg=None, search=None, scope=None):
if is_history_view: tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
caption = 'listened:'
tracks = get_recently_listened(q=search, scope=scope, pg=pg)
else:
caption = 'liked:'
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
tracks_next = tracks.get('next') tracks_next = tracks.get('next')
tracks_prev = tracks.get('previous') tracks_prev = tracks.get('previous')
tracks_results = tracks.get('results') tracks_results = tracks.get('results')
@ -27,15 +22,15 @@ def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False)
index = tracks_results.index(i) index = tracks_results.index(i)
track_name = i['track'].get('title') track_name = i['track'].get('title')
who_user = i['user'].get('username') who_user = i['user'].get('username')
view.append(f'{index}.{track_name} | {caption} {who_user}') view.append(f'{index}.{track_name} | liked: {who_user}')
select = fzf.prompt(view, '--multi') select = fzf.prompt(view, '--multi')
if 'Next page' in select: if 'Next page' in select:
list_fav_or_history(pg=tracks_next, is_history_view=is_history_view) list_favorites_tracks(pg=tracks_next)
elif 'Prev page' in select: elif 'Prev page' in select:
list_fav_or_history(pg=tracks_prev, is_history_view=is_history_view) list_favorites_tracks(pg=tracks_prev)
elif 'Search' in select: elif 'Search' in select:
print('Search by track:') print('Search by track:')
list_fav_or_history(search=input(), is_history_view=is_history_view) list_favorites_tracks(search=input())
elif 'Limit by scope' in select: elif 'Limit by scope' in select:
print(''' print('''
Limit the results to a given user or pod: Limit the results to a given user or pod:
@ -48,7 +43,7 @@ Limit the results to a given user or pod:
''') ''')
scope = input() scope = input()
list_fav_or_history(scope=scope, search=search, is_history_view=is_history_view) list_favorites_tracks(scope=scope, search=search)
elif 'Play this page' in select: elif 'Play this page' in select:
for i in tracks_results: for i in tracks_results:
play_track(track=i['track'], multi=True) play_track(track=i['track'], multi=True)