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

build(deps): bump youtube-dl #164

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ 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 Expand Up @@ -92,6 +100,7 @@ jobs:
"-xr!Themerr-plex.bundle/DOCKER_README.md" \
"-xr!Themerr-plex.bundle/Dockerfile" \
"-xr!Themerr-plex.bundle/docs" \
"-xr!Themerr-plex.bundle/patches" \
"-xr!Themerr-plex.bundle/scripts" \
"-xr!Themerr-plex.bundle/tests" \
a "./Themerr-plex.bundle.zip" "Themerr-plex.bundle"
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set -e
apt-get update -y
apt-get install -y --no-install-recommends \
npm=8.5.* \
patch \
python2=2.7.18* \
python-pip=20.3.4*
apt-get clean
Expand Down Expand Up @@ -49,6 +50,18 @@ python2 -m pip --no-python-version-warning --disable-pip-version-check install -
python2 ./scripts/build_plist.py
_BUILD

# patch youtube-dl
WORKDIR /build/Contents/Libraries/Shared
RUN <<_YOUTUBE_DL_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

WORKDIR /build

# setup npm and dependencies
RUN <<_NPM
#!/bin/bash
Expand All @@ -61,6 +74,7 @@ _NPM
RUN <<_CLEAN
#!/bin/bash
set -e
rm -rf ./patches/
rm -rf ./scripts/
# list contents
ls -a
Expand Down
38 changes: 38 additions & 0 deletions patches/youtube_dl-compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 3c526a78d..6e2a92d92 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -58,18 +58,22 @@ except ImportError: # Python 2

# Also fix up lack of method arg in old Pythons
try:
- _req = compat_urllib_request.Request
- _req('http://127.0.0.1', method='GET')
+ type(compat_urllib_request.Request('http://127.0.0.1', method='GET'))
except TypeError:
- class _request(object):
- def __new__(cls, url, *args, **kwargs):
- method = kwargs.pop('method', None)
- r = _req(url, *args, **kwargs)
- 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__
+
+ 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:
25 changes: 25 additions & 0 deletions patches/youtube_dl-extractor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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()
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ 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@26035bde46c0acc30dc053618451d9aeca4b7709#egg=youtube_dl
https://github.com/ytdl-org/youtube-dl/archive/26035bde46c0acc30dc053618451d9aeca4b7709.zip#egg=youtube_dl
# 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

# required for websocket to pass tests
pysocks==1.7.1;python_version<"3"
Expand Down
Loading