|
@@ -7,6 +7,7 @@ import mutagen
|
|
|
import mutagen.id3
|
|
|
import mutagen.mp4
|
|
|
import os
|
|
|
+import symuid.library.itunes
|
|
|
import urllib.parse
|
|
|
import xml.etree.ElementTree
|
|
|
|
|
@@ -75,13 +76,8 @@ def set_play_count_tag(track_path, player, library_id, reg_dt, play_count):
|
|
|
|
|
|
def symuid_import_itunes(xml_library_path, root_url, root_path):
|
|
|
root_path = os.path.expanduser(root_path)
|
|
|
- lib = xml.etree.ElementTree.parse(xml_library_path)
|
|
|
- # WORKAROUND find('.//key[.="Library Persistent ID"]')
|
|
|
- # -> SyntaxError: invalid predicate
|
|
|
- lib_root_dict = lib.find('./dict')
|
|
|
- lib_id = get_itunes_dict_value(lib_root_dict, 'Library Persistent ID')
|
|
|
- assert isinstance(lib_id, str) and len(lib_id) > 0, lib_id
|
|
|
- for track_node in get_itunes_dict_value(lib_root_dict, 'Tracks').iterfind('./dict'):
|
|
|
+ lib = symuid.library.itunes.XmlLibrary(xml_library_path)
|
|
|
+ for track_node in lib._root_dict['Tracks'].iterfind('./dict'):
|
|
|
try:
|
|
|
track_url = get_itunes_dict_value(track_node, 'Location')
|
|
|
except KeyError:
|
|
@@ -104,7 +100,7 @@ def symuid_import_itunes(xml_library_path, root_url, root_path):
|
|
|
set_play_count_tag(
|
|
|
track_path=track_path,
|
|
|
player='itunes',
|
|
|
- library_id=lib_id,
|
|
|
+ library_id=lib.id,
|
|
|
reg_dt=last_play_dt,
|
|
|
play_count=play_count,
|
|
|
)
|