Skip to content

Commit

Permalink
feat: quality setting in playing 'x', limit config, quality in media
Browse files Browse the repository at this point in the history
  • Loading branch information
r3tr0ananas committed May 31, 2024
1 parent b4e368e commit 6daaa36
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
5 changes: 3 additions & 2 deletions mov_cli/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def mov_cli(
debug = debug,
player = player,
scraper = (scraper, ["scrapers", "default"]),
fzf = (fzf, ["ui", "fzf"])
fzf = (fzf, ["ui", "fzf"]),
limit = limit
)

if config.debug:
Expand Down Expand Up @@ -101,7 +102,7 @@ def mov_cli(

chosen_scraper = use_scraper(selected_scraper, config, http_client)

choice = search(query, auto_select, chosen_scraper, config.fzf_enabled, limit)
choice = search(query, auto_select, chosen_scraper, config.fzf_enabled, config.limit)

if choice is None:
mov_cli_logger.error("There was no results or you didn't select anything.")
Expand Down
6 changes: 4 additions & 2 deletions mov_cli/cli/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ def play(media: Media, metadata: Metadata, scraper: Scraper, episode: EpisodeSel

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

media_quality = Colours.GREEN.apply(f"{media.quality.name}")

mov_cli_logger.info(
f"Playing {episode_details_string}'{Colours.BLUE.apply(media.title)}' " \
f"with {chosen_player.display_name}..."
f"Playing {episode_details_string}'{Colours.BLUE.apply(media.title)}' in {Colours.GREEN.apply(media.quality.name)} quality " \
f"with {chosen_player.display_name}..."
)
mov_cli_logger.debug(f"Streaming with this url -> '{hide_ip(media.url, config)}'")

Expand Down
4 changes: 4 additions & 0 deletions mov_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def resolution(self) -> Quality:
def watch_options(self) -> bool:
return self.data.get("ui", {}).get("watch_options", True)

@property
def limit(self) -> int | None:
return self.data.get("ui", {}).get("limit")

@property
def language(self) -> Lang:
language = self.data.get("subtitle", {}).get("language", "en")
Expand Down
1 change: 1 addition & 0 deletions mov_cli/config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hide_ip = true
# [mov-cli.ui]
# fzf = true
# watch_options = true
# limit = 20

[mov-cli.plugins] # E.g: namespace = "package-name"
test = "mov-cli-test"
Expand Down
43 changes: 22 additions & 21 deletions mov_cli/media/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from abc import abstractmethod

from .quality import Quality

__all__ = (
"Media",
"Multi",
"Single",
"Movie",
"Series"
"Single"
)

class Media():
Expand All @@ -23,7 +23,8 @@ def __init__(
title: str,
audio_url: Optional[str],
referrer: Optional[str],
subtitles: Optional[str]
subtitles: Optional[str],
quality: Quality
) -> None:
self.url = url
"""The stream-able url of the media."""
Expand All @@ -35,6 +36,8 @@ def __init__(
"""The required referrer for streaming the media content."""
self.subtitles = subtitles
"""The url or file path to the subtitles."""
self.quality = quality
"""The selected quality of media."""

@property
@abstractmethod
Expand All @@ -45,13 +48,14 @@ def display_name(self) -> str:
class Multi(Media):
"""Represents a media that has multiple episodes like a TV Series, Anime or Cartoon."""
def __init__(
self,
url: str,
title: str,
episode: EpisodeSelector,
audio_url: Optional[str] = None,
referrer: Optional[str] = None,
subtitles: Optional[str] = None
self,
url: str,
title: str,
episode: EpisodeSelector,
audio_url: Optional[str] = None,
referrer: Optional[str] = None,
subtitles: Optional[str] = None,
quality: Quality = Quality.AUTO
) -> None:
self.episode = episode
"""The episode and season of this series."""
Expand All @@ -61,7 +65,8 @@ def __init__(
title = title,
audio_url = audio_url,
referrer = referrer,
subtitles = subtitles
subtitles = subtitles,
quality = quality
)

@property
Expand All @@ -77,7 +82,8 @@ def __init__(
audio_url: Optional[str] = None,
referrer: Optional[str] = None,
year: Optional[str] = None,
subtitles: Optional[str] = None
subtitles: Optional[str] = None,
quality: Quality = Quality.AUTO
) -> None:
self.year = year
"""The year this film was released."""
Expand All @@ -87,15 +93,10 @@ def __init__(
title = title,
audio_url = audio_url,
referrer = referrer,
subtitles = subtitles
subtitles = subtitles,
quality = quality
)

@property
def display_name(self) -> str:
return f"{self.title} ({self.year})" if self.year is not None else self.title

# Backwards compatibility for post v4.3 extensions.
Series = Multi
"""DEPRECATED!!! USE 'Multi' INSTEAD! This will be removed after v4.4 and WILL cause hard crashes."""
Movie = Single
"""DEPRECATED!!! USE 'Single' INSTEAD! This will be removed after v4.4 and WILL cause hard crashes."""
return f"{self.title} ({self.year})" if self.year is not None else self.title

0 comments on commit 6daaa36

Please sign in to comment.