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

Support filelike objects, not only pathes #35

Closed
JuniorJPDJ opened this issue Sep 5, 2020 · 6 comments · Fixed by #45
Closed

Support filelike objects, not only pathes #35

JuniorJPDJ opened this issue Sep 5, 2020 · 6 comments · Fixed by #45

Comments

@JuniorJPDJ
Copy link
Contributor

JuniorJPDJ commented Sep 5, 2020

Hi!
I'm trying to use this library with remote files defined as file-likes in python.
mutagen supports file-like interface, why tho mediafile doesn't?
Docs say it needs local file path as first argument.

@sampsyo
Copy link
Member

sampsyo commented Sep 7, 2020

Sounds like a reasonable addition! A PR would be welcome.

@JuniorJPDJ
Copy link
Contributor Author

It works, would just need rename of path to filelike

@sampsyo
Copy link
Member

sampsyo commented Sep 7, 2020

OK! Updates to the naming and the docs would still be welcome in a PR. (But we wouldn't want to call it filelike because it can also be a path. 😃)

@JuniorJPDJ
Copy link
Contributor Author

Nvm, saving doesn't work if using filelike.

@JuniorJPDJ
Copy link
Contributor Author

What if we use loadfile decorator from mutagen itself and provide filething argument?
MediaFile would be usable the same as mutagen.File itself.

If you are OK with this I can try doing it.

@sampsyo
Copy link
Member

sampsyo commented May 11, 2021

Sure! That seems worth a shot. Thanks for looking into it!

JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 12, 2021
fixes support to filelike objects
resolves beetbox#35

Incompatible changes:
- renames `MediaFile.path` to `MediaFile.filename`
- renames `path` arument to `MediaFile` to `filename` (compatibility with mutagen)

Mediafile can now be created using following scheme:
```
fileobj = io.BytesIO()
...

Mediafile(filename="myfile.mp3")
Mediafile(fileobj=myfileobj)
```
but
```
Mediafile("myfile.mp3")
Mediafile(myfileobj)
```
will also work.
JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 12, 2021
fixes support to filelike objects
resolves beetbox#35

Incompatible changes:
- renames `MediaFile.path` to `MediaFile.filename`
- renames `path` arument to `MediaFile` to `filename` (compatibility with mutagen)

Mediafile can now be created using following scheme:
```
fileobj = io.BytesIO()
...

Mediafile(filename="myfile.mp3")
Mediafile(fileobj=myfileobj)
```
but
```
Mediafile("myfile.mp3")
Mediafile(myfileobj)
```
will also work.
JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 12, 2021
fixes support to filelike objects
resolves beetbox#35

Incompatible changes:
- renames `MediaFile.path` to `MediaFile.filename`
- renames `path` arument to `MediaFile` to `filename` (compatibility with mutagen)

MediaFile can now be created using following scheme:
```
fileobj = io.BytesIO()
...

MediaFile(filename="myfile.mp3")
MediaFile(fileobj=myfileobj)
```
but
```
MediaFile("myfile.mp3")
MediaFile(myfileobj)
```
will also work.
JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 12, 2021
fixes support to filelike objects
resolves beetbox#35

Incompatible changes:
- renames `path` argument to `MediaFile` to `filename` (compatibility with mutagen)

MediaFile can now be created using following scheme:
```
fileobj = io.BytesIO()
# here goes filling of BytesIO with music file
MediaFile(filename="myfile.mp3")
MediaFile(fileobj=myfileobj)
```
but old style
```
MediaFile("myfile.mp3")
MediaFile(myfileobj)
```
will also work.
JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 18, 2021
fixes support to filelike objects
resolves beetbox#35

Incompatible changes:
- renames `path` argument to `MediaFile` to `filename` (compatibility with mutagen)

MediaFile can now be created using following scheme:
```
fileobj = io.BytesIO()
# here goes filling of BytesIO with music file
MediaFile(filename="myfile.mp3")
MediaFile(fileobj=myfileobj)
```
but old style
```
MediaFile("myfile.mp3")
MediaFile(myfileobj)
```
will also work.
JuniorJPDJ added a commit to JuniorJPDJ/mediafile that referenced this issue May 21, 2021
fixes support for filelike objects
resolves beetbox#35

Incompatible changes:
- renames `path` argument to `MediaFile` to `filename` (compatibility with mutagen)

MediaFile can now be created using following scheme:
```
fileobj = io.BytesIO()
MediaFile(filename="myfile.mp3")
MediaFile(fileobj=myfileobj)
```
but old style
```
MediaFile("myfile.mp3")
MediaFile(myfileobj)
```
will also work.
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 a pull request may close this issue.

2 participants