From f0138fdb95c8195c0cc40b187ba90f624205872f Mon Sep 17 00:00:00 2001 From: Philipp Hauer Date: Wed, 28 Sep 2016 17:18:07 +0200 Subject: [PATCH] [#1] skip songs without a location --- TODO.md | 2 ++ build.py | 2 +- .../rhythmbox_playlists_writer.py | 13 ++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index e69de29..efc60d7 100644 --- a/TODO.md +++ b/TODO.md @@ -0,0 +1,2 @@ +- add tests for remote songs +- extend pyItunes: Add to Song: Track Type ("File" vs "Remote"). optionally Purchased (None vs True) and Matched (None vs True) diff --git a/build.py b/build.py index 653b9be..2ec589d 100644 --- a/build.py +++ b/build.py @@ -9,7 +9,7 @@ default_task = ['install_dependencies', 'clean', 'publish'] name = "migrate-itunes-to-rhythmbox" -version = "1.0.0" +version = "1.0.1" summary = settings.PROJECT_DESCRIPTION authors = (Author("Philipp Hauer", "")), url = "https://github.com/phauer/migrate-itunes-to-rhythmbox" diff --git a/src/main/python/migrate_itunes_to_rhythmbox/rhythmbox_playlists_writer.py b/src/main/python/migrate_itunes_to_rhythmbox/rhythmbox_playlists_writer.py index ff16338..23613f0 100644 --- a/src/main/python/migrate_itunes_to_rhythmbox/rhythmbox_playlists_writer.py +++ b/src/main/python/migrate_itunes_to_rhythmbox/rhythmbox_playlists_writer.py @@ -1,5 +1,5 @@ from lxml import etree -from pyItunes import Playlist +from pyItunes import Playlist, Song from typing import List, Dict from path import Path from migrate_itunes_to_rhythmbox.transform import transform_to_rhythmbox_path @@ -31,10 +31,13 @@ def write(playlists: List[Playlist], target_path: Path, target_library_root: str 'search-type': "search-match", 'type': "static"} playlist_element = etree.SubElement(root, "playlist", attributes) for song in playlist.tracks: - transformed_location = transform_to_rhythmbox_path(song.location_escaped, target_library_root, source_library_root) - # transformed_location = transform_to_rhythmbox_path(song.location, target_library_root, source_library_root) - location_element = etree.SubElement(playlist_element, "location") - location_element.text = transformed_location + if song.location_escaped is not None: + transformed_location = transform_to_rhythmbox_path(song.location_escaped, target_library_root, source_library_root) + location_element = etree.SubElement(playlist_element, "location") + location_element.text = transformed_location + else: + print(" Can't convert the track [{} - {}] in playlist '{}' because there is no file location defined. It's probably a remote file." + .format(song.artist, song.name, playlist.name)) common.write_to_file(root, target_path, add_standalone_to_xml_declaration=False)