'''
BSD 3 License
-Copyright 2024 Julien Selamme
+Copyright 2025 Julien Selamme
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
xspf: xml.etree.ElementTree.Element = xml.etree.ElementTree.parse(filePath).getroot()
xmlns: str = "http://xspf.org/ns/0/"
- # Each element is a string path.
- for track in xspf[0]: # <track> in <tracks>
- element: typing.Optional[xml.etree.ElementTree.Element] = track.find("{" + xmlns + "}location")
-
- if element is None:
+ for node in xspf: # <trackList> in document.
+ if not node.tag.endswith("trackList"):
continue
- urlDecodedString: str = urllib.parse.unquote(str(element.text))
- playlist.add(os.path.dirname(urlDecodedString),
- os.path.basename(urlDecodedString))
+ # Each element is a string path.
+ for track in node: # <track> in <trackList>.
+ if not track.tag.endswith("track"):
+ continue
+
+ element: typing.Optional[xml.etree.ElementTree.Element] = track.find("{" + xmlns + "}location")
+
+ if element is None:
+ continue
+
+ urlDecodedString: str = urllib.parse.unquote(str(element.text))
+ playlist.add(os.path.dirname(urlDecodedString),
+ os.path.basename(urlDecodedString))
# Create or update playlist file from a directory.
def _updatePlaylistFile(self, playlist: list[str], playlistPath: str) -> None: