dotfiles

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

commit bc92e4e13a7f3f7684295e8ea4b845ab7e214e6f
parent 2d5af59b0b16831033cc42648ca2f9b4bcf6642c
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Thu,  3 Aug 2017 16:40:22 +0200

Modifications


Diffstat:
Ddoc2tex | 2--
Mitunes_style_getter | 16++++++++++++----
Mitunes_style_getter_helper.rb | 18++++++++++++++----
3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/doc2tex b/doc2tex @@ -1 +0,0 @@ -/Users/alex/Documents/Github/docx2tex/d2t- \ No newline at end of file diff --git a/itunes_style_getter b/itunes_style_getter @@ -3,9 +3,11 @@ artist=`osascript -e "tell application \"iTunes\" to return artist of selection" album=`osascript -e "tell application \"iTunes\" to return album of selection"`; name=`osascript -e "tell application \"iTunes\" to return name of selection"`; -# Get the style using a Ruby helper script (much easier to use the API in Ruby...) -style=$(ruby /Users/alex/.bin/itunes_style_getter_helper.rb ${artist} ${album} ${name}); -echo $style +if [ -z "$album" ]; then + style=$(ruby /Users/alex/.bin/itunes_style_getter_helper.rb "$artist" "$name"); +else + style=$(ruby /Users/alex/.bin/itunes_style_getter_helper.rb "$artist" "$album" "$name"); +fi # Parsing the array # Split the Ruby array into a Bash array, do some replacements @@ -13,10 +15,16 @@ IFS=',' read -ra style <<< "${style}" style[0]=$(echo ${style[0]} | sed -e 's/\[//') # Remove front [ style[$((${#style[@]}-1))]=$(echo ${style[$((${#style[@]}-1))]} | sed -e 's/\]//') # Remove back ] +echo "URL: $style" +delete=${style[0]} +style=( "${style[@]/$delete}" ) +style=("${style[@]:1}") + echo "You're changing the album \"$album\" by \"$artist\"" +printf '\n' echo "The options:" printf '%s\n' "${style[@]}" -echo "Would you like to use one of these?" +printf "\nWould you like to use one of these?" select yn in "Yes" "No"; do case $yn in Yes) diff --git a/itunes_style_getter_helper.rb b/itunes_style_getter_helper.rb @@ -2,14 +2,24 @@ require "discogs-wrapper" my_user_token = ENV["DISCOGS_API_TOKEN"] -query="#{ARGV[0]} #{ARGV[1]} #{ARGV[2]}" + +query=ARGV.join(" ") wrapper=Discogs::Wrapper.new("iTunesStyleGetter", user_token: my_user_token) +res=[] search=wrapper.search("#{query}") search.results.each do |result| if result.style? && !result.style.empty? - p result.style.to_a + res="http://discogs.com#{result.uri}".split(" ") + result.style.to_a.each {|x| res.push x } + break + end +end +search.results.each do |result| + if result.genre? && !result.genre.empty? + result.genre.each do |g| + res.push("#{g}") + end + p res exit end end - -p search["results"][0].genre[0].split(",")