Last active
June 3, 2020 03:04
-
-
Save hisaac/f24cb04622a21ebb799c4b6c753dc63e to your computer and use it in GitHub Desktop.
A hyper-specific AppleScript for putting on the clipboard a list of album artists in the currently selected playlist in Music.app in a format used for an "Action" in Feedbin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
This script, like most, was created to scratch a very particular itch. | |
I am a lover of RSS, and a lover of music, so I follow a few blogs that post about new music releases. | |
Most of the releases I'm not interested in, but I am interested in releases by artists that I'm already familiar with. | |
I've got a playlist in Music containing the artists I'm most interested in, and these are the ones I want to follow. | |
I use Feedbin as my RSS feed aggregator (highly recommended by the way). | |
Feedbin has the ability to perform "Actions" on feed items as they arrive. | |
I have a custom action built that marks any item as "read" that does not contain an artist that I want. | |
The problem is, this list needs to be updated every once in a while, as my tastes change. | |
It's a pain to do by hand, previously involving multiple tricks and hacks in addition to some manual editing. | |
So, I finally decided to just hack together my own solution, which is what you see below. | |
You almost certainly won't find the entire thing useful, but maybe you'll be able to steal some bits here and there. | |
*) | |
tell application "Music" | |
set currentPlaylist to current playlist | |
set theTracks to tracks of currentPlaylist | |
set albumArtists to {} | |
repeat with theTrack in theTracks | |
set albumArtist to album artist of theTrack | |
if albumArtist is "" then | |
set albumArtist to artist of theTrack | |
end if | |
if albumArtists does not contain albumArtist then | |
set the end of albumArtists to albumArtist | |
end if | |
end repeat | |
set AppleScript's text item delimiters to "\" OR \"" | |
set albumArtistsText to ("title:(NOT(\"" & albumArtists as text) & "\"))" | |
set the clipboard to albumArtistsText | |
set theDialogText to "The action has finished. The following output has been placed lovingly on your clipboard:" & return & return & albumArtistsText | |
display dialog theDialogText buttons {"OK"} default button "OK" | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment