Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > iTunes: Create playlist containing only albums?

iTunes: Create playlist containing only albums?
Thread Tools
siMac
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 26, 2005, 02:33 AM
 
I'd like to create a playlist that contains only the 'full' albums in my library. This could be achieved as it is in CoverFlow, ie. either by filtering by album length or by number of tracks.

Does anyone know how I could achieve this? Smart playlists won't work because they can't access an album's duration or how many tracks it contains. Any ideas?
|\|0\/\/ 15 7|-|3 71|\/|3
     
B Gallagher
Grizzled Veteran
Join Date: Jan 2005
Location: New Zealand
Status: Offline
Reply With Quote
Oct 26, 2005, 06:37 AM
 
Hmm.. copy and paste each album into a non-smart playlist?

seems like the easiest way to me.. might take a bit of time, but even so...
MBP 15" C2D 2.2GHz 4.0GB 500GB@5400
iPhone 4 32GB Black
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 26, 2005, 06:59 AM
 
8,702 songs, 27 days 18:14:49 total time, 46.59 GB

'The easiest way', eh?

I figure that if CoverFlow is capable of performing the kind of filtering I want then it must also be possible by Applescript or somehow...



^^^ What I would like is to be able to create a playlist in iTunes using exactly these criteria. ^^^
( Last edited by siMac; Oct 26, 2005 at 07:03 AM. Reason: Add image.)
|\|0\/\/ 15 7|-|3 71|\/|3
     
Weyland-Yutani
Mac Elite
Join Date: Mar 2005
Location: LV-426
Status: Offline
Reply With Quote
Oct 26, 2005, 11:22 AM
 
Did anyone else notice we went from iTunes 4 to iTunes 6 without any real improvements? *boom* two versions up and what happened? Nothing. People with weeks upon weeks of music and no database improvements? Tsk tsk.

cheers

W-Y

“Building Better Worlds”
     
mpancha
Grizzled Veteran
Join Date: May 2005
Location: Toronto, ON
Status: Offline
Reply With Quote
Oct 26, 2005, 11:29 AM
 
Originally Posted by Weyland-Yutani
Did anyone else notice we went from iTunes 4 to iTunes 6 without any real improvements? *boom* two versions up and what happened? Nothing. People with weeks upon weeks of music and no database improvements? Tsk tsk.

cheers

W-Y
well said... cheers!
MacBook Pro | 2.16 ghz core2duo | 2gb ram | superdrive | airport extreme
iBook G4 | 1.2ghz | 768mb ram | combodrive | airport extreme
iPhone 3GS | 32 GB | Jailbreak, or no Jailbreak
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 26, 2005, 11:40 AM
 
I'd like this as well. It probably is possible with Applescript. You just need to write it that's all.
     
jasong
Mac Elite
Join Date: Mar 2000
Location: Allston, MA, USA
Status: Offline
Reply With Quote
Oct 26, 2005, 01:29 PM
 
Originally Posted by mpancha
well said... cheers!
And also very helpful. Now all we need is someone to tell siMac he is stupid for wanting to do this.

That being said, I don't see how you can do this within the iTunes interface, which I guess makes this post as helpful as the rest. Sorry. Be sure to post if you find a solution.
-- Jason
     
Weyland-Yutani
Mac Elite
Join Date: Mar 2005
Location: LV-426
Status: Offline
Reply With Quote
Oct 26, 2005, 01:39 PM
 
Originally Posted by jasong
And also very helpful. Now all we need is someone to tell siMac he is stupid for wanting to do this.

That being said, I don't see how you can do this within the iTunes interface, which I guess makes this post as helpful as the rest. Sorry. Be sure to post if you find a solution.
Helpful? That was my point. There is no help. Doing what he wants isn't possible in iTunes, which I was pointing out.

An Apple script may be a solution, but then the OP will just have to write one for himself, unless you or someone else is prepared to sit down and do it for him?

And thus the story ends. I'd be surprised if anyone would tell siMac that he's stupid for wanting to do this. Rather that Apple is stupid for not having updated the database features of iTunes since iTunes 4.

Out of curiousity though, was your post very helpful to the OP?

cheers

W-Y

“Building Better Worlds”
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 26, 2005, 01:52 PM
 
Originally Posted by Weyland-Yutani
Did anyone else notice we went from iTunes 4 to iTunes 6 without any real improvements? *boom* two versions up and what happened? Nothing. People with weeks upon weeks of music and no database improvements? Tsk tsk.
Exactly. I think they're just trying to bump the version number as high as possible, because everyone know Windows Media Player has already reached version 10 and, therefore, is almost twice as good!

But seriously, they could have enhanced the smart-playlist functionality to take account of more metadata (Album Length or Album Track Count for example). Or how about improving the sound enhancer and EQ? Sound Check's performance leaves room for improvement. Then there's the much-requested gapless playpack....

I'd also like to be able to Autofill my nano. Relative to the size of my colection, my nano is like a shuffle - I'd love to be able to use it as such.

I could go on, but this isn't helping with my original problem.
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 26, 2005, 01:59 PM
 
siMac,

I'll have a bash at it (applescript). No promises though.
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 26, 2005, 02:13 PM
 
Yay! Don't worry, no pressure, you're my new personal hero just for trying.
|\|0\/\/ 15 7|-|3 71|\/|3
     
jasong
Mac Elite
Join Date: Mar 2000
Location: Allston, MA, USA
Status: Offline
Reply With Quote
Oct 26, 2005, 02:32 PM
 
I think I mentioned that my post wasn't helpful. ;-)

You didn't say sorry you can't do that, you said iTunes just jumped from 4 to 6 with no real improvements. That sounds lot more like an Apple Bash opportunity rather than the "sorry, you can't do that" that you are playing it off as now.

A question for you, if iTunes 6 was released as iTunes 4.9.3a, what would your response be?
A second question, say iTunes 6 was just released with tons of improvements, but didn't allow this particular request, what would your response be?
-- Jason
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 26, 2005, 02:49 PM
 
[PHP]tell application "iTunes"
set albumList to {}
set trackCount to count of every track of library playlist 1
set processedCount to 1

repeat while processedCount ≤ trackCount
set theAlbum to album of track processedCount of library playlist 1 as string
set add2List to true
if theAlbum is equal to "" then set add2List to false
if albumList contains theAlbum then set add2List to false
if add2List is true then
set albumList to albumList & (theAlbum as string)
end if

set processedCount to processedCount + 1
end repeat

if exists (some user playlist whose name is "Long Albums") then
set albumsPlaylist to user playlist "Long Albums"
else
set albumsPlaylist to (make user playlist with properties {name:"Long Albums"})
end if

repeat with theAlbum in albumList
set these_tracks to (file tracks of library playlist 1 whose album is theAlbum)
set theAlbumDuration to 0

if the (count of these_tracks) is greater than 4 then
repeat with a_track in these_tracks
set theAlbumDuration to theAlbumDuration + the (duration of a_track)
end repeat
end if

if theAlbumDuration is greater than 20 * 60 then
repeat with a_track in these_tracks
duplicate a_track to albumsPlaylist
end repeat
end if
end repeat
end tell[/PHP]

Edit:
Added check for at least 5 songs.
( Last edited by TETENAL; Oct 26, 2005 at 03:08 PM. )
     
Weyland-Yutani
Mac Elite
Join Date: Mar 2005
Location: LV-426
Status: Offline
Reply With Quote
Oct 26, 2005, 02:53 PM
 
Originally Posted by jasong
I think I mentioned that my post wasn't helpful. ;-)

You didn't say sorry you can't do that, you said iTunes just jumped from 4 to 6 with no real improvements. That sounds lot more like an Apple Bash opportunity rather than the "sorry, you can't do that" that you are playing it off as now.

A question for you, if iTunes 6 was released as iTunes 4.9.3a, what would your response be?
A second question, say iTunes 6 was just released with tons of improvements, but didn't allow this particular request, what would your response be?
That was the gist of my post. The OP mentioned he had almost 4 weeks of music and I agreed with him that it was strange iTunes didn't have any new or improved methods of organizing it especially in the light that iTunes has just jumped from version 4 to version 6 in less than 2 months. If you read this as Apple criticism it was, but not out of context. That would have been unnecessary.

I can try to answer the questions you pose me as well as I can. It is only polite.

1° I'd ask "why did they go to version 5 and then back to version 4.9.x!?"
I kid I kid. Assuming the highest version of iTunes today was 4.9.3a or something, we'd be patiently waiting for the major update of iTunes. Version 5. When version 5 was published it was a disappointment to those who hoped for database improvements. That is, new or better ways to organize the music. So, in short my response to iTunes 6 as iTunes 4.9.3a would be: they've had almost 2 years to work on iTunes 5 and it is just around the corner. This version is just to show basic support to the new iPods and video store. I'd defend Apple. Because version numbers used to mean something when I was a kid.

2º Certainly more positive than a rather bewildered "Apple has had almost 2 years to design and program iTunes 5 (or 6) and they give us.. nothing!". Certainly given that this hypothetical iTunes 5 (or 6) had included a bunch of improvements it would demonstrate Apple is listening to customers or/and desires to improve their product and stay sharp. iTunes is a critical companion to the iTMS and the iPod. So in light of a bunch of improvements in the hypothetical iTunes 5, odds are good that the missing feature will be added.

Right now, what are the odds of iTunes improvements? Two years and we got iTunes 5/6 (essentially the same app). Of course there wasn't that much difference between iTunes 2 and 3, but there was quite a jump between 3 and 4.

cheers

W-Y

“Building Better Worlds”
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 26, 2005, 03:56 PM
 
looks like I've been beaten to it. I'll continue with what I've got (I like learning) and compare and contrast. I'll take me a bit longer than (speedy!) TETENAL
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 02:19 AM
 
Thanks TetenaI! I'm testing it out now. I haven't got it to work just yet, it seems to hang iTunes when I run it, but it could just be that it needs a long time to process my library. I'm gonna leave it running while I go to work and see what happens.

Thanks again,

Si
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 06:31 AM
 
Well for completeness here's mine.

You will of course notice the similarity. I think TETENAL's is based on a script called "Make Album Playlists" from Doug's Applescripts for iTunes (although he could well be the original author). I was working with that as a base as well.

I couldn't quite get TETANAL's to work. It threw a wobbly at the point of duplicating tracks to the playlist. Applescript seems to be a right little madam in that commands have to be written slightly differently depending on the context they are used in. Anyway, more by luck than anything else, I got the duplicate bit to work as below.

The script also prompts the user to input the min. number of tracks and min. album length.

Oh, by the way it does take ages to run.


[PHP]
--This script will attempt to compile a playlist of only albums based on user inputted
--values for min. number of tracks per album and min. album duration
--
--Inspired by "Make Album Playlists" by Andrew Mathieson
--And also by TETENAL's script on macnn after he beat me to it
--With info from "Doug's Applescripts for iTunes" www.dougscripts.com/itunes
--
--This script by i5m
--
tell application "iTunes"

set albumList to {}
--Change name below to suit your requirements
set only_albums_playlist to "OnlyAlbums"
--Below can change the source. Used mainly for testing so don't have to work on whole library ("library playlist 1")
set library_source to library playlist 1


display dialog "Enter Min Number of tracks per Album" & return & return & ¬
"No. of Tracks:" default answer ""
set min_number_tracks to the text returned of the result
display dialog "Enter Min Duration of Album in Minutes" & return & return & ¬
"Min Duration:" default answer ""
set min_album_duration to the text returned of the result
display dialog "This may take a long time to run press OK to continue"

--Set fixed indexing. Not utterly sure if this is required here but does no harm
set fx to fixed indexing
set fixed indexing to true

log "Begin part 1, get list of albums"

set source_tracks to (get a reference to library_source)
copy (count library_source's tracks) to idx

repeat with j from 1 to idx
copy track j of source_tracks to thisTrack
set theAlbum to album of thisTrack as string

set add2List to true
if theAlbum is equal to "" then set add2List to false
if albumList contains theAlbum then set add2List to false
if add2List is true then
set albumList to albumList & (theAlbum as string)
log "Added album \"" & (theAlbum as string) & "\" to the list."

end if
end repeat

set fixed indexing to fx

log "Finished Part 1"

log "Begin Part 2: Add Albums to Playlist"

set skipItAll to false

--Don't add blank albums
if theAlbum is "" then set skipItAll to true

if skipItAll is false then

-- does this playlist already exist?
if exists (some user playlist whose name is only_albums_playlist) then
set my_opts to (display dialog "This Playlist exists: " & only_albums_playlist buttons {"Don't Replace", "Replace"} default button 2 with icon 0)

if button returned of my_opts is "Replace" then
set new_playlist to user playlist only_albums_playlist
try
delete every track of new_playlist
end try
else
set skipItAll to true
end if
else
set new_playlist to (make user playlist with properties {name:only_albums_playlist})
end if

if skipItAll is false then


repeat with theAlbum in albumList

set these_tracks to (file tracks of library_source whose album is theAlbum)
set theAlbumDuration to 0

if the (count of these_tracks) is greater than min_number_tracks then
repeat with a_track in these_tracks
set theAlbumDuration to theAlbumDuration + the (duration of a_track)
end repeat
end if

if theAlbumDuration is greater than min_album_duration * 60 then
repeat with a_track in these_tracks
duplicate a_track to playlist only_albums_playlist
end repeat
end if

end repeat
end if
end if

display dialog "Finished making Only Albums playlist!" buttons {"OK"} default button 1 with icon note

end tell[/PHP]
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 27, 2005, 08:10 AM
 
Originally Posted by ism
think TETENAL's is based on a script called "Make Album Playlists" from Doug's Applescripts for iTunes (although he could well be the original author). I was working with that as a base as well.
Yes, I took a look at this script to see how things are done (never scripted iTunes before) and copied bits as needed. My script works for me, even though it takes a little for the 600 songs I have. Asking for the minimum time and number of songs is better, so thanks a lot for posting your version.
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 08:19 AM
 
Originally Posted by TETENAL
(never scripted iTunes before)
Well you learnt that pretty quick!
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 08:21 AM
 
Thanks for your version, ism - being able to specify the criteria at launch will be very handy. However the script as posted here doesn't work for me - it won't compile in Script Editor:

" Expected end of line, etc. but found ". "

for the line:
            log "Added album "" & (theAlbum as string) & "\" to the list."

Any ideas?
|\|0\/\/ 15 7|-|3 71|\/|3
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 08:26 AM
 
OK, I removed one of the double " and the script has compiled, I'll post back with results.

Thanks!
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 08:35 AM
 
I guess it was the cr*ppy formatting as it got posted?

I should have linked to it I guess.

You can delete all the log lines if you want. They aren't important. They were just in the original script. It makes monitoring it easier as you are developing it that's all.
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 08:43 AM
 
Update: the script runs, I used '5' songs and '20' minutes as the criteria; after about two minutes it shows a prompt saying "Finished making Only Albums playlist!", I click OK but there is no playlist. I'm sure I am missing something simple here, please help!

Thanks again for all the help so far guys.

Edit: perhaps it's the aforementioned 'cr*ppy' formatting of the forums, any chance of that d/l link?
|\|0\/\/ 15 7|-|3 71|\/|3
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 27, 2005, 08:52 AM
 
Didn't my script work for you? It adds a playlist "Long albums".

ism's script looks like basically the same so it should run as well.
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 08:53 AM
 
Hmmm. Odd.

Well here's a link. I hope this works.

OnlyAlbums

The good news is that me and TETENAL have these scripts running locally so it's just a matter of working out the issues for you
( Last edited by ism; Oct 27, 2005 at 08:54 AM. Reason: link corrected)
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 09:01 AM
 
A ha! Discovered a problem. Runs fine from script editor. Has issues when run from within iTunes.

I shall investigate...
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 09:09 AM
 
Right it works best if you do this:

Download that script. Open it in script editor and save it as an application. Place that in your ~/library/iTunes/Scripts folder.

Run from iTunes script menu. it will open it as an application with a dialog (you can at this point in time set it so it doesn't prompt you everytime it's run from File>Use Startup Screen)

Hey presto should work

I'd upload it as an application, but I did that through my bluetooth modem and the difference in size between script and app is significant in those circumstances.

Note: I've had this problem in the past, can't remember what the issues are, if interested Doug's site probably details it.
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 09:11 AM
 
D'oh, still no worky. I'll have a look at it when I get home and see if I can't figure out what's wrong. I'm wondering whether it is related to my setup - my iTunes library is in the Shared user's directory which is then symlinked to my user directory, although this doesn't normally affect the scripts I run.

I'll let you know how I get on.

Si

Edit - we posted simultaneously, I will try your latest suggestion.
|\|0\/\/ 15 7|-|3 71|\/|3
     
mpancha
Grizzled Veteran
Join Date: May 2005
Location: Toronto, ON
Status: Offline
Reply With Quote
Oct 27, 2005, 09:47 AM
 
Originally Posted by jasong
And also very helpful. Now all we need is someone to tell siMac he is stupid for wanting to do this..
what does that have to do with my post, or W-Y's post? :s

anyways, I'm going to try out those scripts as well, but it would be nice if apple just built that function into iTunes. There's already a seperate section for radio/video/podcast. as long as everythign is seperated, having the library be music only wouldn't be such a bad thing.
MacBook Pro | 2.16 ghz core2duo | 2gb ram | superdrive | airport extreme
iBook G4 | 1.2ghz | 768mb ram | combodrive | airport extreme
iPhone 3GS | 32 GB | Jailbreak, or no Jailbreak
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 10:00 AM
 
mpancha,

You can filter for just music using smart playlists or when browsing. I see these scripts as an attempt to filter out complete albums from a library that might contain partial albums or singles, etc.
     
JLL
Professional Poster
Join Date: Apr 1999
Location: Copenhagen, Denmark
Status: Offline
Reply With Quote
Oct 27, 2005, 10:01 AM
 
Originally Posted by siMac
I'd like to create a playlist that contains only the 'full' albums in my library. This could be achieved as it is in CoverFlow, ie. either by filtering by album length or by number of tracks.

Does anyone know how I could achieve this? Smart playlists won't work because they can't access an album's duration or how many tracks it contains. Any ideas?
How about adding a comment on the songs that belong to full albums and make a smart playlist from that?
JLL

- My opinions may have changed, but not the fact that I am right.
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 10:11 AM
 
Originally Posted by JLL
How about adding a comment on the songs that belong to full albums and make a smart playlist from that?
That's exactly what I intend to do from now on. What I need for now is something to automate that process for my 8000+ track library, unless you can spare a few days to do it for me?

The script still doesn't work for me, I will carry on the investigation later today. For now I'd best do some work!
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 10:33 AM
 
siMac,

Not sure what else to say. Will try it with my folder in a different location (as per you) later.

I'm the same: I'm meant to be working
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 27, 2005, 10:39 AM
 
Why isn't the script working for you? Just copy it into Script Editor and press the Run button. It works fine for me.

In the bottom of the Script Editor window there is a "Event protocol" tab. Click this and then the Run button. Can you post the part of the protocol where the error occurs?
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 11:30 AM
 
Originally Posted by TETENAL
Why isn't the script working for you?
I wish I knew!

It's not a problem with your scripts, because they run fine on my Panther box at work, but do nothing on my Tiger machine at home. I will investigate and keep you posted.
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 11:37 AM
 
Just tried (well it beats work) with a symlinked iTunes folder (i.e. iTunes folder in /Users/shared/music) and it worked (using the application version of the script).

I'm pretty stumped. Will try when I get home on my bigger library, perhaps it's the sheer number of items causing a problem? (Applescript can have issues with this, but that's usually with Selections not playlists).
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 01:10 PM
 
OK, it's all good - I set the script going when I got home and it is currently chewing its way through my library. I don't know why it wasn't working before, the only difference is I was controlling my Mac from work via VNC earlier, and this time I am in front of it.

All the same, thanks to both of you for your help, the script works exactly as I wanted!*

(*so far at least, here's hoping it finishes well! )
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 27, 2005, 04:33 PM
 
Welll you never told us that did you

I think Applescripts can have certain issues when executed remotely. Did you have the "remote apple events" enabled?

In fact googling turned up this: http://www.macosxhints.com/article.p...31202072813173
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 27, 2005, 04:37 PM
 
I never mentioned it because I didn't see how it could possibly have been an issue, after all the script wasn't being executed remotely, only the mouse and keyboard were being controlled, all the processing happened locally.

Anyway, the script is still running (my iMac sounds like a 747), I'm gonna let it run through the night - fingers crossed...

Update: the script stopped running during the night, no idea why. I have relaunched it this morning, perhaps I'll have better luck in the daylight!
( Last edited by siMac; Oct 28, 2005 at 04:10 AM. Reason: Update.)
|\|0\/\/ 15 7|-|3 71|\/|3
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 28, 2005, 12:42 PM
 
Damn! Nothing...

Code:
tell application "iTunes" get library playlist 1 library playlist id 8779 of source id 41 display dialog "Enter Min Number of tracks per Album No. of Tracks:" default answer "" {text returned:"5", button returned:"OK"} display dialog "Enter Min Duration of Album in Minutes Min Duration:" default answer "" {text returned:"25", button returned:"OK"} display dialog "This may take a long time to run press OK to continue" {button returned:"OK"} get fixed indexing true set fixed indexing to true (*Begin part 1, get list of albums*) count every track of library playlist id 8779 of source id 41 8734 get track 1 of library playlist id 8779 of source id 41 file track id 8782 of library playlist id 8779 of source id 41 get album of file track id 8782 of library playlist id 8779 of source id 41 "Louden Up Now!" (*Added album "Louden Up Now!" to the list.*) ..... get album of file track id 17514 of library playlist id 8779 of source id 41 "Stealing of a Nation" get track 8734 of library playlist id 8779 of source id 41 file track id 17515 of library playlist id 8779 of source id 41 get album of file track id 17515 of library playlist id 8779 of source id 41 "" set fixed indexing to true (*Finished Part 1*) (*Begin Part 2: Add Albums to Playlist*) display dialog "Finished making full albums playlist!" buttons {"OK"} default button 1 with icon note current application "iTunes got an error: AppleEvent timed out."
All seemed to go well, but I have no playlist in iTunes.

F*ck it, I guess I'll have to do it by hand.
( Last edited by siMac; Oct 28, 2005 at 12:49 PM. )
|\|0\/\/ 15 7|-|3 71|\/|3
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 28, 2005, 12:45 PM
 
F*ck it, double post.
|\|0\/\/ 15 7|-|3 71|\/|3
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 28, 2005, 12:46 PM
 
F*ck it, triple post.
|\|0\/\/ 15 7|-|3 71|\/|3
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 28, 2005, 12:47 PM
 
Damn it!
|\|0\/\/ 15 7|-|3 71|\/|3
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 28, 2005, 05:22 PM
 
Originally Posted by siMac
"iTunes got an error: AppleEvent timed out."
One one command (probably one of those whose clauses) is probably taking a long time due to the large library you have and is longer than the default timeout. One would have to increase the timeout for these commands (or do without the whose').

Maybe I can change the script later.
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 28, 2005, 07:28 PM
 
SiMac,

sorry to hear about that. You could break your playlists down into smaller ones and edit the script and run it on each one.

Meant to be spending time away from the computer and with my missus so can't do much now. Will check out the time out thing tomorrow. Maybe TETENAL will sort something out sooner.
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 29, 2005, 06:15 AM
 
Originally Posted by ism
Meant to be spending time away from the computer and with my missus...
LOL, I know how that goes...
|\|0\/\/ 15 7|-|3 71|\/|3
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 29, 2005, 07:29 AM
 
Originally Posted by siMac
LOL, I know how that goes...
SiMac,

Will be a bit busy today with other stuff, but I've had a look at the "with timeout" statement.

Looks easy enough, see here

We just need an estimate for the timeout value. 12 hours? what do you reckon? If you read the link you'll see the default is only 1min!

I think we could just stick the "with timeout" statements around the repeat loops since they are the long running bits.

If you don't manage to figure it I'll be back this evening (9pm uk time)
     
TETENAL
Addicted to MacNN
Join Date: Aug 2004
Location: FFM
Status: Offline
Reply With Quote
Oct 29, 2005, 09:00 AM
 
OK. Try this version:
[PHP]tell application "iTunes"
set albumList to {}
set albumDurations to {}
set albumTrackCounts to {}
set trackCount to count of every track of library playlist 1
set processedCount to 1

display dialog "Enter Min Number of tracks per Album" & return & return & ¬
"No. of Tracks:" default answer "5"
set min_number_tracks to the (text returned of the result) as number
display dialog "Enter Min Duration of Album in Minutes" & return & return & ¬
"Min Duration:" default answer "20"
set min_album_duration to the (text returned of the result) as number

repeat while processedCount ≤ trackCount
set theAlbum to album of track processedCount of library playlist 1 as string
set add2List to true
if theAlbum is equal to "" then set add2List to false
set theAlbumIndex to my list_position(theAlbum, albumList)

if theAlbumIndex is greater than 0 then
set add2List to false
set item theAlbumIndex of albumDurations to (item theAlbumIndex of albumDurations) + the (duration of track processedCount of library playlist 1)
set item theAlbumIndex of albumTrackCounts to (item theAlbumIndex of albumTrackCounts) + 1
end if
if add2List is true then
set albumList to albumList & (theAlbum as string)
set albumDurations to albumDurations & the (duration of track processedCount of library playlist 1)
set albumTrackCounts to albumTrackCounts & 1
end if

set processedCount to processedCount + 1
end repeat

set albumsPlaylist to (make user playlist with properties {name:"Long Albums"})

set processedCount to 1
repeat while processedCount ≤ trackCount
set theAlbum to album of track processedCount of library playlist 1 as string
if theAlbum is not equal to "" then
set theAlbumIndex to my list_position(theAlbum, albumList)
if item theAlbumIndex of albumTrackCounts is greater than or equal to min_number_tracks then
if item theAlbumIndex of albumDurations is greater than or equal to min_album_duration * 60 then
duplicate track processedCount of library playlist 1 to albumsPlaylist
end if
end if
end if

set processedCount to processedCount + 1
end repeat
end tell

on list_position(this_item, this_list)
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then return i
end repeat
return 0
end list_position[/PHP]

I don't think this can time out for you.
     
ism
Grizzled Veteran
Join Date: Sep 2001
Status: Offline
Reply With Quote
Oct 29, 2005, 04:28 PM
 
Hey,

Don't think I'll have time to look at it right now, so I'm glad TETENAL's come up with something. I did a bit of looking into the timeout issue and that isn't necessarily the solution since Applescript can suffer with large values of data, etc. I.e. lots of songs. The "set a reference" bit in my script was meant to get around this, but the second bit of the script doesn't use this so I guess that's where the problem is with mine.

Hopefully TETENAL's will work otherwise I might not get around to it until Monday (I'll get into trouble with the powers that be otherwise)
     
siMac  (op)
Mac Elite
Join Date: Aug 2004
Location: ZZ9 Plural Z Alpha
Status: Offline
Reply With Quote
Oct 31, 2005, 01:42 PM
 
Thanks again for the help guys. I'm not sure timeout was the problem because it ran for at least five hours without any trouble - it seems my computer is just bizarre.

In any case I had some free time the other night so I bit the bullet and did the job manually. I will certainly keep this script on hand though as I don't relish having to perform that task again!
|\|0\/\/ 15 7|-|3 71|\/|3
     
 
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 09:12 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,