Using "Ripped?" more efficiently?
I have just begun using "ripped?" to help determine if a track is already being used on a playlist.
But the script is set up such that it reviews all playlists & for my purpose, I only what to review a particular set of playlists--namely those devoted to one artist, Bob Dylan.
Does anybody know how to limit the selection of playlists to be reviewed? It should be made easier by the fact that the playlists in question all have a unique named included in the title (Dylan).
# 1 Re: Using "Ripped?" more efficiently?
hi thomas,
are you familiar with the script editor at all.. i can take you through moding the code or you could try dropping an email to the author, the address is included in the read-me.. they'll probably be able to knock up a custom version for you..
deeg at 2007-11-15 17:25:09 >

# 2 Re: Using "Ripped?" more efficiently?
are you familiar with the script editor at all.. i can take you through moding the code or you could try dropping an email to the author,[/B]
Yes, my main experience with scripting has been finding existing scripts and modifying them to suit my whims. Not always with success, however.
So it's my guess that these lines in the script:
set the_playlists to name of every user playlist
global the_playlists -- list of all user playlists
could be changed to limit the choice to those playlists which contain the word "Dylan".
I would also think that I could eliminate much of the first half of the script entirely since I would prefer to devote any time to searching out whether or not the track has been ripped.
# 3 Re: Using "Ripped?" more efficiently?
i tried limiting the playlists selected in that line but is failed for me so instead this will limit the playlists searched to just those containing the word Dylan by checking the playlists after we have them all and discarding those we dont want...
set the_userplaylists to name of every user playlist
set the_playlists to {}
repeat with aPlaylist in the_userplaylists
if aPlaylist does not contain "Dylan" then
-- noop
else
set the_playlists to the_playlists & aPlaylist
end if
end repeat
note: applescript ignores case unless asked so it would find dylan/Dylan/dyLan etc..
i did originally write Ripped? to just scan the library file but someone asked for it to include a playlist scan as well.. you could cut out alot of the code if all you want to do is scan for a given track, something along the lines of...
--
-- declare the variables for later use
--
set track_to_check to ""
-- start of script
tell application "iTunes"
if selection is {} then
display dialog "This script requires you to have selected a track in iTunes before running"
else
set track_to_check to (item 1 of selection)
end if
if track_to_check is not equal to "" then
set album_to_check to album of track_to_check
set trackname to name of track_to_check
set found to false
tell source "library"
tell playlist "library"
repeat with i from 1 to the count of tracks
tell track i
if (name of track i is equal to trackname) & (album of track i is equal to album_to_check) then
set found to true
exit repeat
else
-- noop
end if
end tell -- end of each track check
end repeat -- end of all track checks
end tell -- end of library playlist chat
end tell -- end of library source chat
-- display results
if found then
display dialog "you have already imported this track"
else
display dialog "you have not imported this track"
end if
end if -- end of check for album
end tell
would probably do it.. it checks both the album and trackname since you might have different versions from different albums.. if you are not concerned about that then just remove the album name checks and leave the trackname check..
deeg at 2007-11-15 17:27:07 >

# 4 Re: Using "Ripped?" more efficiently?
My apology, I misled you in my earlier post--I should have said that I am only interested in the playlist search part of the script.
Trying the code you gave to limit the scope of the playlist search, I inserted it after this line of your script:
set track_to_check to database ID of track_to_check -- get the id of the track we are interested in
But upon use, all playlists were still scanned. Should I have inserted it somewhere else?
I really appreciate your help. If I can modify ripped? to just do a search to tell me if a track has already been used in one of my "Dylan" playlists, I would use it quite a bit. But I have so many playlists that searching through them all would waste a considerable amount of time.
Thomas S. England
Decatur GA 30030
Portfolio:
http://englandphoto.com/portfolio//
# 5 Re: Using "Ripped?" more efficiently?
By intuitive copy/pasting, I now have altered the script so that it does what I wanted. It will not check for the use of a track in previous playlists which have "Dylan" as part of the playlist name:
--
-- declare the variables for later use
--
property old_versions : {"2.0.2", "2.0.1"} -- old versions of itunes used by get_the_playlists
global the_playlists -- list of all user playlists
global found_in -- which playlists the track was found in
set the_playlists to {}
set found_in to {}
set track_to_check to ""
-- start of script
tell application "iTunes"
if selection is {} then
display dialog "This script requires you to have selected a track in iTunes before running"
else
set track_to_check to (item 1 of selection)
end if
if track_to_check is not equal to "" then
-- what would they like to check ?
set track_to_check to database ID of track_to_check -- get the id of the track we are interested in
set the_userplaylists to name of every user playlist whose name contains "dylan"
my gettheplaylists() -- call sub routine to get all the user playlists
if (count of items in the_playlists) > 0 then -- we have some playlists to check
set show_result to true -- we have something to show them
repeat with p in the_userplaylists -- check each playlist
-- keep them informed of progress
set the_name to p as string
display dialog "checking playlist " & the_name buttons {"KLF"} giving up after 1
tell playlist p -- chat with the playlists
set include_playlist to false
repeat with i from 1 to the count of tracks -- check all tracks in playlist
tell track i
set a_test to false
-- if the track matches what we are looking for update found_in
if (database ID = track_to_check) then
set include_playlist to true
end if
end tell -- end of each track check
end repeat -- end of all track checks
-- add playlist to list of playlists..
if include_playlist then
set end of found_in to p
end if
end tell -- end of chat with the playlist
end repeat
else
display dialog "no user playlists found" buttons {"KLF"} giving up after 5
set show_result to false -- we have nothing to show them
end if
if show_result then -- we have something to tell them
if (count of items in found_in) > 0 then -- track has been found in some lists
-- show the user
set x to (choose from list found_in with prompt ?
" Your selected track has been located in the following playlists" with empty selection allowed) as string
-- allows the user to display the playlist of desired
if x is not equal to "" then
tell application "iTunes"
set the view of the front browser window to playlist x
end tell
end if
else -- not found in any playlists
display dialog "Your track is not in any playlist" buttons {"KLF"} giving up after 5
end if
end if
end if
end tell
--
-- subroutine to get the playlists
--
on gettheplaylists()
tell application "iTunes"
-- get the current version of itunes
set itunes_version to version
-- get which playlists exist
if old_versions contains itunes_version then -- cannot use "every" command
set theLists to {}
set pCount to (get index of last user playlist)
repeat with i from 1 to pCount
copy (get name of user playlist i) to end of the_playlists
end repeat
else
set the_playlists to name of every user playlist
end if
end tell -- end of chat with itunes
-- set what to return
return (the_playlists)
end gettheplaylists
# 6 Re: Using "Ripped?" more efficiently?
glad to here its getting there, you can probably remove alot of code to make it slightly quicker.. for example
if...
set the_userplaylists to name of every user playlist whose name contains "dylan"
is returning the list of playlists that you are interested in then the whole subroutine which gets the playlists can be removed, thats only there because different versions of itunes had different scripting abilities...
also the method of adding the playlist to the list of found playlists in ripped? is not very good, think i wrote this a nearly couple of years ago, so the method i used in the the example is neater/faster since it exits from checking each playlist as soon as it finds the track rather than carrying on to check the rest of the tracks as the ripped? code does...
ps.. like the shots from venice by the way.. out of interest was the photo showing the close up of the gondola's altered in anyway? .. the silver looks really nice against the deep blues
deeg at 2007-11-15 17:30:12 >

# 7 Re: Using "Ripped?" more efficiently?
Yes, I will get around to cleaning it up a bit, but it's working for me now.
As to thephoto, no there is no special effect being applied there. just some Photoshopping to control contrast, saturation, etc.