diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3dccedcf..23e94910 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,12 +53,24 @@ jobs: uses: actions/checkout@v4 with: path: Themerr-plex.bundle + submodules: recursive - name: Set up Python uses: LizardByte/setup-python-action@v2023.1211.161304 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 @@ -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: | diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..b338a870 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a05ea658..9f854f07 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile index 5ae1aa9f..61f08128 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 WORKDIR /build diff --git a/docs/source/contributing/build.rst b/docs/source/contributing/build.rst index c12fccbe..6576d016 100644 --- a/docs/source/contributing/build.rst +++ b/docs/source/contributing/build.rst @@ -11,13 +11,22 @@ Ensure `git `__ 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 diff --git a/patches/youtube_dl-extractor.patch b/patches/youtube_dl-extractor.patch deleted file mode 100644 index 384e6fd9..00000000 --- a/patches/youtube_dl-extractor.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py -index 9c419c002..3bf483c1c 100644 ---- a/youtube_dl/extractor/youtube.py -+++ b/youtube_dl/extractor/youtube.py -@@ -260,16 +260,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor): - cookies = self._get_cookies('https://www.youtube.com/') - if cookies.get('__Secure-3PSID'): - return -- consent_id = None -- consent = cookies.get('CONSENT') -- if consent: -- if 'YES' in consent.value: -- return -- consent_id = self._search_regex( -- r'PENDING\+(\d+)', consent.value, 'consent', default=None) -- if not consent_id: -- consent_id = random.randint(100, 999) -- self._set_cookie('.youtube.com', 'CONSENT', 'YES+cb.20210328-17-p0.en+FX+%s' % consent_id) -+ socs = cookies.get('SOCS') -+ if socs and not socs.value.startswith('CAA'): # not consented -+ return -+ self._set_cookie('.youtube.com', 'SOCS', 'CAI', secure=True) # accept all (required for mixes) - - def _real_initialize(self): - self._initialize_consent() diff --git a/requirements.txt b/requirements.txt index e33a65fd..6466ea08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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" diff --git a/third-party/youtube-dl b/third-party/youtube-dl new file mode 160000 index 00000000..be008e65 --- /dev/null +++ b/third-party/youtube-dl @@ -0,0 +1 @@ +Subproject commit be008e657d79832642e2158557c899249c9e31cd