GithubHelp home page GithubHelp logo

caleb531 / play-song Goto Github PK

View Code? Open in Web Editor NEW
106.0 5.0 9.0 2.98 MB

An Alfred workflow for quickly and easily playing music in the Apple Music app

License: MIT License

AppleScript 91.73% Shell 8.27%
applescript itunes alfred alfred-workflow

play-song's Introduction

Play Song

Copyright 2013-2024 Caleb Evans
Released under the MIT license

Play Song is an Alfred workflow designed to make playing music in Music.app extremely quick and convenient.

The workflow will be solely supporting Alfred 5 going forward, but the workflow versions last compatible with the previous versions of Alfred will remain available here for your convenience.

Play Song in action

Special thanks to @Tyilo for his invaluable feedback and code contributions.

Usage

Play Song includes a number of keyword filters which allow you to search for and play songs in your Music.app library. For example:

Playing a song

playsong hey jude

Playing a song in a particular album

playsongin abbey road

Playing a song by a particular artist

playsongby beatles

Playing an album

playalbum pet sounds

Playing an album by a particular artist

playalbumby beach boys

Playing an artist

playartist killers

Playing a genre

playgenre alternative

Playing a playlist

playplaylist favorites

Controlling the Music app's global shuffle setting

shuffleon
shuffleoff
shuffletoggle

Queueing songs

For any of the above filters, choosing a result with the cmd key held down will queue the result (as opposed to playing it immediately). This allows you to queue up multiple songs before playing them.

To play the songs you've queued, use the playqueue keyword. To clear the queue of all songs, use the clearqueue keyword.

Note: At this time, Play Song does not support queueing for Apple Music playlists.

Searching songs on Google

For any of the above filters, choosing a result with the ctrl key held down will search the result on Google.

Clearing the cache

Play Song stores a local cache containing album artwork (from displayed results), as well as the compiled workflow configuration. If you experience any issues with Play Song, you can clear this cache via the clearcache keyword.

A note about play order

Play Song always respects the current shuffle mode within Music.app. For example, if shuffle is enabled, playing an album via Play Song will play the songs of the album in shuffled order. Therefore, if you desire Play Song to respect album order, run the shuffleoff command within Alfred.

Additionally, Play Song will honor the column you are sorting by in Music.app to sort queued songs. This applies to keyword filters like playartist, playalbum, and playgenre. For example, if you are sorting by "Album by Artist" in your library, then Play Song will group artists together and group albums together when using playgenre. However, if you are sorting by "Title" in your library, then Play Song will disregard album groupings and simply play songs in alphabetical order.

The playplaylist filter is the only Play Song filter where play order is guaranteed.

Playing a song directly (the Play Song v1 behavior)

If you are a longtime Play Song user who prefers the v1 behavior for playing songs (where music continues playing after the song finishes), you can do so via the shift modifier. Note that this only works for the playsong filter.

Support

If you have a bug to report or a feature to request, please submit an issue on GitHub. You can also contact me directly via email.

play-song's People

Contributors

caleb531 avatar tyilo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

play-song's Issues

Play any song without using alfred playlist (iTunes resumes on existing playlist)

I had used an old version of this plugin (version 2.x?) and it had the capabilities of playing any song within itunes immediately and then itunes would continue on where it left off. This was a great workflow for me as sometimes I would just want to hear a specific song, and afterwards itunes would continue playing in the manner it was before (i.e., in a playlist).

I had updated to the latest version and noticed songs can be queued up and would placed in an alfred playlist. The issue here is when the song would finish itunes wouldn't go back to the old playlist.

I'm just putting this out here but this the new action I put for playsong

on loadConfig()
    return (load script POSIX file (do shell script "./resources/compile-config.sh"))
end loadConfig

on run query
    set config to loadConfig()

    set typeAndId to parseResultQuery(query as text) of config
    set theType to type of typeAndId
    set theId to id of typeAndId

    set theSong to getSong(theId) of config

    log theSong

    tell application "iTunes" to play theSong
end run

Essentially I just want to tell iTunes to play the selected song. No playlist stuff to worry about and modify.

@caleb531 you can close this if you want. I was just putting this up as it was something that had existed in the past, just incase someone stumbles upon they can use this custom action. If its something you see benefit in having as an alternative action (i.e., alt for playsong) that works as well.

Better sorting of results

Results should not be sorted alphabetically, but by the relevance.

Example:

I would expect "OK Computer" to come before "Bookends", because "ok" is in the middle of "Bookends" and is in the beginning of "OK Computer".

I suggest sorting like so (assuming that there are no spaces in the query):

  1. Output all results beginning with the query
  2. Output all results having a word that begins with the query
  3. Output all results containing the query
  4. Output all remaining results

Error about config.scpt when using

I'm getting the following error in the debug when attempting to search for a song using the playsong command... is there a setup step I missed? I simply downloaded the .alfredworkflow file and installed it. I attempted to clearcache, but no improvement.

[ERROR: input.scriptfilter] Code 1: filters/playsong.applescript:48:120: execution error: Can’t make file "Macintosh HD:Users:matthew:Library:Caches:com.runningwithcrayons.Alfred-3:Workflow Data:com.calebevans.playsong:config.scpt" into type file. (-1700)

Play song in current playlist, and continue through the playlist

If I'm playing a playlist in iTunes, is it possible to use this workflow to play a specific song from this playlist, and once that song is done, then cede control back to iTunes and continue playing the playlist like normal?

Because right now, this workflow creates a new playlist with just the song that I chose, therefore playing it indefinitely.

Queue isn't working?

Hi, first of all a huge thx this really is an incredible workflow!

Queueing songs:For any of the above filters, choosing a result with the cmd key held down will queue the result (as opposed to playing it immediately).

it dosent seem to Abe working here ? Ii press cmd it does show in alfred queue song but then i press enter (while CMD is pressed) it doesn't seem to queue.

on latest catalina and music app

would be happy to help debug

thx a bunch

Z

Request: Play Album of Currently Playing Song

I find myself putting my whole song library on random and I'd love to be able to have iTunes start playing the whole album of the currently playing song (when that song reminds of you the awesome album, of course). Could something like this be added to play-song?

Allow songs search into Apple Music

Hello,

It seems that playsong [song title] is only searching in my library. It would be great that for Apple Music subscribers, the search happens in Apple Music, so you could almost play every song that exists, and not only those you added to your library.

Very nice workflow by the way ;-) .

Idea: remove `play` keyword in favor of `playsong`

I'm about to propose a major change to the workflow. I would very much appreciate your input, @tyilo. :)

Proposal

  • Remove the play filter in favor of the existing playsong filter

Arguments for the change

  • The play filter behaves inconsistently compared to all other filters apart of the workflow
    • play searches all attributes of an item, whereas all other filters search by name only
    • play cannot reuse the same filtering logic which all other filters can utilize
  • The search scope for play is ultimately too broad to be practical
  • With the addition of new keywords (playsong, playalbum, etc.) in v2.0, the name play becomes ambiguous

Arguments against the change (and counterarguments)

  • Removing the play keyword would break backwards-compatibility
    • I realize that this would be the case, and so I would promote Play Song to v3.0
    • Coalescing the play filter removal with the upcoming changes to sorting behavior may further justify the major version bump

Thoughts?

Feature request: play only rated songs from artist?

Hi again

the more i play around with this workflow i learn out how awesome it is.. :)

is it possible to tot add a feature request so that there could be a new command to play only rated songs from artist?

ie a user define threshold (rating >=4) and then only songs >=4 from artist plays?

thx a bunch!!

z

playgenre adds songs by album and not by genre onlly

It seems that if I use the playgenre keyword songs will get added on a per album basis, i.e. if at least one song in the alum fits the genre, then the whole album gets added to the playlist instead of only the songs that fit the genre. Is that intended behavior? Many thanks for the awesome workflow though.

Workflow plays song/artist randomly instead of what was requested

Hey, this workflow seems straightforward and I'm sure it's working great for many others.

But, so far, every time I've tried it, it will just randomly play some song from my Library...but not the one I'm asking for. It performs the same way when I try to play a particular artist.

Is there something I'm missing?

After song ends nothing happens.

When I turn on a song via "ps", when the song ends, the song doesn't repeat itself, despite the music app settings. Is it possible to do something so that after the end of the song turned on via "ps" the song repeat settings in the application are respected?

Expected class name but found identifier

I just installed playsong on alfred 4 and I have such an issue:

[02:19:31.162] Logging Started...
[02:19:41.041] Play Song[Script Filter] Queuing argument 't'
[02:19:41.196] Play Song[Script Filter] Script with argv 't' finished
[02:19:41.199] ERROR: Play Song[Script Filter] Code 1: filters/playgenre.applescript:435:440: script error: Expected class name but found identifier. (-2741)
[02:19:41.235] Play Song[Script Filter] Queuing argument 'te'
[02:19:41.386] Play Song[Script Filter] Script with argv 'te' finished
[02:19:41.389] ERROR: Play Song[Script Filter] Code 1: filters/playgenre.applescript:435:440: script error: Expected class name but found identifier. (-2741)

Doesn't work on Mojave 10.14.2

Hi! I'm a new Mac-User who just bought my mac a week ago.
I just got Alfred and found out your wonderful workflow that would be just ever so helpful if it worked.

Error 1: Searches well w/ "playsong" but other commands like "playalbum" "playartist" doesn't work
Error code 1-1:
[2018-12-18 20:37:17][ERROR: input.scriptfilter] Code 1: filters/playalbum.applescript:429:524: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose album = "18 Hits" and kind contains songDescriptor of «script». (-1728)
[2018-12-18 20:37:18][ERROR: input.scriptfilter] Code 1: filters/playalbum.applescript:429:524: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose album = "Buzz 4ever (Digital Single)" and kind contains songDescriptor of «script». (-1728)
[2018-12-18 20:37:18][ERROR: input.scriptfilter] Code 1: filters/playalbum.applescript:429:524: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose album = "Buzz 4ever (Digital Single)" and kind contains songDescriptor of «script». (-1728)

Error Code 1-2:
[2018-12-18 20:38:48][ERROR: input.scriptfilter] Code 1: filters/playartist.applescript:437:534: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose artist = "ABBA" and kind contains songDescriptor of «script». (-1728)
[2018-12-18 20:38:48][ERROR: input.scriptfilter] Code 1: filters/playartist.applescript:437:534: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose artist = "BUZZ" and kind contains songDescriptor of «script». (-1728)
[2018-12-18 20:38:49][ERROR: input.scriptfilter] Code 1: filters/playartist.applescript:437:534: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose artist = "BUZZ" and kind contains songDescriptor of «script». (-1728)
[2018-12-18 20:38:50][ERROR: input.scriptfilter] Code 1: filters/playartist.applescript:437:534: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose artist = "BUZZ" and kind contains songDescriptor of «script». (-1728)

Error 2: Doesn't play music. No response after hitting "return."
Error Code 2:
[2018-12-18 20:23:27][ERROR: action.script] actions/play.applescript: execution error: iTunes got an error: Can’t get track 1 of playlist 2 whose database ID of it = "7222" and kind of it contains "audio". (-1728)

Error 3: Command "playplalist" fails to bring up anything in search.
Error Code 3:
None! Didn't show up any debug errors.

It would be great if you can tell me how to get your workflow working. This will make my life much easier :)

playplaylist shows no result when there are too many matches

I have a lot (>30) of playlist that start with "Best-Of:".
When using playplaylist, no result is shown until I limit the matches, e.g "Best-Of: R". Following error is given while typing Best-Of:

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 1660:1671: execution error: The variable resultLimit is not defined. (-2753)

None of the commands work

As of the v2 release none of the commands seems to work, they all return an empty list, so that you can't choose a song/album/etc. to play.

searching for songs in playlist

hi i was wondering if there was a way to specifically search for a song thats in my playlsit. That way when i do chose that song and it finishes playing my playlist continues playing as normal and doesnt give me random songs.

Cannot play music for non-English systems

Starting debug for 'Play Song'

[ERROR: alfred.workflow.input.scriptfilter] Code 0: 2015-01-21 01:09:33.613 osascript[2332:345183] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
[ERROR: alfred.workflow.input.scriptfilter] Code 0: 2015-01-21 01:09:34.348 osascript[2339:345206] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
[ERROR: alfred.workflow.input.scriptfilter] Code 0: 2015-01-21 01:09:38.992 osascript[2360:345334] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
[ERROR: alfred.workflow.action.script] Code 1: 2015-01-21 01:09:41.505 osascript[2367:345357] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
execution error: System Events got an error: Can’t get menu bar item "Controls" of menu bar 1 of process "iTunes". (-1728)

Like / add to music actions (feature request)

I really love your workflow ! great work.

I find myself however missing some features, although I'm aware that this workflow is geared towards playing and queuing songs it would be great if the following use-cases could be implemented in this workflow. Note that some of those probably only apply to Apple music subscribers.

  1. Liking / disliking the current playing song
  2. Play more like this / Play less like this (great when you are listening to a artist/song radio)
  3. Add to My Music

I'm no apple script expert, But I'm certainly willing to help out with this. Let me know what you think of the proposed features.

Combine all actions into one

I think we should combine all actions into one script, where the argument to the script would be prefixed with song-, album-, genre- etc., which would then be used to play the correct type of content.

This would allow filters which returns different kinds of items, eg. both songs and albums. This could maybe be used to create an unified play filter script.

This would also simplify updating the action using the python script.

Another thing, would it be possible to make the user choose multiple level of options like a menu?
For example I might want to play an album by BandX, but I don't remember the album name, so I would type playalbumby Band, where both BandX and BandY would appear as options.
I would then choose BandX and be presented with a list of all of BandX's albums. When I have chosen one of these it play-song would play that album.

Propose Logo

Hi @caleb531 ,I'm a graphic designer and an open source enthusiast. I would like to contribute to your project by proposing a logo design and I've designed a logo for you. If you like it you can use it. If you have an idea please share with me, it would be better for me. Thank you.
Best Regard.
play song

Feature Request: Universal Search of Artist, Album, and Song Title.

I used to love an app called Coversutra and your script is by far to closest to how it used to work.

One thing that I loved was the simplicity of invoking a hotkey and having my search text return all matches for artists, albums, and song titles, all co-mingled in one giant result. It would show the artist, album (with cover art), and song title in the results. And furthermore, the results would be "bundled" in a pretty logical way. Any albums under the same artist would appear successively in the results. Any songs under the same album would appear successively in the results.

Currently with your script, I've mapped 3 different hotkey combinations to launch "playsongby, "playsongin", and "playsong", but I would like one single hotkey to launch a search in all 3.

Do you think this would be possible? Thanks!

How to stop playing?

Hi, thanks for the great work! I am just wondering if we have a module for stop playing song. If not, it would be super cool to have it in the futhre.

Easier way of updating "Play Song.alfredworkflow"

Maybe you use another method, but when I need to update Play Song.alfredworkflow for testing I have to copy and paste the changed applescripts into Alfred's workflow editor.
I think I could easily make a script that does this automatically, should I do that?

Playback stops after ~25-seconds after "play playlist" on a Apple Music Playlist

Playback stops ~10-45 seconds after using workflow "play playlist" on an Apple Music Playlist.

Running itunes 12.7.5.9
macos 10.13.4
2017 mbp 13" non-touchbar

Repro Steps:

  1. Add all of these Apple Music Playlists to your iTunes Library:
> open "itmss://itunes.apple.com/us/playlist/primavera-sound-2018-barcelona/pl.9d153d7b2bc94e5983a510115cdc2410"
> open "itmss://itunes.apple.com/us/playlist/pure-yoga/pl.6e7eb6c06bcd40ec982e24d6af0cd59a"
> open "itmss://itunes.apple.com/us/playlist/the-a-list-dance/pl.6bf4415b83ce4f3789614ac4c3675740"
  1. Click +ADD from within iTunes for the Apple Music Playlist
  2. In iTunes observe playlist now appears in "Apple Music Playlist"
  3. In alfredapp try "play playlist"
  4. Observe "Alfred Play Song" is populated in iTunes under 'Music Playlists'
  5. Playlist starts and first song plays.
  6. Observe stops after n-seconds (time varies)
  7. "Alfred Play Song" Playlist becomes 'empty'

Adding to workflow

Hey I appologize for the silly question but how exactly do i add this to workflow. Thank you

Respect current shuffle setting

Hi, @tyilo. I have an idea for Play Song that I'd like to discuss with you.

Currently, Play Song forcefully disable shuffle mode before playing its queue in iTunes. This ensures that albums/playlists always play in the correct order. However, I am beginning to realize that forcefully disabling shuffle was not the best approach when I initially wrote v2.0. Therefore, I propose that we update the workflow to respect the current shuffle setting for the following reasons:

  1. Play Song would no longer require access to assistive devices
  2. Some iTunes users prefer to always or sometimes play albums/playlists on shuffle
  3. Play Song cannot disable shuffle for non-English systems anyway (recall issue #24)

As always, I welcome your feedback before I proceed to implement this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.