From 29deb150bf3d2e9cbda68b6c4bfcae2b6569496b Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 17 Dec 2023 19:55:47 -0500 Subject: [PATCH] build(deps): Bump youtube-dl and add as a submodule (#140) --- .github/workflows/CI.yml | 20 ++++++++++++-------- .gitmodules | 4 ++++ .readthedocs.yaml | 5 +++++ Dockerfile | 12 ++++++++++++ docs/source/contributing/build.rst | 11 ++++++++++- patches/youtube_dl-extractor.patch | 25 ------------------------- requirements.txt | 5 +---- third-party/youtube-dl | 1 + 8 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 .gitmodules delete mode 100644 patches/youtube_dl-extractor.patch create mode 160000 third-party/youtube-dl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9e94379..24b97c2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,12 +53,24 @@ jobs: uses: actions/checkout@v4 with: path: PlexyGlass.bundle + submodules: recursive - name: Set up Python uses: LizardByte/setup-python-action@v2023.1210.35516 with: python-version: '2.7' + - name: Patch third-party deps + shell: bash + working-directory: PlexyGlass.bundle/third-party + run: | + patch_dir=${{ github.workspace }}/PlexyGlass.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: PlexyGlass.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: PlexyGlass.bundle/Contents/Libraries/Shared - run: | - patch_dir=${{ github.workspace }}/PlexyGlass.bundle/patches - patch -p1 < "${patch_dir}/youtube_dl-compat.patch" - patch -p1 < "${patch_dir}/youtube_dl-extractor.patch" - - name: Build plist working-directory: PlexyGlass.bundle env: diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b338a87 --- /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 a05ea65..9f854f0 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 c534cc1..16c376e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN <<_DEPS set -e apt-get update -y apt-get install -y --no-install-recommends \ + patch \ python2=2.7.18* \ python-pip=20.3.4* apt-get clean @@ -47,6 +48,17 @@ python2 -m pip --no-python-version-warning --disable-pip-version-check install - python2 ./scripts/build_plist.py _BUILD +# patch youtube-dl, cannot use git apply because we don't pass in any git files +WORKDIR /build/Contents/Libraries/Shared +RUN <<_PATCH +#!/bin/bash +set -e +patch_dir=/build/patches +patch -p1 < "${patch_dir}/youtube_dl-compat.patch" +_PATCH + +WORKDIR /build + # clean RUN <<_CLEAN #!/bin/bash diff --git a/docs/source/contributing/build.rst b/docs/source/contributing/build.rst index 47cbbec..e634453 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/plexyglass.git plexyglass.bundle + git clone --recurse-submodules https://github.com/lizardbyte/plexyglass.git plexyglass.bundle cd ./plexyglass.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 384e6fd..0000000 --- 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 6c06689..a017a8c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,4 @@ 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 -# dependabot cannot update this -# git+https://github.com/ytdl-org/youtube-dl.git@00ef748cc0e35ee60efd0f7a00e373ab8d1af86b#egg=youtube_dl -# do not use git as git in ubuntu 22.04 does not work with python 2.7 -https://github.com/ytdl-org/youtube-dl/archive/00ef748cc0e35ee60efd0f7a00e373ab8d1af86b.zip#egg=youtube_dl +./third-party/youtube-dl diff --git a/third-party/youtube-dl b/third-party/youtube-dl new file mode 160000 index 0000000..be008e6 --- /dev/null +++ b/third-party/youtube-dl @@ -0,0 +1 @@ +Subproject commit be008e657d79832642e2158557c899249c9e31cd