iLounge 2013 iPhone + iPod Buyers' Guide
Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.

Topic: Basis of a "Script to add placeholder/wishlist item/dummy track to a playlist"

Reply Thread Tools Topic Search
 
Old 11-02-2004, 04:42 AM
#1
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12
Basis of a "Script to add placeholder/wishlist item/dummy track to a playlist"

Thank you. Hello,

itunes is lacking one thing as far as I'm concerned and that's the ability to add tracks I don't have to playlists. Why do I want to do this? Well I like to use iTunes to organize music as well as play it, and I have an upcoming event where I would like to use iTunes to develop the playlist. I'll be able to use this as a kind of 'to-do' list for music of songs I need to get. I can replace the dummy tracks as I get the proper versions. Ultimately the playlist will be placed on an ipod, etc and the music played from there.

I can use a smart playlist to select all tracks from my event's playlist of time 0:00 so I have a separate list of the dummy tracks.

So to get to the point, I've written (badly) a script to add a dummy track to the library that then prompts the user to input the title, artist, etc. I'm posting it here as hopefully someone will point out how I can improve it, i.e. error handling.

I'll like to have one dialog box pop up instead of three one after the other, but I think this is a limitation of applescript. Applescript studio could do it.

Here we go:

-- Use Quicktime to create a dummy mp3 file. Open a new player and just save as to create a mp3.
-- Need to add in some error routines
-- Need to deselect the tracks so they don't get played (Although no biggy as they are 0 length

tell application "iTunes"
activate
set win to front browser window
tell win
-- add dummy track, change location to suit
add "Macintosh HD:Users:user:location:temp.mp3"
end tell
duplicate track "temp.mp3" of playlist "Library" to playlist "event"
tell win
display dialog "Add placeholder file" & return & return & ??
"Track Title:" default answer ""
set track_title to the text returned of the result
end tell
tell win
display dialog ??
"Artist:" default answer ""

set track_artist to the text returned of the result
end tell
tell win
display dialog ??
"Album:" default answer ""

set track_album to the text returned of the result
end tell
set this_track to track "temp.mp3" of playlist "event"
set the name of this_track to the track_title
set the artist of this_track to the track_artist
set the album of this_track to the track_album
end tell
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote

Join the iLounge Community and the ad above will disappear.

Old 11-02-2004, 04:45 AM
#2
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

I didn't mean to sound like a complete spaz. The "Thank you. Hello.." bit comes from me not deleting all the default post text "Please post in the appropriate forum, etc..."
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-02-2004, 12:42 PM
#3
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

It gets better. Now deselects the track, Also the order is changed. Dialogs come first, so therefore cancelling prevents the dummy track from being added anyway.

The only issue I have is when run from iTunes I sometimes get an "Apple event timed out" error when I try to run it. If I try again it will work. Any ideas? When run from Script Editor there's no problems

-- Use Quicktime to create a dummy mp3 file. Open a new player and just save as to create a mp3.
-- Need to add in some error routines.

tell application "iTunes"
activate
set win to front browser window
tell win
display dialog "Add placeholder file" & return & return & ??
"Track Title:" default answer ""
set track_title to the text returned of the result
end tell
tell win
display dialog ??
"Artist:" default answer ""

set track_artist to the text returned of the result
end tell
tell win
display dialog ??
"Album:" default answer ""

set track_album to the text returned of the result
end tell

tell win
-- add dummy track, change location to suit
add "Macintosh HD:Users:User:Location:temp.mp3"
end tell
duplicate track "temp.mp3" of playlist "Library" to playlist "Event"
set this_track to track "temp.mp3" of playlist "Event"
set the name of this_track to the track_title
set the artist of this_track to the track_artist
set the album of this_track to the track_album
set enabled of this_track to false
end tell
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-03-2004, 08:02 AM
#4
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

I've found the answer (ish) to the "Apple Event Timed Out" problem here: http://ipodlounge.com/forums/showthr...threadid=50304

Saving it as an application works. Apart from when run from iTunes it first prompts whether you want to run the script or not. Nevermind.
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-03-2004, 08:11 AM
#5
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

The dog's nads. If you run the script/application directly you have the option to disable the start-up screen. This means that when run from itunes it just runs. Ace

Sorted.

Happy bunny.
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-03-2004, 09:05 AM
#6
 

Mod
 
Join Date: Jun 2003
Location: Providence, RI, USA
Posts: 705

Wow. Good work. Send me the script when you get a chance
__________________
Visit Doug's AppleScripts for iTunes
Doug Adams is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-03-2004, 09:53 AM
#7
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

Doug,

I'll just post it here if that's ok (haven't time to figure out where I'm supposed to send it to). It isn't that fancy at all and I'm sure someone like you could improve it. I'd love it if it just presented one dialog. It's probably the same as the last post above, but for completeness:

--This script is used to create a dummy file/wishlist item/placeholder track in an iTunes playlist of your choice. It prompts you to enter Song name, artist and album. My intention for use is so I can add tracks I don't have yet to a playlist. I can then use the playlist to get the desired play order of the tracks (which will be a mix of ones I do have and ones I don't.) Tracks can be replaced manually as and when I get them.
-- Use Quicktime to create a dummy mp3 file. Open a new player and just save as to create a mp3.
-- Store this dummy mp3 somewhere suitable. Mine is called temp.mp3 in is in my music folder
-- Save this script as an application. Place in itunes script folder. This gets around an apple event time out problem
-- Before running from itunes, launch the application directly and disable the start-up screen (Select File and uncheck 'use start-up screen')
-- Create a playlist where you want to store the dummy tracks, alter the playlist name in the code below.
-- You can create a smart playlist that looks in the playlist you've defined for all songs that are 0:00 length in time. This gives you an easy way to get just your dummy tracks, i.e. as you replace the dummy tracks one by one in your playlist.
-- TO DO: Need to add in some error routines? I don't think I can have one dialog box instead of three due to a limitation of Applescript, Applescript studio could get around this.



tell application "iTunes"
activate
try
set win to front browser window
tell win
display dialog "Add placeholder file" & return & return & ??
"Track Title:" default answer ""
set track_title to the text returned of the result
display dialog ??
"Artist:" default answer ""
set track_artist to the text returned of the result
display dialog ??
"Album:" default answer ""
set track_album to the text returned of the result
-- add dummy track, change location to suit
add "Macintosh HD:Users:simonheywood:Music:temp.mp3"
end tell
-- Alter playlist to suit where you want this track added to
duplicate track "temp.mp3" of playlist "Library" to playlist "Si&Amy"
set this_track to track "temp.mp3" of playlist "Si&Amy"
set the name of this_track to the track_title
set the artist of this_track to the track_artist
set the album of this_track to the track_album
set enabled of this_track to false
end try
end tell
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-04-2004, 11:15 AM
#8
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

An important note regarding this script. It does depend on you having the "Copy files to iTunes music library when adding to library" checked. Otherwise the script will only work once!

I guess this script could be altered to check this is the setting before running and if not set it before running and unset it afterwards. The alternative would be for the script to create a new "temp.mp3" file each time
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-04-2004, 11:19 AM
#9
 

Mod
 
Join Date: Jun 2003
Location: Providence, RI, USA
Posts: 705
Well, no

No, you can't script Preferences, so you can't check if that setting is set
__________________
Visit Doug's AppleScripts for iTunes
Doug Adams is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote
Old 11-04-2004, 04:05 PM
#10
 
i5m
Freshman Lounger
 
Join Date: Nov 2004
Location: Lancaster, UK
Posts: 12

OK, well the other option's there if someone wants to take it further.
i5m is offline  
Share on TwitterShare on FacebookDigg this Post!Google Bookmark this Post!
Reply With Quote

Topic: Basis of a "Script to add placeholder/wishlist item/dummy track to a playlist"

Reply Thread Tools Topic Search

Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





View iLounge History. Read our old Forums Archive (2001-2003)
All times are GMT -4. The time now is 11:04 AM.


Shop for Accessories: Cases, speakers, chargers, etc.