Get the next ten songs in iTunes DJ using AppleScript - applescript

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).

Related

Applescript to cause iTunes to play an album by Apple Music URL?

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?

Does iTunes have an SDK or API to use?

Is there a way to import to apple music playlist without having the mp3 for the song, that apple music will automatically find and allow you to play?
OR
Is there anyway to add a playlist to iTunes Apple Music without having the song and getting iTunes Match to find the song from the importing?
Time flies! MusicKit from Apple might be your best bet.
https://developer.apple.com/musickit/

How to get status and song info from iTunes on Mac

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

How to get iTunes to play an iPhone playlist automatically when connected to the iPhone

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

Script/Program to connect iTunes and Spotify

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

Resources