Skip to content

Commit

Permalink
feat: improved playing info log
Browse files Browse the repository at this point in the history
  • Loading branch information
THEGOLDENPRO committed Apr 28, 2024
1 parent eaeb5da commit 32b3d8b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
14 changes: 13 additions & 1 deletion mov_cli/cli/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .episode import handle_episode
from .watch_options import watch_options

from ..media import MetadataType
from ..utils import what_platform
from ..logger import mov_cli_logger

Expand All @@ -24,7 +25,18 @@ def play(media: Media, metadata: Metadata, scraper: Scraper, episode: EpisodeSel

chosen_player = config.player

mov_cli_logger.info(f"Playing '{Colours.BLUE.apply(media.display_name)}' with the '{chosen_player.__class__.__name__}' player...")
episode_details_string = ""

if metadata.type == MetadataType.MULTI:
season_string = Colours.CLAY.apply(str(episode.season))
episode_string = Colours.ORANGE.apply(str(episode.episode))

episode_details_string = f"episode {episode_string} in season {season_string} of " if episode.season > 1 else f"episode {episode_string} of "

mov_cli_logger.info(
f"Playing {episode_details_string}'{Colours.BLUE.apply(media.title)}' " \
f"with {chosen_player.display_name}..."
)
mov_cli_logger.debug(f"Streaming with this url -> '{media.url}'")

popen = chosen_player.play(media)
Expand Down
2 changes: 1 addition & 1 deletion mov_cli/cli/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ..logger import mov_cli_logger

def scrape(choice: Metadata, episode: EpisodeSelector, scraper: Scraper) -> Media:
mov_cli_logger.info(f"Scrapping media for '{Colours.CLAY.apply(choice.title)}'...")
mov_cli_logger.info(f"Scrapping '{Colours.CLAY.apply(choice.title)}'...")

try:
media = scraper.scrape(choice, episode)
Expand Down
1 change: 0 additions & 1 deletion mov_cli/players/mpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def __init__(self, platform: SUPPORTED_PLATFORMS, config: Config, **kwargs) -> N

def play(self, media: Media) -> Optional[subprocess.Popen]:
"""Plays this media in the MPV media player."""

logger.info("Launching MPV Media Player...")

if self.platform == "Android":
Expand Down
5 changes: 4 additions & 1 deletion mov_cli/players/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from ..media import Media

import subprocess
from devgoldyutils import Colours
from abc import ABC, abstractmethod

__all__ = ("Player",)

class Player(ABC):
"""A base class for all players in mov-cli."""
def __init__(self, **kwargs) -> None:
def __init__(self, display_name: Optional[str] = None, **kwargs) -> None:
self.display_name = display_name or Colours.PINK_GREY.apply(self.__class__.__name__)

super().__init__()

@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion mov_cli/players/syncplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, platform: SUPPORTED_PLATFORMS, config: Config, **kwargs) -> N
self.platform = platform
self.config = config

super().__init__(**kwargs)
super().__init__(display_name = "Syncplay", **kwargs)

def play(self, media: Media) -> Optional[subprocess.Popen]:
"""Plays this media in SyncPlay."""
Expand Down

0 comments on commit 32b3d8b

Please sign in to comment.