]> git.scottworley.com Git - pinch/commitdiff
Use a proper User-Agent when fetching channel info
authorScott Worley <scottworley@scottworley.com>
Mon, 4 May 2026 06:20:31 +0000 (23:20 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 4 May 2026 06:20:31 +0000 (23:20 -0700)
Changelog
pinch.py

index e087c30993bf79a7b293850b74bb06a131a0a4ff..724bb0bb492b93545a3b29c20814076a73eaa8ce 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
 ## [Unreleased]
+- Use a proper User-Agent when fetching channel info
 
 ## [3.3.2] - 2025-12-14
 - Keep up with nixpkgs 25.11
index c101dc333856953c1cae1f026c5630c79ef82bb1..bbafe6bd811a8860c2c59392a33ec4fe2fe31f6b 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -43,6 +43,8 @@ from typing import (
 
 import git_cache
 
+from version import pinch_version
+
 # Use xdg module when it's less painful to have as a dependency
 
 
@@ -252,7 +254,11 @@ def compare(a: str, b: str) -> Tuple[List[str], List[str], List[str]]:
 def fetch_channel(
         v: Verification, channel: ChannelSearchPath) -> Tuple[str, str]:
     v.status(f'Fetching channel from {channel.channel_url}')
-    with urllib.request.urlopen(channel.channel_url, timeout=10) as request:
+    with urllib.request.urlopen(
+            urllib.request.Request(
+                url=channel.channel_url,
+                headers={'User-Agent': f'pinch-{pinch_version}'}),
+            timeout=10) as request:
         channel_html = request.read().decode()
         forwarded_url = request.geturl()
         v.result(request.status == 200)