urls: remove the app=desktop query parameter from YouTube URLs
- ID
e27fae7- date
2026-05-17 12:03:23+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
a318488- message
urls: remove the `app=desktop` query parameter from YouTube URLs- changed files
4 files, 11 additions, 4 deletions
Changed files
CHANGELOG.md (4868) → CHANGELOG.md (4967)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d3d191..cd8ec84 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## v41 - 2026-05-17
+
+In `urls.clean_youtube_url()`, remove the `app=desktop` URL query parameter.
+
## v40 - 2026-05-14
Add a function `text.coloured()` for printing text with ANSI escape codes.
src/chives/__init__.py (391) → src/chives/__init__.py (391)
diff --git a/src/chives/__init__.py b/src/chives/__init__.py
index ee2ecdb..17ac617 100644
--- a/src/chives/__init__.py
+++ b/src/chives/__init__.py
@@ -11,4 +11,4 @@ I share across multiple sites.
"""
-__version__ = "40"
+__version__ = "41"
src/chives/urls.py (4643) → src/chives/urls.py (4632)
diff --git a/src/chives/urls.py b/src/chives/urls.py
index 2823330..001baf8 100644
--- a/src/chives/urls.py
+++ b/src/chives/urls.py
@@ -22,13 +22,12 @@ __all__ = [
def clean_youtube_url(url: str) -> str:
"""
- Remove any query parameters from a YouTube URL that I don't
- want to include.
+ Remove any unnecessary tracking parameters from a YouTube URL.
"""
u = urlsplit(url)
query = parse_qs(u.query)
- for param in ("list", "index", "start_radio", "t"):
+ for param in ("app", "list", "index", "start_radio", "t"):
try:
del query[param]
except KeyError:
tests/test_urls.py (5789) → tests/test_urls.py (5940)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index d67b690..258fb5c 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -29,6 +29,10 @@ from chives.urls import (
"https://www.youtube.com/watch?v=WiIi7STG3e0&start_radio=1",
"https://www.youtube.com/watch?v=WiIi7STG3e0",
),
+ (
+ "https://www.youtube.com/watch?app=desktop&v=vQ4ATsyD4hA",
+ "https://www.youtube.com/watch?v=vQ4ATsyD4hA",
+ ),
],
)
def test_clean_youtube_url(url: str, cleaned_url: str) -> None: