I'm attempting to script iTunes to play an arbitrary playlist or an arbitrary album from a shell script.
I've solved the playlist problem with the following:
osascript -e 'tell application "iTunes" to open location "'$url'?cmd=AddStation"'
Where url is an itmss:// type URL to a playlist. Without the "cmd=AddStation" parameter, it won't automatically play.
This doesn't work for an album URL, however. If I execute:
osascript -e 'tell application "iTunes" to open location "'$url'"'
where url is defined as an itmss:// album URL, then the album does come up on iTunes, but it won't start playing. If I tell iTunes to play via Applescript, it instead starts playing the first album in the entire iTunes library, not the album that is displayed.
There was a similar question about a year back here Applescript play music from iTunes URL ; however, the solution provided in that response requires you to know the title of the first track you want to play. Does anyone have an idea for a more generic solution that will bring an album from the command-line and then play the first track?
Related
Found out that I am able to control Spotify through terminal from here
http://www.instructables.com/id/RFID-Controls-for-Spotify-on-OSX-using-hacked-Mir/?ALLSTEPS
for example skipping to the next song, you would type this in the terminal:
osascript -e 'tell application "Spotify" to next track'
Just wanted to know if there was a way to create a new playlist on Spotify through the terminal .
Cheers.
No, creating playlists it's not possible using the desktop application's API.
Some useful resources:
The API reference can be found at /Applications/Spotify.app/Contents/Resources/Spotify.sdef
A shorter guide can be found at https://developer.spotify.com/applescript-api/
The iPhone has an app that can control iTunes on a Mac, for example play a song. Is it possible to get iTunes status in my program (Objective-c or other language like node.js)? When I play a song I want to receive an event, and when I add a song I want to know what file I added in my program. I tried to find documentation about this but found no result - is there documentation about how to do this?
Absolutely, this can be done with Applescript. iTunes is fully scriptable. You can control it, get information about the currently playing media, etc.
http://dougscripts.com/itunes/itinfo/info01.php
I have a habit of working/studying while listening to music. And since the Mac I am connected to at work doesn't have all the songs I want, I normally listen to the songs via iTunes from the iPhone Playlists option.
For this, everytime I connect my iPhone to the computer, iTunes detects it, then I have to manually goto the 'iPhone' button in the application, and then "On my iPhone", and then select the playlist, and play a song.
Is there anyway of automating this process ? What I'm looking for, is as soon as I connect my iPhone, iTunes should open the playlist inside my iPhone automatically, and start playing a song at random.
I've tried automating it with Automator. But that doesn't seem to be working. There's something wrong I'm doing in AppleScript ::
tell application "iTunes"
play playlist named "Sasha" of source of type iPhone
end tell
Ha !! I figured it out !! And then I created an applet that would do this for me using AppleScript.
And then, I published the steps/code for the same on my blog below. Here's the link ::
Explanation of Code :: How to start playing songs from your iOS device automatically on your Mac
And the code for the same ::
tell application "iTunes"
set theCurrentPlaylist to view of front browser window
set myiPhone to some source whose kind is iPod
set mainPhonePlaylist to playlist "Sasha" of myiPhone
set the view of the front browser window to mainPhonePlaylist
set EQ enabled to true
play playlist named "Sasha" of myiPhone
set myRandomSong to random number from 1 to count of tracks of (get view of front window)
play track myRandomSong of mainPhonePlaylist
end tell
So I am trying to either play a song in spotify and have it update the playcount of the song in iTunes. Or when I play a song in iTunes to have it play in Spotify. either is fine.
I have a vbs script that can increment the playcount of a song if it matches a folder path on iTunes. However I don't know how to get that path of Spotify. As far as the second option I have no clue how to do it.
Any ideas? Thanks
Spotify doesn't really provide access to the currently playing song, so what you're attempting to do is probably not really feasible. I would suggest maybe using something like Last.FM to save overall playcounts.
I wrote a script in Python which can update iTunes with playcounts from Last.FM http://deceptacle.com/2010/10/21/itunes-playcount-updater-using-last-fm/ which may be of some use
I am creating an application using AppleScript and I want to display a list of the next ten (including the current) songs iTunes will play from iTunes DJ. I can't find it anywhere on the internet, Google, whatever so I asked it here. Can anyone help me? Thanks
The following AppleScript will return the names of the songs in the iTunes DJ playlist:
tell application "iTunes"
get name of every track of playlist "iTunes DJ"
end tell
The song names are returned in play order and will also include recently played songs (this can be configured in the iTunes DJ settings).