commit f6f4ee5396ea0c0b0291b62bc1e2e4d2af431b79 parent 4c4d18d0a055971a0fe5cfdeca2f88d6c081008a Author: Alex Balgavy <a.balgavy@gmail.com> Date: Fri, 13 Jan 2017 15:28:10 +0100 Wrote a program for iTunes genre organization Will automatically set genres using Discogs.com Diffstat:
A | itunes_style_getter | | | 6 | ++++++ |
A | itunes_style_getter_helper.rb | | | 11 | +++++++++++ |
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/itunes_style_getter b/itunes_style_getter @@ -0,0 +1,6 @@ +#!/bin/bash +artist=`osascript -e "tell application \"iTunes\" to return artist of selection"` +album=`osascript -e "tell application \"iTunes\" to return album of selection"` +style=$(ruby /Users/alex/.bin/itunes_style_getter_helper.rb \"$artist\" \"$album\") +echo $style +osascript -e "tell application \"iTunes\" to set the genre of every track whose album is \"$album\" to \"$style\"" > /dev/null diff --git a/itunes_style_getter_helper.rb b/itunes_style_getter_helper.rb @@ -0,0 +1,11 @@ +require "discogs-wrapper" + +query="#{ARGV[0]} #{ARGV[1]}" +wrapper=Discogs::Wrapper.new("iTunesStyleGetter", user_token: "uTZcIvlAFxZzteceXTKJlZLRgSJhbiJCOBIjZIbx") +search=wrapper.search("#{query}") +search.results.each do |result| + if result.style? + puts result.style[0] + break + end +end