diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c245e80 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM python:3.11-slim as builder + +ENV PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + POETRY_VERSION=1.3.1 \ + POETRY_VIRTUALENVS_CREATE=0 + +RUN pip install "poetry==$POETRY_VERSION" + +WORKDIR /app +COPY poetry.lock pyproject.toml /app/ +RUN poetry install --no-interaction --no-ansi --only main +COPY README.md /app/ +COPY plexy/ /app/plexy/ +RUN poetry build --no-interaction --no-ansi + + +FROM python:3.11-slim + +ENV PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PYTHONDONTWRITEBYTECODE=1 \ + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 + +COPY --from=builder /app/dist /usr/src/dist + +RUN pip install /usr/src/dist/plexy-*.tar.gz + +WORKDIR / + +ENTRYPOINT ["plexy"] +CMD ["--help"] diff --git a/README.md b/README.md index 9b04776..cf14584 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,14 @@ You can exclude this codec when saving your preferences: >> plexy --url http://mylocalplex:32400 --token ABCDEF1234567890 preferences --language pt-BR -A truehd original ``` +And print the full summary of changes: +```bash +>> plexy --url http://ratostation.nas:32400 --token FLRJstK4r4TiR4_Soafq preferences -f -l en --title "The Matrix (1999)" original +Configuring watching preferences [####################################] 100% +1 movie changed out of 1 selected movie +The Matrix (1999) changed from pt-BR: Português (SRT External) to no subtitles +``` + All available CLI options: ```bash @@ -107,6 +115,12 @@ Options: ``` +## Using Docker + + + docker run -it --rm plexy --url http://mylocalplex:32400 --token ABCDEF1234567890 preferences --language pt-BR -A truehd original + + ## Installation **Plexy** can be installed as a regular python module by running: diff --git a/plexy/api.py b/plexy/api.py index 725b093..09f4b2c 100644 --- a/plexy/api.py +++ b/plexy/api.py @@ -436,6 +436,7 @@ def get_sorted_subtitle_streams(self, preferences: Preferences): def save_preferences(self, preferences: Preferences): previous_selected_audio = self.selected_audio previous_selected_subtitle = self.selected_subtitle + selected_subtitle = previous_selected_subtitle audio_streams = self.get_sorted_audio_streams(preferences) selected_audio = audio_streams[0] if audio_streams else previous_selected_audio @@ -451,6 +452,7 @@ def save_preferences(self, preferences: Preferences): if previous_selected_subtitle: logger.debug('%s - no subtitle selected', self.title) self.unselect_subtitle() + selected_subtitle = None else: subtitle_streams = self.get_sorted_subtitle_streams(preferences) selected_subtitle = subtitle_streams[0] if len(subtitle_streams) else previous_selected_subtitle @@ -461,8 +463,8 @@ def save_preferences(self, preferences: Preferences): selected_subtitle) self.select_subtitle(selected_subtitle) - if self.selected_audio != previous_selected_audio or self.selected_subtitle != previous_selected_subtitle: - return Change(self, previous_selected_audio, previous_selected_subtitle) + if selected_audio != previous_selected_audio or selected_subtitle != previous_selected_subtitle: + return Change(self, previous_selected_audio, previous_selected_subtitle, selected_audio, selected_subtitle) def __str__(self): return f'{self.title}' @@ -476,12 +478,14 @@ class Change: def __init__(self, video: VideoPart, previous_audio: Stream, - previous_subtitle: Stream): + previous_subtitle: Stream, + audio: Stream, + subtitle: Stream): self.video = video self.previous_audio = previous_audio self.previous_subtitle = previous_subtitle - self.audio = video.selected_audio - self.subtitle = video.selected_subtitle + self.audio = audio + self.subtitle = subtitle def __repr__(self): return f'<{self.__class__.__name__} - {self.video}]>'