Skip to content

Commit

Permalink
feat: fallback to EDITOR env
Browse files Browse the repository at this point in the history
  • Loading branch information
r3tr0ananas committed Mar 31, 2024
1 parent 1bf0fec commit 3cd9b9c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
24 changes: 14 additions & 10 deletions mov_cli/cli/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ def open_config_file(config: Config):
"""Opens the config file in the respectable editor for that platform."""
editor = config.editor

if editor is None:
if editor is None:
platform = utils.what_platform()

if platform == "Windows":
editor = "notepad"
elif platform == "Darwin":
editor = "nano" # NOTE: https://support.apple.com/guide/terminal/use-command-line-text-editors-apdb02f1133-25af-4c65-8976-159609f99817/mac
elif platform == "iOS":
editor = "vi"
elif platform == "Linux" or platform == "Android":
editor = "nano"
env_editor = os.environ.get("EDITOR")

if env_editor is not None:
editor = env_editor
else:
if platform == "Windows":
editor = "notepad"
elif platform == "Darwin":
editor = "nano" # NOTE: https://support.apple.com/guide/terminal/use-command-line-text-editors-apdb02f1133-25af-4c65-8976-159609f99817/mac
elif platform == "iOS":
editor = "vi"
elif platform == "Linux" or platform == "Android":
editor = "nano"

os.system(f"{editor} {config.config_path}")
2 changes: 1 addition & 1 deletion mov_cli/cli/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def play(media: Media, metadata: Metadata, scraper: Scraper, episode: EpisodeSel

popen = chosen_player.play(media)

if popen is None:
if popen is None and platform != "iOS":
mov_cli_logger.error(
f"The player '{config.player.__class__.__name__.lower()}' is not supported on this platform ({platform}). " \
"We recommend VLC for iOS and MPV for every other platform."
Expand Down
2 changes: 1 addition & 1 deletion mov_cli/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def greetings() -> Tuple[Literal["Good Morning", "Good Afternoon", "Good Evening
i = int(now.strftime("%I"))

try:
user_name = user_name if what_platform() == "Android" else getpass.getuser()
user_name = user_name if what_platform() in ["Android", "iOS"] else getpass.getuser()
except Exception as e: # NOTE: Apparently an exception is raised but they don't tell us what exception :(
mov_cli_logger.debug(
"getpass couldn't get the user name so a random one is being returned. "
Expand Down
4 changes: 1 addition & 3 deletions mov_cli/players/vlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def play(self, media: Media) -> Optional[subprocess.Popen]:

logger.info("The URL was copied into your clipboard. To play it, open a browser and paste the URL.")

return None # TODO: Idk what we can do here as for ios we don't return a subprocess.Popen.
# Leaving it like so will print an error from the cli stating the player is not supported.
# I'll leave it to you Ananas. At least it doesn't raise an exception now. ~ Goldy
return None

elif self.platform == "Linux" or self.platform == "Windows":
try:
Expand Down
26 changes: 0 additions & 26 deletions scripts/test_play.py

This file was deleted.

0 comments on commit 3cd9b9c

Please sign in to comment.