Package: itunessmart
iTunes Smartplaylist parserConvert smart playlist information to a readable form.This module is aPython 3implementation, based onbanshee-itunes-import-pluginbyScott Peterson.It was tested on Windows 10 with iTunes 12.10.6.2 (64bit) and Python 3.8.It does not work with Python 2.x.Kodi smart playlistsYou can convert all your iTunes smart playlists to Kodi smart playlists with this interactive script:python3 utils/export_xsp.pyorpython3 -m itunessmartThen place the resulting .xsp files fromout/in youruserdatafolder.Most of the common functions and rules are available in both formats and often iTunes playlists are fully convertible to Kodi.The biggest difference are nested rules in iTunes which are not available in Kodi.
However, nested rules can be simulated with sub-playlists. These "helper"-playlists are named with the prefix "zzzsub_" and a MD5 hash of its rules.
When you runutils/export_xsp.py, you can disable generation of subplaylists.More information on Kodie smart playlists:http://kodi.wiki/view/smart_playlists#Format_of_a_smart_playlist_fileText exportTo export all playlists to text files, usepython3 utils/export.pyThe formatSmart playlist data in iTunes is saved in theiTunes Music Library.xmlfile.The data in the playlist entry in the xml file is base64 encoded binary data:<dict><key>Name</key><string>Example</string><key>PlaylistID</key><integer>123456</integer><key>PlaylistPersistentID</key><string>49C97D85843B04CC</string><key>ParentPersistentID</key><string>4DA0F774D3F70473</string><key>AllItems</key><true/><key>SmartInfo</key><data>AQEAAwAAAAIAAAAZAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</data><key>SmartCriteria</key><data>U0xzdAABAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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Items</key><array><dict><key>TrackID</key><integer>123</integer></dict><dict><key>TrackID</key><integer>124</integer></dict><dict>...<dict></array></dict>It can be converted into three different output formats:importitunessmartinfo="AQEAAwAAAAIAAAAZ..."criteria="U0xzdAABAAEAAAAD..."parser=itunessmart.Parser(info,criteria)result=parser.resultprint(result.output)print(result.query)print(json.dumps(result.queryTree,indent=2))A text format:Playsisgreaterthan15and[Playsisgreaterthan16orPlaysisgreaterthan17orPlaysisgreaterthan18]andRatingisgreaterthan4A sql-like format:(Plays>15)AND((Plays>16)OR(Plays>17)OR(Plays>18))AND(Rating>4)And two tree structures{"tree":{"and":[["Plays","(Plays > 15)"],{"or":[["Plays","(Plays > 16)"],["Plays","(Plays > 17)"],["Plays","(Plays > 18)"]]},["Rating","(Rating > 4)"]]},"liveupdate":true,"onlychecked":false}{"fulltree":{"and":[{"field":"Plays","type":"int","operator":"greater than","value":15},{"or":[{"field":"Plays","type":"int","operator":"greater than","value":16},{"field":"Plays","type":"int","operator":"greater than","value":17},{"field":"Plays","type":"int","operator":"greater than","value":18}]},{"field":"Rating","type":"int","operator":"greater than","value":4}]}}