Florian

iTunes (+ feed back info into alfred)

22 posts in this topic

Hey beautiful people,

 

It's been a while since I haven't posted anything. Mainly because what I was developing wouldn't have interested anyone ;) Oh and also, you know, sometimes I actually work.

 

But here is a little piece of code that might help some of you: something to feed back into Alfred the current playing track (name and artist) and it's rating. As well as some basic controls.

 

Screen%20Shot%202013-02-09%20at%202.31.5

 

I'm pretty sure it'd be very easy to tweak for most of you because I'm using some applescript within the bash script (thank you osascript hook =D). So please, feel free to steal that and make it awesome. Go crazy ! 

 

 

(also available on AlfPT)
 
cheers
 

Share this post


Link to post

Very cool! I wonder if this script can be leveraged to do something like share the title/album of my current track on twitter/facebook. What do you think?

Share this post


Link to post

Very cool! I wonder if this script can be leveraged to do something like share the title/album of my current track on twitter/facebook. What do you think?

 

It's definitely doable. But I'm not going to do it :-]

GamerChase likes this

Share this post


Link to post

Sharing on Twitter will be part of AlfredTweet when I release it. Still trying to figure out what all functionality I want in it. I have basic things done like, following/unfollowing people, tweeting, and the NowPlaying stuff.

Share this post


Link to post

As always nice work Florian. It would be nice to get notifications with info of musician/album/song title on track change. Cover art if possible would also be cool but probably a lot of work. Thanks for sharing! Check your messages btw... 

Share this post


Link to post

It'd be pretty cool if you could get it to work when shuffle is on as well.

 

I made some research and right now iTunes 11 is not responding to shuffle or repeat. It’s a bug.

 

But it seems to be very difficult to get the sequence of songs when played from the “Music” library. 

 

For now (and unfortunately), the “up next” and “previous” will work only when a playlist is playing.

Share this post


Link to post

I was able to “manually” get the album songs based on the current track. 

 

The efficiency of this method will depend on how organized the library is because it is based on artist and album tags.

 

Tomorrow I’ll test the code in a workflow… 

Share this post


Link to post

Any help for improvements will be appreciated.

 

In resume:

 

- The workflow works well with a custom playlist.

 

- Song playing from Library is another story:

 

  • iTunes does not provide a way to get the order of playing songs (even with shuffle off)
  • iTunes does not provide a way to get a list of the songs from current album

- Right now the workflow can get a list of songs from current album (but not from an Album with “Various” as album artist)

- Sometimes or for some tracks the code inside Alfred does not work though it works in AppleScript Editor

 

I know there are a lot of missing things regarding a song playing from Library but a song from Library can be skipped making the workflow a simple next/prev.

 

Download the updated version here:

 

 

Share this post


Link to post

Sweet! I like that!

Any chance you could add the artist (or show if tv show) next to the track name? It'd really help understand what's actually next (or previous).

Share this post


Link to post

Sweet! I like that!

Any chance you could add the artist (or show if tv show) next to the track name? It'd really help understand what's actually next (or previous).

 

Yes, I think it is possible. Thank you for your suggestion. :)

Share this post


Link to post

I don't even know if this is possible, but can the icon be the album cover art?

Share this post


Link to post

How would I use part of this workflow to search (either Google or a specific site) for the lyrics of the currently playing song?

Share this post


Link to post

Within the "script filter" named "rate" in this workflow, you will find the code that gives you the title and the artist of the track currently playing. I don't know exactly what you want to do with the lyrics (open in browser, save in .txt, add to track metadata, paste to clipboard...) so depending on that there are several approaches you might want to take. 

 

Say you want to add that to the track's metadata.

 

First, I'd pass the title and artist as arguments (in the xml output) to a second script (thus replacing the current NSAppleScript) that would get (and parse) the lyrics form a predefined website. I'd recommend you use php for that part as it's very good at dealing with websites but anything would do.

 

Second, I'd pass the lyrics you've obtained to a final script. I recommend you use Apple Script as it'll make it really easy for you to set the tracks metadata to the lyrics you've just passed.

 

Any question? 

 

have fun

Share this post


Link to post

Within the "script filter" named "rate" in this workflow, you will find the code that gives you the title and the artist of the track currently playing. I don't know exactly what you want to do with the lyrics (open in browser, save in .txt, add to track metadata, paste to clipboard...) so depending on that there are several approaches you might want to take. 

 

Say you want to add that to the track's metadata.

 

First, I'd pass the title and artist as arguments (in the xml output) to a second script (thus replacing the current NSAppleScript) that would get (and parse) the lyrics form a predefined website. I'd recommend you use php for that part as it's very good at dealing with websites but anything would do.

 

Second, I'd pass the lyrics you've obtained to a final script. I recommend you use Apple Script as it'll make it really easy for you to set the tracks metadata to the lyrics you've just passed.

 

Any question? 

 

have fun

 

Thanks. I'm a total beginner at any sort of coding, but I'll take this and give it a try.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now