-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Guess the content type of remote files as well
* Move get_mime from cli to util * StreamInfo: Add the guessed_content_type property * Use the guessed content-type of the stream to initialize the call of play_media_url This is more sensible than the default of video/mp4, not suitable for all media files (like images). * Rename get_mime into guess_mime This better reflects the fact that is might be wrong sometimes. * Rename is_video to is_remote_file * Remove use of guess_mime from cli.py * Make guess_mime return None if it can't make a guess * Fix content_type fallback in play_media_url
- Loading branch information
1 parent
0bbb6f0
commit e003fe7
Showing
5 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
from pathlib import Path | ||
|
||
import click | ||
|
||
|
||
def warning(msg): | ||
click.secho("Warning: ", fg="red", nl=False, err=True) | ||
click.echo(msg, err=True) | ||
|
||
|
||
def guess_mime(path): | ||
# source: https://developers.google.com/cast/docs/media | ||
extension = Path(path).suffix.lower() | ||
extensions = { | ||
".mp4": "video/mp4", | ||
".m4a": "audio/mp4", | ||
".mp3": "audio/mp3", | ||
".mpa": "audio/mpeg", | ||
".webm": "video/webm", | ||
".mkv": "video/x-matroska", | ||
".bmp": "image/bmp", | ||
".jpg": "image/jpeg", | ||
".gif": "image/gif", | ||
".png": "image/png", | ||
".webp": "image/web", | ||
} | ||
return extensions.get(extension, "video/mp4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters