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

track_id not persistent #61

Open
tcarroll2 opened this issue Sep 11, 2019 · 2 comments
Open

track_id not persistent #61

tcarroll2 opened this issue Sep 11, 2019 · 2 comments

Comments

@tcarroll2
Copy link

iTunes track_id does not remain persistent. Any changes to your iTunes library, such and changing any metadata may very well cause the track_id to change. I had this happen to me. Only the persistent_id field remains unchanged no matter what you do to the library. This can result in errant behavior if one is relying on the track_id to never change for a particular track.

Is there a specific reason the persistent_id is not being used to build the dictionaries/lists?

@tcarroll2
Copy link
Author

After further investigating this issue, it appears whenever iTunes detects any changes that have been made to a 'Track' (i.e. Year, track number, album name, composer) metadata the entire iTunes Library.xml file is written back to disk and that previous 'track_id' is different for that track. Only the 'persistent_id' is consistent across any changes or deletions. Therefore, for anyone using this library who needs to be able to consistently refer to the same track, regardless of any updates made within the iTunes application, you will need to use the 'peristent_id' field.

I will see what I can do to make the 'Tracks' dictionary use the 'persistent_id' field as the key rather than the 'track_id' field. I discovered this after printing out hundreds of pages with track names and then find out the names no longer match up to a track_id after making a few changes within the iTunes library. Expensive mistake!

@tcarroll2
Copy link
Author

I created a new variable right below 'self.songs' named 'self.byPID' and then at the end of the getSongs() function I added just below 'self.songs[int(trackid)] = s', 'self.byPID[s.persistent_id] = s' this will now create an additional dictionary 'byPID' that can be used to manage tracks by their 'persistent_id' rather than 'track_id', which can change at anytime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant