Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #116 from LizardByte/nightly
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
ReenigneArcher authored Jul 31, 2023
2 parents 16cab72 + 7f3ad89 commit 0162116
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,6 +105,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
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions Contents/Code/default_prefs.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
39 changes: 34 additions & 5 deletions Contents/Code/youtube_dl_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 14 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions docs/source/about/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions docs/source/contributing/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:github_url: https://github.com/LizardByte/Themerr-plex/tree/nightly/docs/source/contributing/contributing.rst

Contributing
============

Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 0162116

Please sign in to comment.