Bug 18119 - iTunes playlist import broken
: iTunes playlist import broken
Status: UNCONFIRMED
Product: Logitech Media Server
Classification: Unclassified
Component: iTunes
: 7.7.2
: PC Other
: -- normal (vote)
: ---
Assigned To: Unassigned bug - please assign me!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-06 06:26 UTC by Jon Baker
Modified: 2014-09-06 06:26 UTC (History)
0 users

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Baker 2014-09-06 06:26:26 UTC
System Info:

Using iTunes 11.3.1 (2) 64-bit on Mac OSX 10.8
And Logitech Media Server Version: 7.7.3 - 1375965195 on ReadyNAS Ultra 6 Pro

Description:

iTunes Library.xml does not import Playlists. Music is imported correctly from iTunes Library.xml

Cause:

Debugged /Slim/Plugin/Importer.pm perl script. In the method handleEndElement:

---- Code Begin ----

		if ($inTracks && $currentKey eq 'Playlists') {

			Slim::Schema->rs('Playlist')->clearExternalPlaylists('itunesplaylist:');

			main::DEBUGLOG && $log->debug("Starting playlist parsing, cleared old playlists");

			$inTracks = 0;
			$inPlaylists = 1;

			# Set the progress to final when we're done with tracks and have moved on to playlists.
			$progress->final;
			
			$progress = Slim::Utils::Progress->new({ 
				'type'  => 'importer', 
				'name'  => 'itunes_playlists', 
				'total' => $class->getTotalPlaylistCount, 
				'bar'   => 1
			});

		}

----- Code end ----

In iTunes 11.x, the element "Playlists" appears ahead of the elements "Tracks". So the variable $inTracks is undefined, and the conditional expression fails.

Workaround:

If I edit the iTunes Libary.xml, and move the <key>Playlists</key> (and all child elements) to be *after* <key>Tracks</key>, then the import works.
 
Suggested fix:

Make the scanner code more robust so it is not order dependent. Since using a DOM object maybe too large for embedded computer devices, maybe run the iTunes scan in two phases... first get the tracks. Then get the Playlists.