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

Feature request: option to create Library from file stream, instead of XML filename #67

Open
cdwfs opened this issue Nov 17, 2022 · 0 comments

Comments

@cdwfs
Copy link

cdwfs commented Nov 17, 2022

Hello! I have a few use cases where I'm loading iTunes libraries from sources other than an XML file on disk (for example, from a compressed archive or over a network). Previously, this was trivially possible, since Library.__init__() took an open file-like object as input to read XML from With the recent change to replace the obsolete readPlist function (26b3fdf), Library.__init__() now expects itunesxml to be a filename, since it calls open(itunesxml, 'rb') as f internally.

Would it be possible to restore the original behavior, perhaps intelligently detecting whether itunesxml is a filename or a file-like object? Something like:

if os.path.isfile(itunesxml):
    # itunesxml is a filename, and must be opened
    with open(itunesxml, 'rb') as f:
        self.il = plistlib.load(f)
else:
    # itunesxml is a file-like object and can be loaded directly
    self.il = plistlib.load(f)
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