dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit c188d3eb571defa7b2266b13b9fc7351ddb61a75
parent 34af9956ccb8d47ef9baa216b2f52190fd9c461c
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Wed,  6 Jan 2021 23:54:10 +0100

discogs & it-style: rewrite to allow discogs to fetch album name

Diffstat:
Mscripts/discogs | 10++++++++++
Mscripts/it-style | 4++--
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/discogs b/scripts/discogs @@ -19,6 +19,11 @@ genres,styles=[],[] # Search for the query search=wrapper.search("#{query}") +if search.results.empty? + STDERR.puts 'discogs: no search results' + exit 1 +end + # Add the genres of the first result search.results.each do |result| if result.genre? && !result.genre.empty? @@ -48,5 +53,10 @@ url = "http://discogs.com#{search.results[0].uri}".split(" ") # 2 different separators ("~", ",") because bash result = [genres.join("~"), styles.join("~"), url] +# Unless only asking for genre, also add title +if !(ARGV.include?('-g') || ARGV.include?('--genre')) + result = [search.results.first.title] + result +end + # Send result to stdout p result \ No newline at end of file diff --git a/scripts/it-style b/scripts/it-style @@ -74,12 +74,12 @@ while :; do # If there's no album, query without an album search_url="https://www.discogs.com/search/?q="$(sed -e 's/ /%20/g' -e 's/&/%26/g' <<< "${artist%%feat*} $name") echo "Querying: \"$artist $name\" ($search_url)" - response=$(ruby $DOTFILES/scripts/discogs "${artist%%feat*}" "$name"); + response=$(ruby $DOTFILES/scripts/discogs -g "${artist%%feat*}" "$name"); else # Otherwise, add the album to query for precision search_url="https://www.discogs.com/search/?q="$(sed -e 's/ /%20/g' -e 's/&/%26/g' <<< "${artist%%feat*} $album") echo "Querying: \"$artist $album $name\" ($search_url)" - response=$(ruby $DOTFILES/scripts/discogs "${artist%%feat*}" "$album"); + response=$(ruby $DOTFILES/scripts/discogs -g "${artist%%feat*}" "$album"); fi # Remove brackets from the Ruby array