-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: remove PlayerNotFound and handle FileNotFoundError in cli …
…play method.
- Loading branch information
1 parent
32b3d8b
commit 04913c3
Showing
9 changed files
with
144 additions
and
149 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,5 +1,7 @@ | ||
from .player import * | ||
|
||
from .mpv import * | ||
from .vlc import * | ||
from .iina import * | ||
from .syncplay import * | ||
from .custom_player import * |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Optional | ||
from ..media import Media | ||
from .. import Config | ||
from ..utils.platform import SUPPORTED_PLATFORMS | ||
|
||
import subprocess | ||
from devgoldyutils import Colours | ||
|
||
from .player import Player | ||
|
||
__all__ = ("IINA",) | ||
|
||
class IINA(Player): | ||
def __init__(self, platform: SUPPORTED_PLATFORMS, config: Config, **kwargs) -> None: | ||
self.config = config | ||
self.platform = platform | ||
|
||
super().__init__(display_name = Colours.GREY.apply("IINA"), **kwargs) | ||
|
||
def play(self, media: Media) -> Optional[subprocess.Popen]: | ||
"""Plays this media in the IINA media player for MacOS.""" | ||
|
||
if self.platform == "Darwin": | ||
args = [ | ||
"iina", | ||
"--no-stdin", | ||
"--keep-running", | ||
media.url, | ||
f"--mpv-force-media-title={media.display_name}", | ||
] | ||
|
||
if media.referrer is not None: | ||
args.append(f"--mpv-referrer={media.referrer}") | ||
|
||
if media.audio_url is not None: # TODO: This will need testing. | ||
args.append(f"--mpv-audio-file={media.audio_url}") | ||
|
||
if media.subtitles is not None: # TODO: This will need testing. | ||
args.append(f"--mpv-sub-file={media.subtitles}") | ||
|
||
if self.config.resolution is not None: | ||
args.append(f"--mpv-hls-bitrate={self.config.resolution}") # NOTE: This only works when the file is a m3u8 | ||
|
||
return subprocess.Popen(args) | ||
|
||
return None |
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
Oops, something went wrong.