From 09c2fd191e9a136d7acf42d0647ad3fe05240fee Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Sat, 2 Apr 2022 22:44:45 +0300 Subject: [PATCH] added history instances usage --- .gitignore | 1 + funkwhale-cli.sh | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 335639f..68cbea8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ playlist.m3u8 podcast.m3u8 preload +instance.hist diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 88858a1..0cc0676 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -1,6 +1,7 @@ #!/bin/sh instance=$(jj -i config.json instance) +instance_hist='instance.hist' ordering='title' default_player_command='mpv --no-vid --no-ytdl --network-timeout=30' @@ -143,23 +144,34 @@ case "$choice" in "$changepod") - if [ 'Choice from list' = "$(echo 'Choice from list\nManual input' | fzy)" ]; then - instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy) - else - echo "Type instance (ex. $instance):" - read instance - fi - - export instance - export instance_point="https://$instance/api/v1" - conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy) - if [ "$conf_instance_state" = 'Permanent' ]; then - jj -i config.json instance -v $instance -o config.json - else - echo '' - fi - clear - get_all_avalaible_count_tracks ;; + empty=0 + case $(echo 'Recently used\nChoice from list\nManual input' | fzy) in + "Recently used") + if [ -s $instance_hist ]; then + touch $instance_hist && instance=$(cat $instance_hist | fzy) + else + echo 'No recently used instances...' + empty=1 + fi ;; + + "Choice from list") instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy) ;; + + "Manual input") echo "Type instance (ex. $instance):" && read instance ;; + esac + if [ $empty -eq 0 ]; then + echo $instance >> $instance_hist + cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null + export instance + export instance_point="https://$instance/api/v1" + conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy) + if [ "$conf_instance_state" = 'Permanent' ]; then + jj -i config.json instance -v $instance -o config.json + else + echo '' + fi + clear + get_all_avalaible_count_tracks + fi ;; "$checkapilimits")