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

Test library playlists reference tracks that don't exist #47

Open
shacker opened this issue May 25, 2017 · 3 comments
Open

Test library playlists reference tracks that don't exist #47

shacker opened this issue May 25, 2017 · 3 comments

Comments

@shacker
Copy link
Collaborator

shacker commented May 25, 2017

In this example (from my personal project), we use the included test library to step through all tracks in the library, then go through the playlists and create ordered PlaylistEntry objects. It is assumed that the Playlists section of the XML will only reference tracks that exist in the library.

Is it intentional that the XML Playlists reference non-existent tracks for testing purposes, or should they all be valid, as would be the typical case?

397/402 Aerosmith - Train Kept a Rollin' (Live)
398/402 Dixie Chicks - I Like It
399/402 J.J. Cale & Eric Clapton - Dead End Road
400/402 Gnarls Barkley - Storm Coming
401/402 U2 - City of Blinding Lights
Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/shacker/Sites/virtualenvs/pyrex/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/Users/shacker/Sites/virtualenvs/pyrex/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/shacker/Sites/virtualenvs/pyrex/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/shacker/Sites/virtualenvs/pyrex/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/shacker/dev/pyrex/itl/management/commands/sync.py", line 130, in handle
    plists = [itl.getPlaylist(p) for p in itl.getPlaylistNames()]
  File "/Users/shacker/dev/pyrex/itl/management/commands/sync.py", line 130, in <listcomp>
    plists = [itl.getPlaylist(p) for p in itl.getPlaylistNames()]
  File "/Users/shacker/dev/libpytunes/libpytunes/Library.py", line 118, in getPlaylist
    t = self.songs[id]
KeyError: 63488

@shacker
Copy link
Collaborator Author

shacker commented May 25, 2017

I just created a simple new library with a playlist and an ordered playlist from a blank/new account on my Mac, then ran the same command above, and it didn't have this problem. So I think it's a fair assumption that standard library files don't reference nonexistent files in the playlists section. I can post this library as a PR if you like, unless you prefer continuing to work with the current test library.

@NathanDotTo
Copy link
Collaborator

NathanDotTo commented May 25, 2017 via email

@shacker
Copy link
Collaborator Author

shacker commented May 25, 2017

I don't have a test, but it would go something like this:

# itl = the Library object
plists = [itl.getPlaylist(p) for p in itl.getPlaylistNames()]
for pl in plists:
    for track in pl.tracks
        # get track by ID or persistent_id

Aside: Rather than editing a library file manually, I think it's much easier and more realistic to create a new account on your Mac, or create a new library by holding down Option while launching iTunes, then drag a few dozen files in, create playlists (including nested playlists) and let iTunes manage the library creation. Then just commit the resulting XML.

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

2 participants