Forum » Development Discussion

(Script) Create iTunes 'Loved Tracks' Playlist

 
    • bathat ha detto...
    • Utente
    • Ago 16 2008, 4:22

    (Script) Create iTunes 'Loved Tracks' Playlist

    *** Mac ONLY ***

    I've created a Python script that goes through your Loved Tracks and creates an iTunes playlist out of them.

    This script will be excellent for anyone not wanting to subscribe simply to play their Loved Tracks. It's also for those with hundreds of such tracks who are looking for an automated approach to collect them.

    I tried to make it work in Windows but it just wasn't possible.
    Alright, so that's not entirely true... However, due to sparse documentation; the script took look enough to create as it was for Mac. I'm simply not in the mood to add functionality for Windows too. Sorry. I would naturally assume most iTunes users are also Mac users, so hopefully it won't be a huge deal.


    I've determined that this does not work with Python 2.6 for some unknown reason. However, it is guaranteed to work under Python 2.5.1.

    Due to the excessive tedium of AppleScript, I decided to use a Python module called Appscript. Therefore, users will need to install it first. Directions and the download link can be found here. (the script downloads and installs the module for you). Of course, if you don't already have Python (which is quite likely), you'll need to install it first. (nothing I can do about this one... Catch-22).

    As of right now, there are at least a few bugs and/or nice features missing. I'm bringing it into the light now since I've been toiling away on it for quite some time and because it will be helpful for users.

    1. It will search through all Loved Tracks EVERY TIME. However, once you run the script once, you're pretty much set.
    (I'm not sure if there's any way around this... I had an idea, but it may not work).

    2. It does not verify whether the track already exists in the playlist, which means if you run it say, twice there will be a duplicate of every track. If you run it multiple times, it's advisable to delete all tracks from the playlist first.

    3. It currently only creates a playlist entitled "Loved Tracks."

    It's still a bit of a work in progress, but it also works quite well.


    To run the script on a Mac, open a terminal and type:
    python [path to script] [username]

    On a Windows box, open an MS-DOS prompt and type:
    python [path to script] [username]

    I'm not sure if this will work for Windows users and I can't test it (easily). It may be necessary to specify the full path (i.e. 'C:/Python') in MS-DOS.


    I may create a simple GUI at some point for the less technical users.


    I hope this program comes in handy.

    I've also recently created a script to copy all Loved Tracks to an MP3 player. If you would be interested in such a thing, send me a message.


    => Download <=

    Modificato da bathat in data Gen 23 2009, 3:33
  • thanks!

    I was just about to respond saying "this is effing awesome" as it iTunes prompted me for the name of my new playlist....

    then I got the following error ;) I'm still going to say this is effing awesome though because I do have a 47 track playlist, I assume the reason it crapped out (see below) is that I don't have some of the song's on my playlist in my itunes library...

    Traceback (most recent call last):
    File "loved.py", line 129, in <module>
    songsList = (iTunes.search(playlists[0], for_=unicode(track.keys()), only=k.songs))
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128)

  • awesome :)

  • !!

    Fantastic!! Thank you Michael!

    • brand929 ha detto...
    • Abbonato
    • Ott 11 2008, 5:39
    This is beyond perfection. Thanks!

  • is this for mac too?

    • c4t2007 ha detto...
    • Utente
    • Ott 22 2008, 6:58
    Thanks. I don't like iTunes, though. But with http://www.davidlomas.com/playlistconverter/ i could convert it to WinAmp format.

    “Brazil’s cattle industry [...] is responsible for about 80 percent of all deforestation in the Amazon. In fact, the Brazilian cattle industry is the largest single source of deforestation anywhere in the world. And deforestation in turn causes one-fifth of all the greenhouse gas emissions in the world, more than all the world’s cars, trucks, trains, planes, and ships combined.” - Lindsey Allen, 2009. Actually one-tenth.
    Child labour: the tobacco industry's smoking gun
    Up to 90 percent of logging has ties to organized crime in some tropical countries.
  • It didn't work for me. Here's what came out of Terminal. BTW, running OS X Leopard 10.5.5 and Python 2.5.1

    python ~/Downloads/loved.py dssolveinlove
    downloading appscript module...
    done.

    decompressing archive...
    installing appscript module...
    Password:
    running install
    running bdist_egg
    running egg_info
    writing Lib/appscript.egg-info/PKG-INFO
    writing top-level names to Lib/appscript.egg-info/top_level.txt
    writing dependency_links to Lib/appscript.egg-info/dependency_links.txt
    reading manifest file 'Lib/appscript.egg-info/SOURCES.txt'
    writing manifest file 'Lib/appscript.egg-info/SOURCES.txt'
    installing library code to build/bdist.macosx-10.5-i386/egg
    running install_lib
    running build_py
    creating build
    creating build/lib.macosx-10.5-i386-2.5
    copying Lib/mactypes.py -> build/lib.macosx-10.5-i386-2.5
    copying Lib/osascript.py -> build/lib.macosx-10.5-i386-2.5
    copying Lib/osax.py -> build/lib.macosx-10.5-i386-2.5
    creating build/lib.macosx-10.5-i386-2.5/CarbonX
    copying Lib/CarbonX/__init__.py -> build/lib.macosx-10.5-i386-2.5/CarbonX
    copying Lib/CarbonX/AE.py -> build/lib.macosx-10.5-i386-2.5/CarbonX
    copying Lib/CarbonX/kAE.py -> build/lib.macosx-10.5-i386-2.5/CarbonX
    copying Lib/CarbonX/kOSA.py -> build/lib.macosx-10.5-i386-2.5/CarbonX
    copying Lib/CarbonX/OSA.py -> build/lib.macosx-10.5-i386-2.5/CarbonX
    creating build/lib.macosx-10.5-i386-2.5/aem
    copying Lib/aem/__init__.py -> build/lib.macosx-10.5-i386-2.5/aem
    copying Lib/aem/findapp.py -> build/lib.macosx-10.5-i386-2.5/aem
    creating build/lib.macosx-10.5-i386-2.5/aem/send
    copying Lib/aem/send/__init__.py -> build/lib.macosx-10.5-i386-2.5/aem/send
    copying Lib/aem/send/connect.py -> build/lib.macosx-10.5-i386-2.5/aem/send
    copying Lib/aem/send/errors.py -> build/lib.macosx-10.5-i386-2.5/aem/send
    copying Lib/aem/send/send.py -> build/lib.macosx-10.5-i386-2.5/aem/send
    creating build/lib.macosx-10.5-i386-2.5/aem/types
    copying Lib/aem/types/__init__.py -> build/lib.macosx-10.5-i386-2.5/aem/types
    creating build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    copying Lib/aem/types/basictypes/__init__.py -> build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    copying Lib/aem/types/basictypes/pack.py -> build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    copying Lib/aem/types/basictypes/typewrappers.py -> build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    copying Lib/aem/types/basictypes/unittypes.py -> build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    copying Lib/aem/types/basictypes/unpack.py -> build/lib.macosx-10.5-i386-2.5/aem/types/basictypes
    creating build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    copying Lib/aem/types/objectspecifiers/__init__.py -> build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    copying Lib/aem/types/objectspecifiers/base.py -> build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    copying Lib/aem/types/objectspecifiers/specifier.py -> build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    copying Lib/aem/types/objectspecifiers/testclause.py -> build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    copying Lib/aem/types/objectspecifiers/unpackspecifier.py -> build/lib.macosx-10.5-i386-2.5/aem/types/objectspecifiers
    creating build/lib.macosx-10.5-i386-2.5/aemreceive
    copying Lib/aemreceive/__init__.py -> build/lib.macosx-10.5-i386-2.5/aemreceive
    copying Lib/aemreceive/handlererror.py -> build/lib.macosx-10.5-i386-2.5/aemreceive
    copying Lib/aemreceive/main.py -> build/lib.macosx-10.5-i386-2.5/aemreceive
    copying Lib/aemreceive/sfba.py -> build/lib.macosx-10.5-i386-2.5/aemreceive
    copying Lib/aemreceive/typedefs.py -> build/lib.macosx-10.5-i386-2.5/aemreceive
    creating build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/__init__.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/genericreference.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/keywordwrapper.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/reference.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/referencerenderer.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/terminology.py -> build/lib.macosx-10.5-i386-2.5/appscript
    copying Lib/appscript/terminologyparser.py -> build/lib.macosx-10.5-i386-2.5/appscript
    creating build/lib.macosx-10.5-i386-2.5/appscript/tools
    copying Lib/appscript/tools/__init__.py -> build/lib.macosx-10.5-i386-2.5/appscript/tools
    copying Lib/appscript/tools/aemcodegen.py -> build/lib.macosx-10.5-i386-2.5/appscript/tools
    copying Lib/appscript/tools/dump.py -> build/lib.macosx-10.5-i386-2.5/appscript/tools
    creating build/lib.macosx-10.5-i386-2.5/osaterminology
    copying Lib/osaterminology/__init__.py -> build/lib.macosx-10.5-i386-2.5/osaterminology
    copying Lib/osaterminology/appscripttypedefs.py -> build/lib.macosx-10.5-i386-2.5/osaterminology
    copying Lib/osaterminology/makeidentifier.py -> build/lib.macosx-10.5-i386-2.5/osaterminology
    copying Lib/osaterminology/objcappscripttypedefs.py -> build/lib.macosx-10.5-i386-2.5/osaterminology
    creating build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/__init__.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/aeteparser.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/applescripttypes.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/appscripttypes.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/objcappscripttypes.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/osadictionary.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    copying Lib/osaterminology/dom/sdefparser.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/dom
    creating build/lib.macosx-10.5-i386-2.5/osaterminology/getterminology
    copying Lib/osaterminology/getterminology/__init__.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/getterminology
    creating build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/__init__.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/htmldoc.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/htmldoc2.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/inheritance.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/quickdoc.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/relationships.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/textdoc.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    copying Lib/osaterminology/renderers/typerenderers.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/renderers
    creating build/lib.macosx-10.5-i386-2.5/osaterminology/sax
    copying Lib/osaterminology/sax/__init__.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/sax
    copying Lib/osaterminology/sax/aeteparser.py -> build/lib.macosx-10.5-i386-2.5/osaterminology/sax
    running build_ext
    building 'CarbonX._AE' extension
    creating build/temp.macosx-10.5-i386-2.5
    creating build/temp.macosx-10.5-i386-2.5/Modules
    creating build/temp.macosx-10.5-i386-2.5/Modules/CarbonX
    gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c Modules/CarbonX/_AEmodule.c -o build/temp.macosx-10.5-i386-2.5/Modules/CarbonX/_AEmodule.o
    unable to execute gcc: No such file or directory
    error: command 'gcc' failed with exit status 1
    done.

    Proceed? (y/n) y

    Apparently, something has gone wrong during the installation process. Please install the module manually from the appscript-0.18.1 directory.
    Traceback (most recent call last):
    File "/Users/jonduenas/Downloads/loved.py", line 66, in <module>
    iTunes = app('iTunes')
    NameError: name 'app' is not defined


    It ended up switching me over to iTunes with a dialog to name the playlist, but when I confirmed it, there's still no playlist in iTunes.

    • maplejet ha detto...
    • Utente
    • Nov 8 2008, 5:38
    Tag for later, looks interesting though.

    • [Utente eliminato] ha detto...
    • Utente
    • Nov 21 2008, 4:50
    So this does not work for Windows then?

  • I would naturally assume most iTunes users are also Mac users

    Are you having a laugh?

    • craq ha detto...
    • Utente
    • Dic 19 2008, 8:01

    craq

    dssolveinlove said:
    It didn't work for me. ....
    Apparently, something has gone wrong during the installation process. Please install the module manually from the appscript-0.18.1 directory.
    Traceback (most recent call last):
    File "/Users/jonduenas/Downloads/loved.py", line 66, in <module>
    iTunes = app('iTunes')
    NameError: name 'app' is not defined


    It ended up switching me over to iTunes with a dialog to name the playlist, but when I confirmed it, there's still no playlist in iTunes.


    Same for me. :S

  • Girraffe!
    I'm with themusicaddict, thanks anyway

    Saluda's, mi chica!
    Got to hurry on back to my hotel room,
    Where I've got me a date with Botticelli's niece.
    • losena ha detto...
    • Utente
    • Gen 24 2009, 13:28




    ❄★♫♪•♥ ! ♥ •♫♪★❄ ★♥★♥
    • Nochek ha detto...
    • Utente
    • Gen 31 2009, 5:47
    Thanks Michael :)

  • I have the same question as fl-_-wers. Will this not work for Windows?

    Check out my digital town!
    http://hafnarfjorur.myminicity.com/tra
  • I'm not sure what to type in to Terminal, nothing works

    • Dee_One ha detto...
    • Utente
    • Feb 22 2009, 15:01

    Thanks!

    * Thank u Michael, u r great :)

    • fmera ha detto...
    • Utente
    • Feb 26 2009, 4:16
    thks. found this link on trilby's shoutbox ;)

    U.G.L.Y. - changing the face of music, one artist at a time.
    there are some things pngs can't fix. for everything else, there's pngoptimizer.
  • Thanks, but i'm windows and winamp user at the moment, thank you anyway. :-]

  • Nice idea! One day someone may write it for us windows dinosaurs! :)

    • Sagehorn ha detto...
    • Utente
    • Mar 5 2009, 18:10
    lol... mac-users are soo cool... and itunes is just for theeem ^^

    okay.. i guess it won't work on windows.. but i won't switch my os for this.. writing such a tool is not that hard :P

  • Kicks Rocks!

    Mac Only?! :-(

    GaGa's SpokesBiTch!



    Musical Genius!=)
  • The script works great! thanks a lot!

  • Someone who knows how to write such script could do a kind thing by writing it for Windows.

Gli utenti anonimi non possono inviare messaggi. Per inserire messaggi nei forum, accedi o crea il tuo account.