From e9d889ce3d48c7953c22e86f50a37ae4001e3045 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 6 May 2023 17:35:30 -0400 Subject: [PATCH 1/7] build(docker): move docker image to ubuntu 22.04 (#115) --- Dockerfile | 33 ++++++++++------------- docs/source/contributing/contributing.rst | 2 ++ requirements.txt | 6 +++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index c709848f..5400ceed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ # syntax=docker/dockerfile:1.4 # artifacts: false # platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 -FROM python:2.7.18-buster AS buildstage -# in order to use ubuntu:22.04 or newer, we will need to install git from source +FROM ubuntu:22.04 AS buildstage # build args ARG BUILD_VERSION @@ -12,21 +11,17 @@ ARG GITHUB_SHA=$COMMIT # note: build_plist.py uses BUILD_VERSION and GITHUB_SHA SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# git 2.34 does not work with python 2.7 -# git 2.25 may work since it is included with ubuntu 20.04 -# to install git from source, see here: https://stackoverflow.com/a/52344030/11214013 # install dependencies -#RUN <<_DEPS -##!/bin/bash -#set -e -#apt-get update -y -#apt-get install -y --no-install-recommends \ -# git=1:2.34.1* \ -# python2=2.7.18* \ -# python-pip=20.3.4* -#apt-get clean -#rm -rf /var/lib/apt/lists/* -#_DEPS +RUN <<_DEPS +#!/bin/bash +set -e +apt-get update -y +apt-get install -y --no-install-recommends \ + python2=2.7.18* \ + python-pip=20.3.4* +apt-get clean +rm -rf /var/lib/apt/lists/* +_DEPS # create build dir and copy GitHub repo there COPY --link . /build @@ -38,7 +33,7 @@ WORKDIR /build RUN <<_PIP #!/bin/bash set -e -python -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ +python2 -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ pip setuptools requests # requests required to install python-plexapi # dev requirements not necessary for docker image, significantly speeds up build since lxml doesn't need to build @@ -48,9 +43,9 @@ _PIP RUN <<_BUILD #!/bin/bash set -e -python -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ +python2 -m pip --no-python-version-warning --disable-pip-version-check install --no-cache-dir --upgrade \ --target=./Contents/Libraries/Shared -r requirements.txt --no-warn-script-location -python ./scripts/build_plist.py +python2 ./scripts/build_plist.py _BUILD # clean diff --git a/docs/source/contributing/contributing.rst b/docs/source/contributing/contributing.rst index 217bda13..adbe1c0c 100644 --- a/docs/source/contributing/contributing.rst +++ b/docs/source/contributing/contributing.rst @@ -1,3 +1,5 @@ +:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/contributing/contributing.rst + Contributing ============ diff --git a/requirements.txt b/requirements.txt index e6b2d0f0..ea494ae1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,11 +7,13 @@ typing==3.10.0.0 # youtube_dl is not capable or willing to create a new release so have to install from git # youtube_dl==2021.12.17 # unknown if dependabot can update this -git+https://github.com/ytdl-org/youtube-dl.git@26035bde46c0acc30dc053618451d9aeca4b7709#egg=youtube_dl +# git+https://github.com/ytdl-org/youtube-dl.git@26035bde46c0acc30dc053618451d9aeca4b7709#egg=youtube_dl +https://github.com/ytdl-org/youtube-dl/archive/26035bde46c0acc30dc053618451d9aeca4b7709.zip#egg=youtube_dl # custom python-plexapi supporting python 2.7 # this is used to upload theme songs since Movie agents cannot correctly do so -git+https://github.com/reenignearcher/python-plexapi.git@master-py2.7#egg=plexapi +# git+https://github.com/reenignearcher/python-plexapi.git@master-py2.7#egg=plexapi +https://github.com/reenignearcher/python-plexapi/archive/master-py2.7.zip#egg=plexapi # websocket-client is required for plexapi alert listener websocket-client==0.59.0;python_version<"3" From 9220cf0fac447589f23aa63482dd0a28c59c2162 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 7 May 2023 18:34:36 -0400 Subject: [PATCH 2/7] build: exclude tests directory from package (#117) --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 53779fff..c5a82210 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -107,6 +107,7 @@ jobs: "-xr!Themerr-plex.bundle/Dockerfile" \ "-xr!Themerr-plex.bundle/docs" \ "-xr!Themerr-plex.bundle/scripts" \ + "-xr!Themerr-plex.bundle/tests" \ a "./Themerr-plex.bundle.zip" "Themerr-plex.bundle" mkdir artifacts From e8221fd42cf15839dbb496b30b1d81409ed0a8a5 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:26:54 -0400 Subject: [PATCH 3/7] fix(ci): fix python 2.7 setup (#123) --- .github/workflows/CI.yml | 4 +--- .github/workflows/python-tests.yml | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c5a82210..69be6381 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -44,9 +44,7 @@ jobs: path: Themerr-plex.bundle - name: Install Python 2.7 - uses: actions/setup-python@v4 - with: - python-version: '2.7' + uses: LizardByte/.github/actions/setup_python2@nightly - name: Set up Python 2.7 Dependencies working-directory: Themerr-plex.bundle diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 2248c749..fcd1f0d3 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -19,9 +19,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '2.7' + uses: LizardByte/.github/actions/setup_python2@nightly - name: Install python dependencies shell: bash @@ -33,5 +31,6 @@ jobs: python -m pip --no-python-version-warning --disable-pip-version-check install -r requirements.txt - name: Test with pytest + shell: bash # our Python 2.7 setup action doesn't support PowerShell run: | python -m pytest -v From b4247c9a7da97cef6e9413ee52df80fc614f50d9 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:35:46 -0400 Subject: [PATCH 4/7] fix(codec): improve compatibility with Apple devices (#122) --- Contents/Code/default_prefs.py | 1 + Contents/Code/youtube_dl_helper.py | 39 ++++++++++++++++++++++++++---- Contents/DefaultPrefs.json | 7 ++++++ docs/source/about/usage.rst | 12 +++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/Contents/Code/default_prefs.py b/Contents/Code/default_prefs.py index c94ea887..c3f01557 100644 --- a/Contents/Code/default_prefs.py +++ b/Contents/Code/default_prefs.py @@ -1,4 +1,5 @@ default_prefs = dict( + bool_prefer_mp4a_codec='True', int_plexapi_plexapi_timeout='180', int_plexapi_upload_retries_max='3', int_plexapi_upload_threads='3', diff --git a/Contents/Code/youtube_dl_helper.py b/Contents/Code/youtube_dl_helper.py index 962583ce..7a51d2e7 100644 --- a/Contents/Code/youtube_dl_helper.py +++ b/Contents/Code/youtube_dl_helper.py @@ -8,6 +8,7 @@ except ImportError: pass else: # the code is running outside of Plex + from plexhints.log_kit import Log # log kit from plexhints.prefs_kit import Prefs # prefs kit # imports from Libraries\Shared @@ -56,14 +57,42 @@ def process_youtube(url): # Just a video video_data = result - size = 0 - audio_url = None + selected = { + 'opus': { + 'size': 0, + 'audio_url': None + }, + 'mp4a': { + 'size': 0, + 'audio_url': None + }, + } if video_data: for fmt in video_data['formats']: # loop through formats, select largest audio size for better quality if 'audio only' in fmt['format']: + if 'opus' == fmt['acodec']: + temp_codec = 'opus' + elif 'mp4a' == fmt['acodec'].split('.')[0]: + temp_codec = 'mp4a' + else: + Log.Debug('Unknown codec: %s' % fmt['acodec']) + continue # unknown codec filesize = int(fmt['filesize']) - if filesize > size: - size = filesize - audio_url = fmt['url'] + if filesize > selected[temp_codec]['size']: + selected[temp_codec]['size'] = filesize + selected[temp_codec]['audio_url'] = fmt['url'] + + audio_url = None + + if 0 < selected['opus']['size'] > selected['mp4a']['size']: + audio_url = selected['opus']['audio_url'] + elif 0 < selected['mp4a']['size'] > selected['opus']['size']: + audio_url = selected['mp4a']['audio_url'] + + if audio_url and Prefs['bool_prefer_mp4a_codec']: # mp4a codec is preferred + if selected['mp4a']['audio_url']: # mp4a codec is available + audio_url = selected['mp4a']['audio_url'] + elif selected['opus']['audio_url']: # fallback to opus :( + audio_url = selected['opus']['audio_url'] return audio_url # return None or url found diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json index f217bcc9..c23672b4 100644 --- a/Contents/DefaultPrefs.json +++ b/Contents/DefaultPrefs.json @@ -1,4 +1,11 @@ [ + { + "id": "bool_prefer_mp4a_codec", + "type": "bool", + "label": "Prefer MP4A AAC Codec (Improves compatibility with Apple devices)", + "default": "True", + "secure": "false" + }, { "id": "int_plexapi_plexapi_timeout", "type": "text", diff --git a/docs/source/about/usage.rst b/docs/source/about/usage.rst index cee3942c..730437a1 100644 --- a/docs/source/about/usage.rst +++ b/docs/source/about/usage.rst @@ -25,6 +25,18 @@ Minimal setup is required to use Themerr-plex. In addition to the installation, Preferences ----------- +Prefer MP4A AAC Codec +^^^^^^^^^^^^^^^^^^^^^ + +Description + Some Plex clients, such as AppleTV, do not support the Opus audio codec for theme songs. This setting will + force Themerr to select the MP4A AAC codec over the Opus codec when both are available. If the MP4A AAC codec is + not available, the Opus codec will be used and the theme song will not be playable on clients that do not support + the Opus codec. + +Default + True + PlexAPI Timeout ^^^^^^^^^^^^^^^ From add9a253526dba038e87ffe47665abb82003560c Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:53:10 -0400 Subject: [PATCH 5/7] ci: update global docker (#125) --- .github/workflows/ci-docker.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 1082c941..acb883af 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -192,6 +192,16 @@ jobs: name: Docker${{ matrix.tag }} steps: + - name: Maximize build space + uses: easimon/maximize-build-space@v7 + with: + root-reserve-mb: 30720 # https://github.com/easimon/maximize-build-space#caveats + remove-dotnet: 'true' + remove-android: 'true' + remove-haskell: 'true' + remove-codeql: 'true' + remove-docker-images: 'true' + - name: Checkout uses: actions/checkout@v3 with: From 973dc921e7f61f2f8cbd6e802a344355e6fc561e Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:10:36 -0400 Subject: [PATCH 6/7] ci: update global workflows (#124) --- .github/workflows/ci-qodana.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-qodana.yml b/.github/workflows/ci-qodana.yml index 91feb59f..5763df11 100644 --- a/.github/workflows/ci-qodana.yml +++ b/.github/workflows/ci-qodana.yml @@ -214,7 +214,7 @@ jobs: - name: Qodana id: qodana continue-on-error: true # ensure dispatch-qodana job is run - uses: JetBrains/qodana-action@v2022.3.4 + uses: JetBrains/qodana-action@v2023.2.1 with: additional-cache-hash: ${{ github.ref }}-${{ matrix.language }} artifact-name: qodana-${{ matrix.language }} # yamllint disable-line rule:line-length From 7f3ad89bd475916f6469d15a3876c789d8822f45 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:37:31 -0400 Subject: [PATCH 7/7] docs(changelog): add v0.2.0 (#126) --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af6074b2..77ef5405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [0.2.0] - 2023-07-31 +**Added** +- Add option to prefer MPEG AAC audio codec over Opus + +**Fixed** +- Fix issue where most theme songs would not play on Apple devices. +- Remove tests directory from release package + ## [0.1.4] - 2023-04-20 **Fixed** - Updated youtube_dl, fixing an issue where plugin would fail to get themes in some cases @@ -87,3 +95,4 @@ [0.1.2]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.1.2 [0.1.3]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.1.3 [0.1.4]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.1.4 +[0.2.0]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.2.0