From 6f00ce812061318cdd50d8808332a971d8bbf201 Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 16 Jan 2025 03:01:10 -0500 Subject: [PATCH 01/11] Create upgrade_yt-dlp.sh --- tubesync/upgrade_yt-dlp.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tubesync/upgrade_yt-dlp.sh diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh new file mode 100644 index 00000000..e4fdd171 --- /dev/null +++ b/tubesync/upgrade_yt-dlp.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +pip3() { + local pip_whl + pip_whl="$(ls -1r /usr/share/python-wheels/pip-*-py3-none-any.whl | head -n 1)" + + python3 "${pip_whl}/pip" "$@" +} + +pip3 install --upgrade --break-system-packages yt-dlp + From d7f9fa45ecb2d94fe48ea2778538fea2a961ca83 Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 16 Jan 2025 08:16:31 +0000 Subject: [PATCH 02/11] Add executable to sh script --- tubesync/upgrade_yt-dlp.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tubesync/upgrade_yt-dlp.sh diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh old mode 100644 new mode 100755 From 4e51d54ec122dc10550be77618250276e6a7b4b2 Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 16 Jan 2025 08:24:11 -0500 Subject: [PATCH 03/11] Use pip runner from pipenv --- tubesync/upgrade_yt-dlp.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh index e4fdd171..21d51564 100755 --- a/tubesync/upgrade_yt-dlp.sh +++ b/tubesync/upgrade_yt-dlp.sh @@ -1,10 +1,16 @@ #!/usr/bin/env bash pip3() { - local pip_whl - pip_whl="$(ls -1r /usr/share/python-wheels/pip-*-py3-none-any.whl | head -n 1)" + local pip_runner pip_whl run_whl - python3 "${pip_whl}/pip" "$@" + # pipenv + pip_runner='/usr/lib/python3/dist-packages/pipenv/patched/pip/__pip-runner__.py' + + # python3-pip-whl + pip_whl="$(ls -1r /usr/share/python-wheels/pip-*-py3-none-any.whl | head -n 1)" + run_whl="${pip_whl}/pip" + + python3 "${pip_runner}" "$@" } pip3 install --upgrade --break-system-packages yt-dlp From ae07c1ce8942385897e1ee743aaf5bf3270d1d52 Mon Sep 17 00:00:00 2001 From: tcely Date: Fri, 17 Jan 2025 13:03:06 -0500 Subject: [PATCH 04/11] Fallback to run_whl Prefer `pip_runner` but try the `pip` wheel too, if it's missing. --- tubesync/upgrade_yt-dlp.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh index 21d51564..c3a7edab 100755 --- a/tubesync/upgrade_yt-dlp.sh +++ b/tubesync/upgrade_yt-dlp.sh @@ -5,12 +5,13 @@ pip3() { # pipenv pip_runner='/usr/lib/python3/dist-packages/pipenv/patched/pip/__pip-runner__.py' + test -s "${pip_runner}" || pip_runner='' # python3-pip-whl pip_whl="$(ls -1r /usr/share/python-wheels/pip-*-py3-none-any.whl | head -n 1)" run_whl="${pip_whl}/pip" - python3 "${pip_runner}" "$@" + python3 "${pip_runner:-"${run_whl}"}" "$@" } pip3 install --upgrade --break-system-packages yt-dlp From 66e51929803cace51ba946eece5af1822e225d51 Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 20 Jan 2025 08:49:14 -0500 Subject: [PATCH 05/11] Warn against regular updating of yt-dlp --- tubesync/upgrade_yt-dlp.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh index c3a7edab..b92e1fd0 100755 --- a/tubesync/upgrade_yt-dlp.sh +++ b/tubesync/upgrade_yt-dlp.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +warning_message() { + cat <&2 + pip3() { local pip_runner pip_whl run_whl @@ -14,5 +23,8 @@ pip3() { python3 "${pip_runner:-"${run_whl}"}" "$@" } +warning_message +test -n "${TUBESYNC_DEBUG}" || exit 1 + pip3 install --upgrade --break-system-packages yt-dlp From f65f6f1de5637b29ebee76c5ccb32388c7752c72 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 01:12:24 -0500 Subject: [PATCH 06/11] Treat static_url the same as other URLs --- tubesync/tubesync/wsgi.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tubesync/tubesync/wsgi.py b/tubesync/tubesync/wsgi.py index 71c61003..123dfde6 100644 --- a/tubesync/tubesync/wsgi.py +++ b/tubesync/tubesync/wsgi.py @@ -1,5 +1,4 @@ import os -from urllib.parse import urljoin from django.core.wsgi import get_wsgi_application @@ -17,9 +16,8 @@ def application(environ, start_response): raise Exception(f'DJANGO_URL_PREFIX must end with a /, ' f'got: {DJANGO_URL_PREFIX}') if script_name: - static_url = urljoin(script_name, 'static/') environ['SCRIPT_NAME'] = script_name path_info = environ['PATH_INFO'] - if path_info.startswith(script_name) and not path_info.startswith(static_url): + if path_info.startswith(script_name): environ['PATH_INFO'] = path_info[len(script_name) - 1:] return _application(environ, start_response) From 52d703ff1ff358f9ae4a44d54b33601160a82737 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 01:55:13 -0500 Subject: [PATCH 07/11] Better check for script_name --- tubesync/tubesync/wsgi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubesync/tubesync/wsgi.py b/tubesync/tubesync/wsgi.py index 123dfde6..74912aef 100644 --- a/tubesync/tubesync/wsgi.py +++ b/tubesync/tubesync/wsgi.py @@ -15,7 +15,7 @@ def application(environ, start_response): else: raise Exception(f'DJANGO_URL_PREFIX must end with a /, ' f'got: {DJANGO_URL_PREFIX}') - if script_name: + if script_name is not None: environ['SCRIPT_NAME'] = script_name path_info = environ['PATH_INFO'] if path_info.startswith(script_name): From 1f95b858f2ef7ec6cc9c2994327474be8c4cbd5f Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 03:08:24 -0500 Subject: [PATCH 08/11] Use --break-system-packages with pip Unfortunately, both versions of `pip` don't have this flag. Check the version, then add the flag if it is not too old. --- tubesync/upgrade_yt-dlp.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tubesync/upgrade_yt-dlp.sh b/tubesync/upgrade_yt-dlp.sh index b92e1fd0..9da6d555 100755 --- a/tubesync/upgrade_yt-dlp.sh +++ b/tubesync/upgrade_yt-dlp.sh @@ -26,5 +26,13 @@ pip3() { warning_message test -n "${TUBESYNC_DEBUG}" || exit 1 -pip3 install --upgrade --break-system-packages yt-dlp +# Use the flag added in 23.0.1, if possible. +# https://github.com/pypa/pip/pull/11780 +break_system_packages='--break-system-packages' +pip_version="$(pip3 --version | awk '$1 = "pip" { print $2; exit; }')" +if [[ "${pip_version}" < "23.0.1" ]]; then + break_system_packages='' +fi + +pip3 install --upgrade ${break_system_packages} yt-dlp From 0ea508443ade4ae05b9ea19500c3d7f1dc1a8b93 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 04:21:47 -0500 Subject: [PATCH 09/11] Pipefile -> Pipfile --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad437bba..dbf4b6fe 100644 --- a/README.md +++ b/README.md @@ -325,7 +325,7 @@ Notable libraries and software used: * [django-sass](https://github.com/coderedcorp/django-sass/) * The container bundles with `s6-init` and `nginx` -See the [Pipefile](https://github.com/meeb/tubesync/blob/main/Pipfile) for a full list. +See the [Pipfile](https://github.com/meeb/tubesync/blob/main/Pipfile) for a full list. ### Can I get access to the full Django admin? From 96078f8d40cfd3b4f75e3d51ac1667cefad78aad Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 21 Jan 2025 04:38:06 -0500 Subject: [PATCH 10/11] Update architectures FAQ --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad437bba..ce89cb7a 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,12 @@ etc.). Configuration of this is beyond the scope of this README. ### What architectures does the container support? -Just `amd64` for the moment. Others may be made available if there is demand. +Only two are supported, for the moment: +- `amd64` (most desktop PCs and servers) +- `arm64` +(modern ARM computers, such as the Rasperry Pi 3 or later) + +Others may be made available, if there is demand. ### The pipenv install fails with "Locking failed"! From 1671c6e7066e83d8ee684c9256726fbcada329ee Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 22 Jan 2025 04:55:57 -0500 Subject: [PATCH 11/11] DRY YouTube domain list I am tired of links copied from YouTube not working without adjustments. --- tubesync/sync/views.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index 52090042..8ca853de 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -193,10 +193,15 @@ class ValidateSourceView(FormView): Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: ('https://www.youtube.com/playlist?list=' 'PL590L5WQmH8dpP0RyH5pCfIaDEdt9nk7r') } + _youtube_domains = frozenset({ + 'youtube.com', + 'm.youtube.com', + 'www.youtube.com', + }) validation_urls = { Source.SOURCE_TYPE_YOUTUBE_CHANNEL: { 'scheme': 'https', - 'domains': ('m.youtube.com', 'www.youtube.com'), + 'domains': _youtube_domains, 'path_regex': '^\/(c\/)?([^\/]+)(\/videos)?$', 'path_must_not_match': ('/playlist', '/c/playlist'), 'qs_args': [], @@ -205,7 +210,7 @@ class ValidateSourceView(FormView): }, Source.SOURCE_TYPE_YOUTUBE_CHANNEL_ID: { 'scheme': 'https', - 'domains': ('m.youtube.com', 'www.youtube.com'), + 'domains': _youtube_domains, 'path_regex': '^\/channel\/([^\/]+)(\/videos)?$', 'path_must_not_match': ('/playlist', '/c/playlist'), 'qs_args': [], @@ -214,7 +219,7 @@ class ValidateSourceView(FormView): }, Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: { 'scheme': 'https', - 'domains': ('m.youtube.com', 'www.youtube.com'), + 'domains': _youtube_domains, 'path_regex': '^\/(playlist|watch)$', 'path_must_not_match': (), 'qs_args': ('list',),