Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/gkelly #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def set_properties(project):
project.depends_on_requirements("requirements.txt")
project.build_depends_on_requirements("requirements-build.txt")
project.depends_on("pyItunes", url="git+https://github.com/phauer/pyitunes.git#egg=pyItunes-1.4") # use my fork to ensure stability
#project.depends_on("libpytunes", url="git+https://github.com/phauer/pyitunes.git#egg=pyItunes-1.4") # use my fork to ensure stability
project.set_property('distutils_classifiers', [
'Topic :: Multimedia :: Sound/Audio :: Conversion',
'Intended Audience :: Information Technology',
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/migrate_itunes_to_rhythmbox/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lxml import etree
from path import Path
from pathlib import Path


def get_xml_declaration(add_standalone_to_xml_declaration: bool):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyItunes import Library, Playlist, Song
from libpytunes import Library, Playlist, Song
from typing import List, Dict

english_german_ignore_list = ("Library", "Music", "Movies", "TV Shows", "Purchased", "iTunes DJ", "Podcasts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pyItunes import Song
from libpytunes import Song
from typing import List, Dict
from path import Path
from pathlib import Path
import lxml.etree
from migrate_itunes_to_rhythmbox import common
from time import struct_time
Expand All @@ -11,10 +11,11 @@


class SongStatistic:
def __init__(self, play_count: int, rating: int, last_played_timestamp: str):
def __init__(self, play_count: int, rating: int, last_played_timestamp: str, date_added_timestamp: str):
self.play_count = play_count
self.rating = rating
self.last_played_timestamp = last_played_timestamp
self.date_added_timestamp = date_added_timestamp


class IntegrationLog:
Expand Down Expand Up @@ -57,6 +58,7 @@ def integrate_statistics_into_entry(itunes_statistics, rhythmdb_song_entry):
integrate_value_to_rhythmdb_song_entry(rhythmdb_song_entry, "play-count", itunes_statistics.play_count)
integrate_value_to_rhythmdb_song_entry(rhythmdb_song_entry, "rating", itunes_statistics.rating)
integrate_value_to_rhythmdb_song_entry(rhythmdb_song_entry, "last-played", itunes_statistics.last_played_timestamp)
integrate_value_to_rhythmdb_song_entry(rhythmdb_song_entry, "first-seen", itunes_statistics.date_added_timestamp)


def integrate_value_to_rhythmdb_song_entry(rhythmdb_song_entry, rhythmdb_node_name, itunes_value):
Expand All @@ -78,11 +80,16 @@ def create_itunes_statistic_dict(itunes_songs: Dict[int, Song], itunes_library_r
count = itunes_song.play_count
last_played = itunes_song.lastplayed
last_played_timestamp = calendar.timegm(last_played) if last_played is not None else None
date_added = itunes_song.date_added
date_modified = itunes_song.date_modified
if date_modified < date_added:
date_added = date_modified #somehow I messed up the timestamps on my library back in 2011
date_added_timestamp = calendar.timegm(date_added) if date_added is not None else None
itunes_rating = itunes_song.rating
mapped_rating = ITUNES_TO_RHYTHMBOX_RATINGS_MAP[itunes_rating]
location = itunes_song.location_escaped
canonical_location = create_canonical_location_for_itunes_location(location, itunes_library_root)
dict[canonical_location] = SongStatistic(count, mapped_rating, last_played_timestamp)
dict[canonical_location] = SongStatistic(count, mapped_rating, last_played_timestamp, date_added_timestamp)
else:
print(" Can't assign the track [{} - {}] because there is no file location defined. It's probably a remote file."
.format(itunes_song.artist, itunes_song.name))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from lxml import etree
from pyItunes import Playlist, Song
from libpytunes import Playlist, Song
from typing import List, Dict
from path import Path
from pathlib import Path
from migrate_itunes_to_rhythmbox.transform import transform_to_rhythmbox_path
from migrate_itunes_to_rhythmbox import common

Expand Down
2 changes: 1 addition & 1 deletion src/main/python/migrate_itunes_to_rhythmbox/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from path import Path
from pathlib import Path
# well, not so easy to get path resolution work during test execution for both a) a single test executed via IDE and b) via pyb
PROJECT_ROOT = Path(__file__).parent.parent.parent.parent.parent # climb up to project root
TARGET_FOLDER = PROJECT_ROOT.joinpath(PROJECT_ROOT, 'target')
Expand Down
2 changes: 1 addition & 1 deletion src/main/scripts/migrate-itunes-to-rhythmbox
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from os.path import expanduser
import click
from path import Path
from pathlib import Path
from migrate_itunes_to_rhythmbox import itunes_library_reader, rhythmbox_playlists_writer, rhythmbox_count_rating_integrator, settings


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from lxml import etree
from path import Path
from pathlib import Path
from migrate_itunes_to_rhythmbox import itunes_library_reader, rhythmbox_count_rating_integrator, settings
from migrate_itunes_to_rhythmbox.rhythmbox_count_rating_integrator import SongStatistic, IntegrationLog

Expand Down
2 changes: 1 addition & 1 deletion src/unittest/python/rhythmbox_playlists_writer_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from path import Path
from pathlib import Path

from migrate_itunes_to_rhythmbox import itunes_library_reader, rhythmbox_playlists_writer, settings

Expand Down