[RELEASE] iTunes Playlist Importer Addon - Convert all iTunes Playlists to XBMC's M3U
#1
Thumbs Up 
Hello all,


I'm using XBMC with many mac in my house, XBMC use itunes directory to play music, It works like a charm.

But the support of playlists was missing.

I've made an addon which parse itunes library and export all playlist in many m3u files, and put them in the playlist directory of XBMC, so no additionnal actions needed.

1) put the folder script.itunes2m3u to XBMC/addons folder / or import by zip file with XBMC.
2) In the addon configuration, select the library file

the 2 other settings about old path / new path are optional

=== Your songs are not in the same location than iTunes think ===

I had a problem with my script, because iTunes think that each file are stored to "c:\Document and Settings\user\Music\iTunes Media\" but from my XBMC computer, music are accessible through another path wich is "smb:\\windows_computer\my_network_share\iTunes Media\".
If I did not changed the path to my music, playlist will not played because songs will not be found, So I create a "replace" function, which will parse all songs path and change "old path" to the "new path"

so, if the path to music files referenced in the library.xml is not the right one (point of view from computer running XBMC), then the script can replace the "old path" to the "new path".

3)In the addon configuration, select the new path to your music files
4) In the addon configuration, enter the old path which need to be converted

ex : I'm running XBMC under linux, my music files are located in my windows computer, my iTunes library too.
the location of each music will not be "c:\Document and Settings\user\Music\iTunes Media\Black eyes Peas.mp3" (as iTunes think) but "smb:\\windows_computer\my_network_share\iTunes Media\Black eyes Peas.mp3"

here :

- old path : "c:\Document and Settings\user\Music\" (have to be typed manually)
- new path : "smb:\\windows_computer\my_network_share\" (wich have to be browseabe, cause your XBMC installation should have access to)

=== Running ===

And then you can run the script, wait few seconds (depending of your processor&library size)

Your playlists should be created, you can use them directly in XBMC music -> playlist

some thinks are taken from http://granades.com/2009/01/02/convertin...playlists/

here is the repository, I don't know how to add to the main repository.

http://code.google.com/p/itunestom3u/

please send me any modification or post them to the repository !

===== how it works =====

- itunes library is a file where songs are associated with an unique number ID and an absolute location (and other things), and playlist are composed of a name and all unique ID song concerned.
- a m3U playlist is just a list of music file path


a librarie (plistloader) take care of understanding/working with iTunes library as of the apple standard.
my librarie (xmltom3u) parse the entire iTunes library, associate playlist with files, and creates playlists files.
my XBMC python script (addon.py) just interface library to XBMC (path selection, description, XBMC things, put playlists in the default XBMC playlist folder, ...)

=== What could be not working / I've no tested ===
- running under mac OS / Windows
- import via Zip file from XBMC
- in another version than last dharma / SVN
- local music & library

=== my working situation ===

XBMC SVN compiled at 28-10-10 running under ubuntu 10.10
iMac OSX 10.6 with itunes 10, the iTunes folder is Shared
iTunes is ordering the music automatically (all music files in local iTunes Media)



if it's working in these non-tested cases, tell me !
Reply
#2
Will try when I get home, if it works, nice job.
Image
To learn more, click here.
Reply
#3
very nice, will try out soon. All that's needed now is some way to import song ratings! With regards to how to submit to the official repository, see here: http://wiki.xbmc.org/index.php?title=Off...Repository
Reply
#4
Code:
4) In the addon configuration, enter the part old path who need to be converted

Hello

Can you elaborate on above? Why do I need to convert the path?

My iTunes Library.xml (version 10.0.1) is in:

/Volumes/iMac File Server HD/iTunes Library/Main/iTunes Library.xml

while my Music files folder is in:

/Volumes/FreeAgent 1TB FW/iTunes Media/Music/

What would my converted path looks like?

Thanks.


AppleTV+Dharma Beta4 / Mac OS X 10.6.4
Reply
#5
if your iTunes library and music are on your computer running XBMC, you don't need to change the path, so the 2 last settings are not needed

But if your itunes library and music are in another computer, the script have to replace "/Volumes/iMac File Server HD/iTunes Media" to "smb://imac/shared_folder/iTunes Media" in order that the music path be right.

the two options "part to the old path" and "path to music" are for this issue.
Reply
#6
Thanks for explaining on the settings; the script is working now.

However, initially the script would terminate half-way through. I looked at the xbmc.log and is able to fixed the issue:

http://pastebin.ubuntu.com/529113/

The script chokes when it encounters an iTunes playlist with a "/" in its name, such as "Justin Timberlake - FutureSex/LoveSound" The script runs just fine once I changed all occurrence of "/" to "-". It's not ideal but it works.

I'm hoping you can program the script to work with the "/" character, as iTunes allows "/" in the name of a playlist.

Thanks for the script; it changes how I use my AppleTV; no longer do I need to use Frontrow for Music but stay in XBMC for my iTunes playlists instead. It's fantastic!


Btw, the progress window does not animate to show the progress… but that's not important.
Reply
#7
Yes, the name of the playlist is directly transformed as filename, but some characters are not allowed.

There is no pre existing function in python to take care of that, I've to make a regex line, but all of these characters will be transformed to another one, so the best issue for you is to do that yourself for the moment.
Reply
#8
Hi,

Firstly, thanks to the author for the plugin - I originally thought I was going to have to individually export all my playlists from iTunes - this would have been a nightmare since I have a lot of music....

I had one issue.... my iTunes library xml file has my path as

file://localhost/Volumes/ATV/Music

my actual path on my server is

/media/USB/Music

path substitution as described by the author totally worked and produced playlists with the correct path:

file://localhost/media/USB/Music

which xbmc couldn't play from..... guess it doesn't parse the file://localhost bit...

Anyway, if anyone else has this problem on a Linux install, they can run:

Code:
sed -i 's/file:\/\/localhost\//\//g' /home/xbmc/.xbmc/userdata/playlists/music/*.m3u

which will strip file://localhost off the paths from all your music playlist files (for a live type install like mine - sub your own username for xbmc above if it is different). This produces m3u files that xbmc can play from.

Anyway, since this plugin was sent from heaven for me, I just wanted to give a little tip back to anyone with the same problem as me. However, don't blame me if you nuke your playlists! Laugh

All I can tell you is it works for me....

Jim
Reply
#9
Hi,

I tried to run this plugin on OSX 10.6.x with the stable Dharma release. Unfortunately no luck getting it to work.

Here's the Pastebin of the XBMC Log. Hope this helps

Alfred.
Reply
#10
Just saw this,very cool! Anyone knows whether this is still working? Plans to add it to the official repo?
Server: Asus Sabertooth Z77 | Intel Core i5 3.4 GHz | 16 GB DDR3 | 128 GB SSD, 82 TB (9 x 6 TB, 7 x 4 TB)
HTPC 1: Raspberry Pi 2 | HTPC 2: Raspberry Pi 2 | HTPC 3: Raspberry Pi
Reply
#11
will this work on ATV2?
Reply
#12
Hi,

I have the following setup...

NAS with the iTunes Library.xml and files on it.
Desktop which I use to run iTunes from and sync with my i devices.
HTPC running WIN7 and XBMC

Both the desktop and HTPC are setup with the Music share on the NAS mapped as X.

The iTunes Library.xml uses the following as it's path...

key>Music Folder</key><string>file://localhost/X:/iTunes%20Music/</string>

Should I enter the following into the options for the plugin?

Old path: file://localhost/X:/
New path: X:/

Then the million dollar question...

How do I run the script!!!

Thanks in advance for any help.
Reply
#13
the optional "old path" & "new path" are there if you want to change where music are.

if your songs are not located at "file://localhost/X:/iTunes%20Music/" you can change the location to the real path of your songs directory. (the script will search "old path" and will replace by "new path")
Reply
#14
Getting the following errors:


10:27:54 T:2958184448 DEBUG: WaitOnScriptResult - waiting on the iTunes Playlist Importer plugin...
10:27:54 T:2955980800 NOTICE: -->Python Interpreter Initialized<--
10:27:54 T:2955980800 DEBUG: Process - The source file to load is /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py
10:27:54 T:2955980800 DEBUG: Process - Setting the Python path to /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u:/Users/maurice/Library/Application Support/XBMC/addons/script.module.simplejson/lib:/Users/maurice/Library/Application Support/XBMC/addons/script.module.beautifulsoup/lib:/Applications/XBMC.app/Contents/Resources/XBMC/addons/script.module.pil/lib:/Applications/XBMC.app/Contents/Resources/XBMC/addons/script.module.pysqlite/lib:/Applications/XBMC.app/Contents/Frameworks:/Applications/XBMC.app/Contents/Frameworks/lib/python26.zip:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/plat-darwin:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/plat-mac:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/plat-mac/lib-scriptpackages:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/lib-tk:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/lib-old:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/lib-dynload:/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/site-packages:
10:27:54 T:2955980800 DEBUG: Process - Entering source directory /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u
10:27:54 T:2955980800 DEBUG: Instantiating addon using automatically obtained id of "script.itunestom3u" dependent on version 1.0 of the xbmc.python api
10:27:54 T:2955980800 ERROR: /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py:36: SyntaxWarning: import * only allowed at module level
def __init__(self):
10:27:54 T:2955980800 ERROR: /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py:20: DeprecationWarning: os.getcwd() currently lies to you so please use addon.getAddonInfo('path') to find the script's root directory and DO NOT make relative path accesses based on the results of 'os.getcwd.'
PLUGIN_PATH = xbmc.translatePath(os.getcwd())
10:27:54 T:2955980800 ERROR: /Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py:30: DeprecationWarning: os.getcwd() currently lies to you so please use addon.getAddonInfo('path') to find the script's root directory and DO NOT make relative path accesses based on the results of 'os.getcwd.'
addon = xbmcaddon.Addon(id=os.path.basename(os.getcwd()))
10:27:55 T:2894398144 DEBUG: ------ Window Init (DialogBusy.xml) ------
10:27:55 T:2894398144 DEBUG: Alloc resources: 0.01ms (0.00 ms skin load)
10:27:56 T:2958184448 INFO: Loading skin file: DialogProgress.xml
10:27:56 T:2958184448 DEBUG: Load DialogProgress.xml: 4.86ms
10:27:56 T:2958184448 DEBUG: DialogProgress::StartModal called
10:27:56 T:2958184448 DEBUG: ------ Window Init (DialogProgress.xml) ------
10:27:56 T:2958184448 DEBUG: Alloc resources: 0.29ms (0.00 ms skin load)
10:27:59 T:2894398144 DEBUG: ------ Window Deinit (Pointer.xml) ------
10:28:14 T:2955980800 INFO: -->Python script returned the following error<--
10:28:14 T:2955980800 ERROR: Error Type: <type 'exceptions.KeyError'>
10:28:14 T:2955980800 ERROR: Error Contents: ('Location',)
10:28:14 T:2955980800 ERROR: Traceback (most recent call last):
File "/Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py", line 81, in <module>
run_program = Main()
File "/Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/addon.py", line 70, in __init__
number_playlist= itunesconvert(libraryfile,oldmusicpath,musicpath,m3u_path)
File "/Users/maurice/Library/Application Support/XBMC/addons/script.itunestom3u/resources/lib/xmltom3u.py", line 37, in itunesconvert
fileloc_quote = playlist['Tracks'][str(track_id)]['Location']
KeyError: ('Location',)
10:28:14 T:2955980800 INFO: -->End of Python script error report<--
10:28:14 T:2894398144 DEBUG: ------ Window Init (DialogKaiToast.xml) ------
Reply
#15
Thumbs Up 
Hey just wanted to say this script works pretty well and is very useful. It works fine in Eden Beta 3 on Windows 7 the first time you run it. It does exactly what it says it will do. What I've found though is that you can't run it twice or it gets a script error. You have to restart XBMC to rerun it. I'm assuming the scheduled update won't work either due to this.

Not a big deal, but this looks like an old thread and wanted to see if you were still doing development on this. I love it and would love it even more if it would regularly pull down playlists. Thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
[RELEASE] iTunes Playlist Importer Addon - Convert all iTunes Playlists to XBMC's M3U0