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

Commit

Permalink
build(deps): add youtube-dl as submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Dec 17, 2023
1 parent 3cc4ad5 commit 43affe6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 49 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,24 @@ jobs:
uses: actions/checkout@v4
with:
path: Themerr-plex.bundle
submodules: recursive

- name: Set up Python
uses: LizardByte/[email protected]
with:
python-version: '2.7'

- name: Patch third-party deps
shell: bash
working-directory: Themerr-plex.bundle/third-party
run: |
patch_dir=${{ github.workspace }}/Themerr-plex.bundle/patches
# youtube-dl patches
pushd youtube-dl
git apply -v "${patch_dir}/youtube_dl-compat.patch"
popd
- name: Set up Python Dependencies
shell: bash
working-directory: Themerr-plex.bundle
Expand All @@ -73,14 +85,6 @@ jobs:
python -m pip install --upgrade --target=./Contents/Libraries/Shared -r \
requirements.txt --no-warn-script-location
- name: Patch python deps
shell: bash
working-directory: Themerr-plex.bundle/Contents/Libraries/Shared
run: |
patch_dir=${{ github.workspace }}/Themerr-plex.bundle/patches
patch -p1 < "${patch_dir}/youtube_dl-compat.patch"
patch -p1 < "${patch_dir}/youtube_dl-extractor.patch"
- name: Install npm packages
working-directory: Themerr-plex.bundle
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "third-party/youtube-dl"]
path = third-party/youtube-dl
url = https://github.com/ytdl-org/youtube-dl.git
branch = master
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ build:
- rstcheck -r . # lint rst files
# - rstfmt --check --diff -w 120 . # check rst formatting

# submodules required to include youtube-dl
submodules:
include: all
recursive: true

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ python2 -m pip --no-python-version-warning --disable-pip-version-check install -
python2 ./scripts/build_plist.py
_BUILD

# patch youtube-dl
# patch youtube-dl, cannot use git apply because we don't pass in any git files
WORKDIR /build/Contents/Libraries/Shared
RUN <<_YOUTUBE_DL_PATCH
RUN <<_PATCH
#!/bin/bash
set -e
patch_dir=/build/patches
patch -p1 < "${patch_dir}/youtube_dl-compat.patch"
patch -p1 < "${patch_dir}/youtube_dl-extractor.patch"
_YOUTUBE_DL_PATCH
patch -p1 < "$patch_dir/youtube_dl-compat.patch"
_PATCH

WORKDIR /build

Expand Down
11 changes: 10 additions & 1 deletion docs/source/contributing/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ Ensure `git <https://git-scm.com/>`__ is installed and run the following:

.. code-block:: bash
git clone https://github.com/lizardbyte/themerr-plex.git themerr-plex.bundle
git clone --recurse-submodules https://github.com/lizardbyte/themerr-plex.git themerr-plex.bundle
cd ./themerr-plex.bundle
Setup venv
----------
It is recommended to setup and activate a `venv`_.

Apply Patches
-------------
Patch YouTube-DL
.. code-block:: bash
pushd ./third-party/youtube-dl
git apply -v ../../patches/youtube_dl-compat.patch
popd
Install Requirements
--------------------
Install Requirements
Expand Down
13 changes: 6 additions & 7 deletions patches/youtube_dl-compat.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 3c526a78d..6e2a92d92 100644
index 3c526a78d..6774fd4a5 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -58,18 +58,22 @@ except ImportError: # Python 2
@@ -58,19 +58,22 @@ except ImportError: # Python 2

# Also fix up lack of method arg in old Pythons
try:
Expand All @@ -17,22 +17,21 @@ index 3c526a78d..6e2a92d92 100644
- if method:
- r.get_method = types.MethodType(lambda _: method, r)
- return r
-
- compat_urllib_request.Request = _request
+ def _add_init_method_arg(cls):
+ init = cls.__init__
+

- compat_urllib_request.Request = _request
+ def wrapped_init(self, *args, **kwargs):
+ method = kwargs.pop('method', 'GET')
+ init(self, *args, **kwargs)
+ if self.has_data() and method == 'GET':
+ method = 'POST'
+ self.get_method = types.MethodType(lambda _: method, self)
+
+ cls.__init__ = wrapped_init
+
+ _add_init_method_arg(compat_urllib_request.Request)
+ del _add_init_method_arg


try:
import urllib.error as compat_urllib_error
25 changes: 0 additions & 25 deletions patches/youtube_dl-extractor.patch

This file was deleted.

4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ werkzeug==1.0.1;python_version<"3"

# youtube_dl is not capable or willing to create a new release so have to install from git
# youtube_dl==2021.12.17
# dependabot cannot update this
# git+https://github.com/ytdl-org/youtube-dl.git@00ef748cc0e35ee60efd0f7a00e373ab8d1af86b#egg=youtube_dl
https://github.com/ytdl-org/youtube-dl/archive/00ef748cc0e35ee60efd0f7a00e373ab8d1af86b.zip#egg=youtube_dl
./third-party/youtube-dl

# required for websocket to pass tests
pysocks==1.7.1;python_version<"3"
Expand Down
1 change: 1 addition & 0 deletions third-party/youtube-dl
Submodule youtube-dl added at be008e

0 comments on commit 43affe6

Please sign in to comment.