Categories: Misc / DotNet / Java / Coder / Linux / PHP Ask - La ask - La Answer

An Applescript Id like to see...

Not sure if this might belong in Wishlist Forum, but thats an iPod wish list...

I want an applescript that would search my library for a list of tunes I give it, and create a playlist based on that list, and report on which tunes it could not find.

Such a script would be very handy for automating an iTunes Music Store search as well perhaps.

I have a ton of tunes, and like it when Mojo or some other magazine prints a list of 100 greatest singles ever... Now I am pretty sure I have some of them, but to actually check for each title would be laborious, and I have a lot of compilation records that may show I have a song I didn't realize I had..

So you would create a list in plain text like so

River Deep, Mountain High<tab>Ike and Tina Turner
Under My Thumb<tab>Rolling Stones

and at the very least, the script would spit out a report of the songs it could NOT find.

How doable is this?
[976 byte] By [Thumbtwiddler] at [2007-11-9 12:11:52]
# 1 Re: An Applescript Id like to see...
How doable is this?

It depends. How specific do you want the search to be? How accurate are your song's tags? How many songs are in your iTunes Library?

The string search function in iTunes is, unfortunately, not scriptable. That means that whatever text is in the text document, the result will be a boolean true/false as to whether it matches. If the song is called "River Deep, Mountain High" in the text file and "River Deep Mountain High" in iTunes, a false value will be returned.
eustacescrubb at 2007-11-15 16:47:47 >
# 2 Re: An Applescript Id like to see...
Originally posted by eustacescrubb
It depends. How specific do you want the search to be? How accurate are your song's tags? How many songs are in your iTunes Library?

The string search function in iTunes is, unfortunately, not scriptable. That means that whatever text is in the text document, the result will be a boolean true/false as to whether it matches. If the song is called "River Deep, Mountain High" in the text file and "River Deep Mountain High" in iTunes, a false value will be returned.

But if the list said River Deep Mountain High, it would find River Deep, Mountain High, would it not, at least the search function works that way. It is the case where the search phrase has MORE than the actual title that will come up null.

It may be easier to do this as a scripted finder search anyway, such as looking at the MP3's themselves.

What I want ideally want is, script reads a text file (the list to match), searches the library, places the matches in a playlist, and reports what is missing. Of course you could cut out some steps, do some of this yourself, the tedious part is actually the search.

If I knew how to script I would probably do something like this

Export Library Summary Title Artist
Read List (prompt for location and name)
Compare List to Library Summary (prompt for location and name)
Read Line 1 in List
Search Summary for Line 1
If Line 1 is in Summary, Line 1 equal true
If Line 1 is not in Summary Line 1 equal false
repeat for line n +1
Print True as "List Tunes found"
Print False as "List Tunes Not Found"

It would be the same as typing in the search and hitting return each time, except you can pull the search phrase from a pretyped list, and a tally is kept if there is a hit. You could of course end up with false positives and false negatives but some of the humdrum is removed.

With a quick glance at the list I could say -- "oh, I have 40 from that list of 50, or whatever, I could find the rest or settle for the subset I have."

The more sophisticated script would say, "A playlist based on your list has been created, finding 40 out of fifty choices."
Thumbtwiddler at 2007-11-15 16:48:50 >
# 3 Re: An Applescript Id like to see...
But if the list said River Deep Mountain High, it would find River Deep, Mountain High, would it not, at least the search function works that way.

The search function works that way, but that's what my point was with saying AppleScript doesn't have access to it and therefore can't do a string search. The best you'd be able to do with AppleScript is a perfect match.
eustacescrubb at 2007-11-15 16:49:49 >
# 4 Re: An Applescript Id like to see...
Originally posted by eustacescrubb
The search function works that way, but that's what my point was with saying AppleScript doesn't have access to it and therefore can't do a string search. The best you'd be able to do with AppleScript is a perfect match.

I think I am just going to compare text files in BBEdit or such, although that may be almost as much work as just sitting and doing the same with an open iTunes window.

I still think it would be a killer script though... Make a Playlist including <List>.

It would run pretty #### slow too, I bet.
Thumbtwiddler at 2007-11-15 16:50:55 >
# 5 Re: An Applescript Id like to see...
It would run pretty #### slow too, I bet.

Incredibly. Especially if your Library is big.

If you have BBEdit, you might be able to use a BBEdit/iTunes combo script of some kind - get AppleScript to open an exported xml of your iTunes Library, look for song titles with BBEdit's (more powerful) search features, then generate a list of database IDs, which could be used to make a playlist in iTunes.
eustacescrubb at 2007-11-15 16:51:54 >
# 6 Re: An Applescript Id like to see...
Originally posted by eustacescrubb
Incredibly. Especially if your Library is big.

If you have BBEdit, you might be able to use a BBEdit/iTunes combo script of some kind - get AppleScript to open an exported xml of your iTunes Library, look for song titles with BBEdit's (more powerful) search features, then generate a list of database IDs, which could be used to make a playlist in iTunes.

Sure. Now only if I could script...

I can do a few grep searches in BBEdit, but I have only tweaked applescript enough to change a few parameters to customize a pre-existing script. What I want to do might be able to be done with scripts already available, but it is the act of stringing them all together for even a subset of what I would like to do which eludes me.

Perhaps among the finder and BBEdit and iTunes, some of those are even recordable as far as creating a script (That is, applescript can watch what you do, and create the script). But at this point I think merely using the existing find engines, either within BBEdit or iTunes, and checking things off the list by hand is going to be my best bet. At least some of the magazine generated lists I would like to try to compile are available online, so some typing would be saved there.

Maybe some eager scripters are reading over my shoulder...

The biggest problem, as you first mentioned, is if this were sucessfully automated, the amount of false positives and negatives that might be found.
Thumbtwiddler at 2007-11-15 16:52:51 >
# 7 Re: An Applescript Id like to see...
The Find box in iTunes works really quickly, and may help you out much quicker. Especially since it updates each time you hit a key. So, once you have typed "moun", you will probably only have 3 or 4 songs listed, and can easily tell if you have that track or not.
thenightfly42 at 2007-11-15 16:53:55 >
# 8 Re: An Applescript Id like to see...
Originally posted by thenightfly42
The Find box in iTunes works really quickly, and may help you out much quicker. Especially since it updates each time you hit a key. So, once you have typed "moun", you will probably only have 3 or 4 songs listed, and can easily tell if you have that track or not.

Oh sure. I use that all the time by the way:)

That isn't what I am trying to do however, I really want to narrow down the list without my active involvement, without keeping a checklist nearby. Typing would be faster than cut and paste, or any script, But even then, doing it a hundred times gets old. You could mentally edit out a lot of the stuff you KNOW you have, but you may still need to verify.

Fer instance , I only probably really need to concentrate on 10 - 20 percent of the following list. Even if I had a bot that would type in the search field, then add that song to a playlist it is building, I would have to weed out multiple versions and covers. Just typing Good Vibrations brings up 72 songs from my library, because there is a boxed set by that name. But to type the list for you now, I just cut and pasted.

1. Good Vibrations - Beach Boys
2. Strawberry Fields Forever/Penny Lane - The Beatles
3. Like A Rolling Stone - Bob Dylan
4. Be My Baby - The Ronetts
5. I Heard It Through The Grapevine - Marvin Gaye
6. (I Can't Get No) Satisfaction - The Rolling Stones
7. Hey Jude / Revolution - The Beatles
8. River Deep Mountain High - Ike & Tina Turner
9. Smells Like Teen Spirit - Nirvana
10. Whats Going On - Marvin Gaye
11. Don't Worry Baby - The Beach Boys
12. Hey Joe - Jimi Hendrix Experience
13. You've Lost That Loving Feeling - The Righteous Brothers
14. I Want To Hold Your Hand - The Beatles
15. Respect - Aretha Franklin
16. Heartbreak Hotel - Elvis Presley
17. (Sittin' On) The Dock Of The Bay - Otis Redding
18. Born To Run - Bruce Springsteen
19. Mr Tambourine Man - The Byrds
20. God Save The Queen - The Sex Pistols
21. Family Affair - Sly And The Family Stone
22. A Whiter Shade Of Pale - Procol Harum
23. Dancing In The Street - Martha And The Vandellas
24. Summertime Blues - Eddie Cochran
25. That'll Be The Day - Buddy Holly And The Crickets
26. When Doves Cry - Prince
27. Jumpin' Jack Flash
28. God Only Knows - The Beach Boys
29. Paperback Writer / Rain - The Beatles
30. You Really Got Me - The Kinks
31. A Change Is Gonna Come - Sam Cooke
32. Reach Out I'll Be There - The Four Tops
33. I Can't Stand The Rain - Ann Peebles
34. "Heroes" - David Bowie
35. Papa's Got A Brand New Bag - James Brown
36. Imagine - John Lennon
37. Superstition - Stevie Wonder
38. Runaway - Del Shannon
39. Space Oddity - David Bowie
40. Bohemian Rhapsody - Queen
41. Green Onions - Booker T And The MGs
42. Why Do Fools Fall In Love - Frankie Lymon And The Teenagers
43. Purple Haze - The Jimi Hendrix Experience
44. Cathy's Clown - Everly Brothers
45. Lets Stay Together - Al Green
46. Something In The Air - Thunderclap Newman
47. Stay With Me - Lorraine Ellison
48. I Wan't You Back - The Jackson Five
49. Wichita Lineman - Glen Campbell
50. Honky Tonk - Bill Doggett
51. Louie, Louie - The Kingsmen
52. What'd I Say - Ray Charles
53. Unchained Melody - The Righteous Brothers
54. Spanish Harlem - Ben E. King
55. Live Forever - Oasis
56. Help! - The Beatles
57. Love Will Tear Us Apart - Joy Division
58. House Of The Rising Sun - The Animals
59. Don't Dream It's Over - Crowded House
60. Proud Mary - Creedence Clearwater Revival
61. Ghost Town - The Specials
62. Day Tripper - The Beatles
63. Telegram Sam - T. Rex
64. Be-Bop-A-Lula - Gene Vincent
65. Starman - David Bowie
66. Unfinished Sympathy - Massive Attack
67. Addicted To Love - Robert Palmer
68. Anarchy In The Uk - Sex Pistols
69. Brown Eyed Girl - Van Morrison
70. Gangsta's Paradise - Coolio
71. If You Don't Know Me By Know - Harold Melvin And The Blue Notes
72. Honky Tonk Woman - The Rolling Stones
73. When A Man Loves A Woman - Percy Sledge
74. Bridge Over Troubled Water - Simon And Garfunkel
75. For What It's Worth - Buffalo Springfield
76. Mystery Train - Elvis Presley
77. Stupid Girl - Garbage
78. Knowing Me, Knowing You - Abba
79. Get Up (I Feel Like Being A) Sex Machine - James Brown
80. (Don't Fear) The Reaper - Blue Oyster Cult
81. Cold, Cold Heart - Hank Williams
82. Wonderwall - Oasis
83. Autobahn - Kraftwerk
84. Rebel Rouser - Duane Eddy
85. Whole Lotta Shakin' Goin' On - Jerry Lee Lewis
86. Relax - Frankie Goes To Hollywood
87. The Tracks Of My Tears - The Miracles
88. Blue Monday - New Order
89. Crying - Roy Orbison
90. She's Not There - The Zombies
91. Every Breath You Take - The Police
92. Walk This Way - Run DMC
93. Walk On By - Dionne Warwick
94. Virginia Plain - Roxy Music
95. Long Tall Sally - Little Richard
96. Subterranean Homesick Blues - Bob Dylan
97. I Can Never Go Home Anymore - The Shangri-Las
98. The Boys Of Summer - Don Henley
99. Stop! In The Name Of Love - The Supremes
100. I've Got You Under My Skin - Frank Sinatra
Thumbtwiddler at 2007-11-15 16:54:58 >
[an error occurred while processing this directive]
[an error occurred while processing this directive]