Updated year, small improvements such as using bash instead of hard-coding command in help screen, deprecated Bash version: will no longer get updated

This commit is contained in:
Mirko Di 2022-01-05 14:08:45 +01:00
parent 8467f3fbd6
commit 006c42aa94
4 changed files with 84 additions and 61 deletions

View File

@ -632,7 +632,8 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
SONARiS
Copyright (C) 2021 Mirko Di
Copyright (C) 2021-2022 mirk0dex
<mirkodi.tech>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -652,7 +653,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) 2021 Mirko Di
<program> Copyright (C) 2021-2022 mirk0dex <mirkodi.tech>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

@ -1,4 +1,4 @@
Copyright (C) 2021 mirk0dex
Copyright (C) 2021-2022 mirk0dex
<mirk0dex.gitlab.io>
This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# Copyright (C) 2021 mirk0dex
# Copyright (C) 2021-2022 mirk0dex
# <mirkodi.tech>
#
# This program is free software: you can redistribute it and/or modify
@ -16,12 +16,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# SONARiS POSIX: a script that lets you listen to tha SoundCloud from your CLI.
# SONARiS Bash: a script that lets you listen to tha SoundCloud from your CLI.
# NOTE: This is the DEPRECATED Bash version, which will no longer be updated,
# use ./sonaris.sh instead (POSIX version).
#
# Deps:
# A POSIX-compliant shell, GNU sed, grep (replaceable with rg), some fuzzy
# finder (default being fzf), curl, a music player (default is mpv) and
# youtube-dl
# bash, GNU sed, grep (replaceable with rg), some fuzzy finder (default
# being fzf), curl, a music player (default is mpv) and youtube-dl
## SETTINGS ######################################################################################
@ -49,7 +50,7 @@ foobar"
## MAIN VARIABLES ################################################################################
# this is the current version of the program
version="POSIX ver. beta 1.0.0 - Codename Mutahar_sus"
version="Stable (Deprecated) 1.0.2 - Codename sus"
# define a couple coloUrs
YELLOW='\033[1;33m'
@ -59,30 +60,34 @@ NC='\033[0m' # no colour
##################################################################################################
# print help screen if needed
# print help screen if needed/requested
helpMe() {
echo "
SONARiS - BASED CLI SoundCloud client and downloader [Version $version]
printf "
SONARiS - DEPRECATED CLI SoundCloud client and downloader [Version %s]
Usage: ./sonaris.sh
./sonaris.sh [options] [option stuffs...]
Usage:\t%s
\t%s [options] [option stuffs...]
SONARiS is a script which allows you to listen to your favourite songs, albums made by the artists you love.
It does so using the amazing MPV and youtube-dl programs and some other nice tools.
SONARiS is a script which allows you to listen to your favourite songs, albums
made by the artists you love. It does so using the amazing MPV and youtube-dl
programs and some other nice tools.
To make it your own and configure it, just open up 'sonaris.sh' in your favoUrite text editor :D.
To make it your own and configure it, just open up 'sonaris.sh' in your
favoUrite text editor :D.
This is free software licensed under the GPL 3.0 license. If you didn't receive a copy of it along with this program, check out <https://www.gnu.org/licenses/>.
This is free software licensed under the GPL 3.0 license. If you didn't receive
a copy of it along with this program, check out <https://www.gnu.org/licenses/>.
Options:
-h, --help prints this help screen and exits
-s, --search [query] search on SoundCloud
-d, --download download a song instead of listening to it
-f, --favs pick an artist from a list (you can choose which to show by editing the script, trust me, it's ez af)
-v, --version prints program version and exits
-h, --help\t\tprints this help screen and exits
-s, --search [query]\tsearch on SoundCloud
-d, --download\tdownload a song instead of listening to it
-f, --favs\t\tpick an artist from a list (you can choose which to show by
\t\t\tediting the script, trust me, it's ez af)
-v, --version\t\tprints program version and exits
[Author: mirk0dex <mirkodi.tech>]
"
[Author: mirk0dex <mirkodi.tech>]\n
" "$version" "$0" "$0"
}
@ -92,7 +97,7 @@ case $1 in
-h|--help) helpMe
exit;;
-s|--search) if [ -z "$2" ]; then
echo "${RED}Error${NC}: please specify what to search for. See ${YELLOW}--help${NC} for more info."
echo "${RED}Error${NC}: please specify what to search for.\nSee ${YELLOW}--help${NC} for more info."
exit 100
else
query="$2"
@ -112,6 +117,7 @@ esac
# if no query is specified using -s or --search, ask for one
enterQuery() {
if [ -z "$query" ]; then
printf "NOTE: This version of SONARiS is DEPRECATED and will no longer be updated,\nplease use the POSIX version instead (./sonaris.sh).\n"
printf "Search: "
read -r query
fi
@ -119,18 +125,21 @@ enterQuery() {
enterQuery
# exit when necessary/asked to
if [ -z "$query" ] || [ "$query" = "q" ] || [ "$query" = "Q" ] || [ "$query" = "wq" ] || [ "$query" = "WQ" ] || [ "$query" = "exit" ] || [ "$query" = "quit" ] || [ "$query" = ":q" ] || [ "$query" = ":wq" ]; then
if [ -z "$query" ] || \
[ "$query" = "q" ] || [ "$query" = "Q" ] || \
[ "$query" = "wq" ] || [ "$query" = "WQ" ] || \
[ "$query" = "exit" ] || [ "$query" = "quit" ] || \
[ "$query" = ":q" ] || [ "$query" = ":wq" ]; then
echo "Goodbye!"
exit
fi
# clean query
query=$(echo "$query" | \
sed \
query=$(sed \
-e 's|+|%2B|g'\
-e 's|#|%23|g'\
-e 's|&|%26|g'\
-e 's| |+|g')
-e 's| |+|g' <<< "$query")
# fetch info from results page
getResults() {
@ -147,9 +156,9 @@ chooseNPlay() {
choice=$(echo "$results" | $finder)
if [ -z "$choice" ]; then echo "Goodbye!"; exit; fi # if no choice then exit
if [ "$player" = "youtube-dl" ]; then
echo " "; echo "Downloaded song(s) will be placed in:${YELLOW} $downloadDir ${NC}"; echo " "
echo " "; echo -e "Downloaded song(s) will be placed in:${YELLOW} $downloadDir ${NC}"; echo " "
$player "https://soundcloud.com$choice" -o "$downloadDir/$choice.mp3"
else echo " "; echo "Press ${YELLOW}CTRL + C${NC} at any moment to abort and go back to the song picking screen."; echo " "
else echo " "; echo -e "Press ${YELLOW}CTRL + C${NC} at any moment to abort and go back to the song picking screen."; echo " "
$player "https://soundcloud.com$choice"
fi
chooseNPlay

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
# Copyright (C) 2021 mirk0dex
# Copyright (C) 2021-2022 mirk0dex
# <mirkodi.tech>
#
# This program is free software: you can redistribute it and/or modify
@ -16,11 +16,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# SONARiS: a script that lets you listen to tha SoundCloud from your CLI.
# SONARiS POSIX: a script that lets you listen to tha SoundCloud from your CLI.
#
# Deps:
# bash, GNU sed, grep (replaceable with rg), some fuzzy finder (default
# being fzf), curl, a music player (default is mpv) and youtube-dl
# A POSIX-compliant shell, GNU sed, grep (replaceable with rg), some fuzzy
# finder (default being fzf), curl, a music player (default is mpv) and
# youtube-dl
## SETTINGS ######################################################################################
@ -48,7 +49,7 @@ foobar"
## MAIN VARIABLES ################################################################################
# this is the current version of the program
version="Beta 1.0.1 - Codename sus"
version="Stable 1.0.1 - Codename Mutahar_sus"
# define a couple coloUrs
YELLOW='\033[1;33m'
@ -58,30 +59,37 @@ NC='\033[0m' # no colour
##################################################################################################
# print help screen if needed
# print help screen if needed/requested
helpMe() {
echo "
SONARiS - BASED CLI SoundCloud client and downloader [Version $version]
printf "
SONARiS - DEPRECATED CLI SoundCloud client and downloader [Version %s]
Usage: ./sonaris.sh
./sonaris.sh [options] [option stuffs...]
Usage:\t%s
\t%s [options] [option stuffs...]
SONARiS is a script which allows you to listen to your favourite songs, albums made by the artists you love.
It does so using the amazing MPV and youtube-dl programs and some other nice tools.
SONARiS is a script which allows you to listen to your favourite songs, albums
made by the artists you love. It does so using the amazing MPV and youtube-dl
programs and some other nice tools.
To make it your own and configure it, just open up 'sonaris.sh' in your favoUrite text editor :D.
To make it your own and configure it, just open up 'sonaris.sh' in your
favoUrite text editor :D.
This is free software licensed under the GPL 3.0 license. If you didn't receive a copy of it along with this program, check out <https://www.gnu.org/licenses/>.
This is free software licensed under the GPL 3.0 license. If you didn't receive
a copy of it along with this program, check out <https://www.gnu.org/licenses/>.
NOTE: This version of SONARiS is DEPRECATED, please use the POSIX version
instead (./sonaris.sh).
Options:
-h, --help prints this help screen and exits
-s, --search [query] search on SoundCloud
-d, --download download a song instead of listening to it
-f, --favs pick an artist from a list (you can choose which to show by editing the script, trust me, it's ez af)
-v, --version prints program version and exits
-h, --help\t\tprints this help screen and exits
-s, --search [query]\tsearch on SoundCloud
-d, --download\tdownload a song instead of listening to it
-f, --favs\t\tpick an artist from a list (you can choose which to show by
\t\t\tediting the script, trust me, it's ez af)
-v, --version\t\tprints program version and exits
[Author: mirk0dex <mirkodi.tech>]
"
[Author: mirk0dex <mirkodi.tech>]\n
" "$version" "$0" "$0"
}
@ -91,7 +99,7 @@ case $1 in
-h|--help) helpMe
exit;;
-s|--search) if [ -z "$2" ]; then
echo "${RED}Error${NC}: please specify what to search for. See ${YELLOW}--help${NC} for more info."
echo "${RED}Error${NC}: please specify what to search for.\nSee ${YELLOW}--help${NC} for more info."
exit 100
else
query="$2"
@ -118,17 +126,22 @@ enterQuery() {
enterQuery
# exit when necessary/asked to
if [ -z "$query" ] || [ "$query" = "q" ] || [ "$query" = "Q" ] || [ "$query" = "wq" ] || [ "$query" = "WQ" ] || [ "$query" = "exit" ] || [ "$query" = "quit" ] || [ "$query" = ":q" ] || [ "$query" = ":wq" ]; then
if [ -z "$query" ] || \
[ "$query" = "q" ] || [ "$query" = "Q" ] || \
[ "$query" = "wq" ] || [ "$query" = "WQ" ] || \
[ "$query" = "exit" ] || [ "$query" = "quit" ] || \
[ "$query" = ":q" ] || [ "$query" = ":wq" ]; then
echo "Goodbye!"
exit
fi
# clean query
query=$(sed \
query=$(echo "$query" | \
sed \
-e 's|+|%2B|g'\
-e 's|#|%23|g'\
-e 's|&|%26|g'\
-e 's| |+|g' <<< "$query")
-e 's| |+|g')
# fetch info from results page
getResults() {
@ -145,9 +158,9 @@ chooseNPlay() {
choice=$(echo "$results" | $finder)
if [ -z "$choice" ]; then echo "Goodbye!"; exit; fi # if no choice then exit
if [ "$player" = "youtube-dl" ]; then
echo " "; echo -e "Downloaded song(s) will be placed in:${YELLOW} $downloadDir ${NC}"; echo " "
echo " "; echo "Downloaded song(s) will be placed in:${YELLOW} $downloadDir ${NC}"; echo " "
$player "https://soundcloud.com$choice" -o "$downloadDir/$choice.mp3"
else echo " "; echo -e "Press ${YELLOW}CTRL + C${NC} at any moment to abort and go back to the song picking screen."; echo " "
else echo " "; echo "Press ${YELLOW}CTRL + C${NC} at any moment to abort and go back to the song picking screen."; echo " "
$player "https://soundcloud.com$choice"
fi
chooseNPlay