Jump to content
smirky

DJ Pedro - iTunes playlist based on Last.fm similar artists

Recommended Posts

DJ Pedro - Create iTunes playlist based on Last.fm similar artists

(Updated 10/11/2015 - Fix for broken Last.fm API links)

 

This workflow uses the Last.fm API for "similar artists" to create and play a playlist based on either the artist of the currently playing song or an artist searched for within the local iTunes Library. The workflow does not require that you use Last.fm, it only pulls information from their database using their API. (i.e., no scrobbling required.)

 

DJ Pedro now lives on the wonderful Packal repository. The best reason for you to get this version is that Packal will handle tracking any future updates so you no longer need to watch this thread.

 

Get the Packal version here

 

The workflow is triggered by a hotkey or the keyword "dj", and if an argument is added the workflow searches your iTunes library for artists that match the query.

 

NEW: I added a couple Alfred Remote triggers to the workflow, the best one allows you to create a DJ Pedro playlist from anywhere in your house via the currently playing iTunes track. This is a feature I have wanted since originally creating the workflow. :-)

You can add the individual trigger(s) to your own custom Remote page or use the DJ Pedro Remote Page. It's fairly minimal at the moment, but I'm considering adding a Favorites feature since we can't yet type directly into an Alfred window via the remote.

 

NEW: If you use my Last.fm and/or Discogs workflows you can now trigger those from results in DJ Pedro's Suggested Artist list using modifier keys. I tend to think that's pretty sweet.

Initial%20WIndow.pngSearching.png?raw=true

Suggested%20Artist%20List.png
Settings for the workflow can be modified by triggering the "djprefs" script filter. Available modifications are:

  • Playlist name
  • Number of tracks in the created playlist
  • Search limit for 'similar artists' the workflow requests from Last.fm.
  • Maximum tracks per artist added to the playlist.
  • Enable/disable the notification that lists any artists suggested by Last.fm that were not found in your Library.

Prefs%20Window.png

Credits/Acknowledgments:

  • Much of the script for displaying artists and their artwork was borrowed from the great "Play Song" workflow, by "caleb531", which you should download if you don't have it yet.
  • Additional scripting was improved by using the qWorkflow library developed by "ursanrazvan".
  • Yes, DJ Pedro is named after our cat.

Notes:

  • This workflow creates a folder in your iTunes folder called "Alfred Album Artwork" for easy access to album artwork icons. This folder should be extremely small and is easily deleted if you delete the workflow.

Known/Possible Issues:

  • Because of the way iTunes 11 handles playlists, there's a pause/un-pause coded into DJ Pedro at the start of playback. If Apple ever provides a better way to deal with Up Next, besides GUI scripting, I'll update this.

 

I'm an amateur coder, so please be kind to my messy code, etc. Constructive criticism is greatly appreciated!
I hope this workflow helps you enjoy your music a little bit more.

Edited by smirky

Share this post


Link to post

Glad you guys like it!

 

I made a small update to add Alleyoop support. Re-downloading from the links above should get you the new version.

Share this post


Link to post

Very cool stuff. 

 

I'm getting the slightly-more-than occasional "Oops...something went wrong, try adjusting your settings" message. May be my slightly-more-than different taste in music, so I am not too worried about that.

 

And I'm happy to report it works fine and dandy with iTunes Match. Seamless.

Share this post


Link to post

Thanks for the feedback Joe! Glad (and surprised) to hear that it works with Match (bonus!)

 

I'm getting the slightly-more-than occasional "Oops...something went wrong, try adjusting your settings" message. May be my slightly-more-than different taste in music, so I am not too worried about that.

 

That message is technically sent out by a timeout in the script (60 seconds). Does it seem to happen for specific artists more often? There's a small amount of randomness in the script (to keep the playlists fresh each time) that might cause it to not happen every time for the same artist.

 

What's really going on that might trigger a timeout:

The default setting is for DJ Pedro to ask Last.fm for their first 40 'similar artists' to your initial selection. If he isn't able to find enough from that list of 40 in your iTunes library, he asks Last.fm about any similar artists to the ones he's added to the playlist from that initial list of 40. This sort of recursive behavior repeats until he either adds enough songs to the playlist or the workflow times out.

 

I've updated the workflow (same link at top) so that the timeout takes a little longer to trigger (120 seconds), in case the issue is just a slower internet connection for receiving Last.fm results. I only had my computer to test this on, so I'll probably need to adjust a few things to make it easier for more folks. If that doesn't fix it, try increasing the setting for 'the number of similar artists requested' to something like 50 or 60 and see if that helps at all.

 

Also, yeah, Last.fm doesn't have the greatest database for all types of music. So, YMMV, unfortunately.  :wacko:

Share this post


Link to post

Thanks for the feedback Joe! Glad (and surprised) to hear that it works with Match (bonus!)

 

 

That message is technically sent out by a timeout in the script (60 seconds). Does it seem to happen for specific artists more often? There's a small amount of randomness in the script (to keep the playlists fresh each time) that might cause it to not happen every time for the same artist.

 

What's really going on that might trigger a timeout:

The default setting is for DJ Pedro to ask Last.fm for their first 40 'similar artists' to your initial selection. If he isn't able to find enough from that list of 40 in your iTunes library, he asks Last.fm about any similar artists to the ones he's added to the playlist from that initial list of 40. This sort of recursive behavior repeats until he either adds enough songs to the playlist or the workflow times out.

 

I've updated the workflow (same link at top) so that the timeout takes a little longer to trigger (120 seconds), in case the issue is just a slower internet connection for receiving Last.fm results. I only had my computer to test this on, so I'll probably need to adjust a few things to make it easier for more folks. If that doesn't fix it, try increasing the setting for 'the number of similar artists requested' to something like 50 or 60 and see if that helps at all.

 

Also, yeah, Last.fm doesn't have the greatest database for all types of music. So, YMMV, unfortunately.  :wacko:

 

One artist I was seeing it a LOT with was "John Butler Trio". Fairly obscure, but good :-)

 

I'll try the longer timeout and let you know. As I recall, though, I was getting that error pretty much instantly with that artist. Very likely more of a last.fm problem than a DJ Pedro problem.

 

If I go to this page http://www.last.fm/music/The+John+Butler+Trio/+similar, I see that I have no of the artists that last.fm considers similar except for maybe some Ben Harper, so your scenario seems pretty likely.

 

Thanks. Really enjoying the workflow. It's helping me rediscover the music I own.

Share this post


Link to post

One artist I was seeing it a LOT with was "John Butler Trio". Fairly obscure, but good :-)

 

I'll try the longer timeout and let you know. As I recall, though, I was getting that error pretty much instantly with that artist. Very likely more of a last.fm problem than a DJ Pedro problem.

 

If I go to this page http://www.last.fm/music/The+John+Butler+Trio/+similar, I see that I have no of the artists that last.fm considers similar except for maybe some Ben Harper, so your scenario seems pretty likely.

 

Thanks. Really enjoying the workflow. It's helping me rediscover the music I own.

 

Super happy that it's helping you rediscover things; I'm having the same reaction and it's pretty fun to see how this workflow is doing just what I hoped it would (and iTunes Genius seems to fail at for me).

 

Also, thanks for the heads-up about the error. That definitely sounds like you just need more artists 'similar' to John Butler Trio. ;)  Your playlist probably populates with a couple tracks, which avoids the "Sorry, DJ Pedro couldn't find anything at all" error, but then spins it's wheels because it can't find enough to fill a playlist entirely.

 

I think I'll work on an option/update to add more than one track per artist to help avoid this error. That shouldn't be too difficult to incorporate.

Share this post


Link to post

I discovered a fun little issue when I moved my iTunes library to an external drive. Ol' Pedro couldn't find my music.

 

It may be worth adding an optional configuration option to tell Pedro where to look, but I was able to solve it by simply going to my Music folder in Terminal and typing:

 

ln -s /Volumes/Backup/iTunes 

 

Now DJ Pedro is happy.

Share this post


Link to post

I discovered a fun little issue when I moved my iTunes library to an external drive. Ol' Pedro couldn't find my music.

 

It may be worth adding an optional configuration option to tell Pedro where to look, but I was able to solve it by simply going to my Music folder in Terminal and typing:

 

ln -s /Volumes/Backup/iTunes 

 

Now DJ Pedro is happy.

 

Nice catch. I'll double-check how DJ Pedro asks for the user's actual music folder location and I may need to have him look more generally if he only looks for the local Media folder.

Share this post


Link to post

Just pushed an update to github that allows your playlist to include more than one track per artist. The default maximum is 5 possible tracks per artist, but this is configurable in "djprefs". This should help reduce the amount of "Oops!" errors shown when DJ Pedro isn't able to find many similar artists in your library.

 

You'll probably want to tweak this to your liking, but here's a couple possible set-ups:

  • Lots of tracks by only a few artists: Set your repeat amount to something like 5 or more, and the Last.fm 'search limit' to something small like 10 or 20.
  • Only a couple tracks by many different artists: Set your repeat amount to something low (1-2), and the Last.fm 'search limit' higher (>30).

I'll likely add a separate repeat limit for the original selected artist soon, but I thought I'd let you guys play with this first and let me know how it works.

 

The link at the top of the page should go to the new version on github, but here it is as well . I assume the Alleyoop updater is working too, if you have that installed.

Edited by smirky

Share this post


Link to post

Pushed another update to github; here's the direct link which is the same as at the top of the page. Thanks to the folks giving me suggestions and help purging errors.

 

Summary of changes:

v1.04 -

  • If DJ Pedro determines that you have low similar-artist counts in your iTunes Library, he chooses to fill up your playlist with whatever artists he as able to find, regardless of your repeat settings, and plays what he was able to find, instead of just quitting the workflow. 
  • Hold down modifier key 'alt' when selecting your initial artist, and DJ Pedro will create a separate playlist for you to view without starting to play it. This lets you see what DJ Pedro thinks would be a good playlist, without affecting what you're currently listening to.

Share this post


Link to post

Just bumping this for anyone that would like to know of another big update to this workflow. I've updated the original post with a new screenshot and info, but here's the summary for version 1.2:

 

  • DJ Pedro now provides feedback of his progress in Alfred. Some may find this useful on slower machines, slower internet connections, or if you just enjoy having too much information.
  • Also, once DJ Pedro has completed your playlist, he will provide a list of similar artists in Alfred that you can click to learn more, in your browser of choice. The items are set to open Last.fm's given artist page, but you can modify this very easily to go to your favorite music discovery/purchasing site. Simply modify the "Open URL" item in this workflow similar to how you would create a Custom Search in Alfred's general Preferences.
  • There are two separate settings in "djprefs" to enable/disable the general progress notifications and the final Suggested Artist list.

Many thanks to @bgartner for help flushing out this idea and generally helping find bugs!

 

As usual, feedback is greatly appreciated!

Share this post


Link to post
Hi smirky!

 

I love your workflow and I use it all the time - thank you for that :)

 

I have one question though: would it be possible for DJ Pedro to create a playlist for Spotify?

I'm asking because the best part about Last.fm (for me) is discovery - right now DJ Pedro can only use stuff I already own and know to create a playlist.

If Pedro could make a playlist based on the massive catalogue of Spotify, that would be truly awesome.

 

I would be perfectly happy if Pedro could just spit out a plain text list (artistname - trackname), then I could go to Ivy and convert that list into a Spotify playlist myself.

 

Just in case you get really bored at some point in the future and need a crazy project to work on... ;D

 

Cheers, Anna

Share this post


Link to post

Hi Anna,

 

Thanks for the kind words; I'm glad DJ Pedro has been helpful to you! 

 

Someone else has mentioned that using Pedro for Spotify playlists would be great, too. Having no real experience with it I'm not even certain if that's possible, although based on other workflows I think it may be. I guess it's time for me to dig in and see what I can do. I'll report back when I have some time to really look into it. My hope is that it's possible, so we'll see.

 

Also, your post reminded me that I have a pretty big update to DJ Pedro's guts that help him run much better. I had been sitting on releasing it until I could use it enough to work out the bugs, but that's long overdue. I'll post the update this weekend!

 

Thanks again!

Share this post


Link to post
Thank you for your reply, smirky :) I really appreciate that you're open to the idea! 

 

Also, it's great to hear that you've got an update coming (I have to say though that DJ Pedro is doing a flawless job already!).

 

Thanks for your continued work on this, DJ Pedro has totally replaced iTunes Genius for me :D

Cheers, Anna

Share this post


Link to post

I posted a v1.3 update to the Packal repository, here. The main thing that's great about Packal is that it will start to handle any updates to your workflows so you don't need to keep an eye on these threads all the time.

 

This update is a pretty big under-the-hood update, which I've been using on my machine for months. I hope that it works for everyone else; please let me know if you hit any snags!

 

 

@shadylane: Thanks again for your kind words and input! DJ Pedro is a great little tool in our home, and I'm glad he's been good to you too!

Edited by smirky

Share this post


Link to post

Wow, thanks a thousand times! I wasn't looking for a workflow like this, but I've been using it now quite a bit - and it's just awesome! Helps me a lot to find new music! 

Share this post


Link to post

Wow, thanks a thousand times! I wasn't looking for a workflow like this, but I've been using it now quite a bit - and it's just awesome! Helps me a lot to find new music! 

 

You're very welcome! Thanks for the kind words, I'm glad this workflow is as useful for others as it is for me. :-)

Share this post


Link to post

Bump for an Alfred Remote Update and more!
 
I created a couple triggers you can import how ever you like or just use the Remote page that I created for them. The page is fairly minimal at the moment, but I'm considering adding a Favorites feature since we can't yet type directly into an Alfred window via the remote.
 
Also, if you use my Last.fm and/or Discogs workflows you can now send results from DJ Pedro to those workflows via modifier keys. I tend to think that's pretty sweet.

 

iPad%20Remote%20Page.png

 

iPhone%20Remote%20Page.png

Edited by smirky

Share this post


Link to post

This workflow alone has made my Alfred purchase worth it. It is far superior to Genius recommendations.

 

I exclusively use Pedro to generate playlists based on the current track playing. Is it possible to have DJ Pedro use a dynamic variable as the playlist name? Something like "DJ Pedro - %current_artist% - %current_track%". Currently he overwrites the playlist specified in preferences every time.

 

Also, is there a way to contribute financially to your efforts? Your tool is useful and has definite value to me.

 

VIVA LA PEDRO!

Edited by Codec

Share this post


Link to post

Sadly, Pedro has stopped working. Debug shows the following when triggering the hotkey.

 

Quote

 

Starting debug for 'DJ Pedro'

[2017-06-15 01:21:52][ERROR: input.scriptfilter] Code 1: 3482:3495: syntax error: Can’t set «constant eMdKkMdS» to «class pTrk». Access not allowed. (-10003)

 

 

Using OSX 10.12.5, Itunes 12.6.1.25, Alfred 3.3.2 and Pedro v1.5.01

Share this post


Link to post
On 6/14/2017 at 10:27 PM, Codec said:

Sadly, Pedro has stopped working. Debug shows the following when triggering the hotkey.

 

 

Using OSX 10.12.5, Itunes 12.6.1.25, Alfred 3.3.2 and Pedro v1.5.01

Hey Codec, sorry that he's stopped working. I tried this morning and couldn't recreate your error. Can you check if there's an update to Alfred on your system that might fix the issue? A couple other follow-ups, which you may have already checked:

  • Do you get this error on any one specific artist, or have you tried multiple choices and get the same error?
  • Have you updated any software on your machine prior to getting this error? I haven't pushed an update to Pedro in a little while, so it's likely an external conflict that I will try to hunt down.

Thanks!

Share this post


Link to post
On 11/17/2016 at 10:35 PM, Codec said:

This workflow alone has made my Alfred purchase worth it. It is far superior to Genius recommendations.

 

I exclusively use Pedro to generate playlists based on the current track playing. Is it possible to have DJ Pedro use a dynamic variable as the playlist name? Something like "DJ Pedro - %current_artist% - %current_track%". Currently he overwrites the playlist specified in preferences every time.

 

Also, is there a way to contribute financially to your efforts? Your tool is useful and has definite value to me.

 

VIVA LA PEDRO!

 

Just realized I never actually replied to your earlier message - apologies for that! I read it and responded in my head but forgot to type it up. :-(

 

Regarding your suggestion, that's a great idea and in fact it's something that I built a separate workflow for myself to do already. I have been trying to think through the best way to implement it because, I imagine, a user wouldn't necessarily want every single run of Pedro to generate a new playlist. The workflow I built essentially adds a new Playlist folder ("DJ Pedro Playlists") and can save a copy of the current DJ Pedro playlist to the folder on demand via hotkey ("%current_artist% Playlist"). That way you can decide when to save one if you happen to like what Pedro gives you. It's also really easy to go through iTunes and select any of those playlist that you want synced to your device for while you're on the go. That's what we use it for in my house - generating cool new playlists for long car rides.

 

If that sounds lie something you think would be worth adding to the general Workflow release, I am more than happy to incorporate it

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...