Skip to content

Add -f force-import, smart skip, and -D batch import from directory#9

Open
mcmanuss8 wants to merge 1 commit into
stu247:masterfrom
mcmanuss8:force-import-and-batch-dir
Open

Add -f force-import, smart skip, and -D batch import from directory#9
mcmanuss8 wants to merge 1 commit into
stu247:masterfrom
mcmanuss8:force-import-and-batch-dir

Conversation

@mcmanuss8

Copy link
Copy Markdown

Wanted to use this to bulk export and bulk import playlists for use case where I keep two sonos systems in sync. The backing up part works, but the importing part not so much since playlists need to be deleted manually before they can be imported.

This PR:

  • Overloads -f to force imports even if the playlist is existing.
  • Adds comparison against the existing playlist so it doesn't try to import if nothing's changed
  • Adds -D to bulk import all playlist files in a directory
  • Some changes to avoid spurious refreshes (Ex: lowering smb share names)
  • -V to see verbose output
  • More verbosity on what playlist is being imported (useful for -D mode)

===
Claude's summary:

  • importPl: compare file URIs vs live Sonos playlist URIs before importing; skip with a message if identical (case-insensitive path comparison handles SMB share name casing differences)
  • importPl: with -f, delete the existing playlist and reimport when content has changed, instead of aborting with an error
  • importPl: skip empty playlists gracefully instead of calling create_sonos_playlist_from_queue with no tracks queued
  • importPl: print playlist name before progress dots so batch runs are readable
  • Add -V verbose diff output showing which URIs differ when a mismatch is detected, to aid diagnosing URI normalization issues
  • Add -D/--importDir flag to import all *.xspf files from a directory, equivalent to -X for export; respects -f
  • Wire args.force through to importPl call sites (was silently ignored)
  • Update -f help text to mention it applies to import as well

- importPl: compare file URIs vs live Sonos playlist URIs before
  importing; skip with a message if identical (case-insensitive path
  comparison handles SMB share name casing differences)
- importPl: with -f, delete the existing playlist and reimport when
  content has changed, instead of aborting with an error
- importPl: skip empty playlists gracefully instead of calling
  create_sonos_playlist_from_queue with no tracks queued
- importPl: print playlist name before progress dots so batch runs
  are readable
- Add -V verbose diff output showing which URIs differ when a mismatch
  is detected, to aid diagnosing URI normalization issues
- Add -D/--importDir flag to import all *.xspf files from a directory,
  equivalent to -X for export; respects -f
- Wire args.force through to importPl call sites (was silently ignored)
- Update -f help text to mention it applies to import as well
Comment thread spl/spl.py
return uris


def importPl(self, speaker, fileName, force=False):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updates change importPl() to read the playlist file in the middle of reading the playlist file, so the playlist file is read twice. The playlist file should only be read once.

I would suggest that importPl() no longer opens the playlist file but relies on getFileUris() to do that. getFileUris() can return the playlist name as well as the URIs. importPl() can use this information to process the playlist.

Comment thread spl/spl.py
"""

import argparse
import glob

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this PR is a good addition to the spl script.

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

Successfully merging this pull request may close these issues.

2 participants