removed useragent header from requests to patch notes and news feed, which would error out the request

This commit is contained in:
Microchip
2026-09-22 14:50:04 -04:00
parent ce3154c563
commit f2f4c372c3
2 changed files with 49 additions and 8 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import json
import hashlib
import os
import sys
import ssl
import re
import subprocess
import urllib.request
from urllib.parse import urlsplit
import shutil
import stat
import struct
import time
import math
import threading
import queue
from functools import cache
from pathlib import Path
import urllib.error
import requests
from . import config
from . import ui
NEWS_FEATURED_URL = f"{config.SERVER}/forum/octonews.php?forum=2&mode=full"
PATCHNOTES_URL = f"{config.SERVER}/forum/octonews.php?mode=list&forum=4&limit=8"
#print(NEWS_FEATURED_URL)
#print(PATCHNOTES_URL)
news = ui.fetch_featured_post()
patch_notes = ui.fetch_patch_notes()
print(patch_notes)
print(news)
+10 -8
View File
@@ -23,7 +23,7 @@ from tkinter import filedialog
import urllib.error
from .app_log import LOG_QUEUE as _LOG_Q, log
from .config import _relocate_legacy_data
#from .config import _relocate_legacy_data
from .net import *
from .client import *
from .torrent import *
@@ -34,8 +34,8 @@ from . import config
# News tab: the latest announcement (forum 2, full post) fills the left panel,
# the patch-notes list (forum 4) fills the right.
NEWS_FEATURED_URL = f"{SERVER}/forum/octonews.php?forum=2&mode=full"
PATCHNOTES_URL = f"{SERVER}/forum/octonews.php?mode=list&forum=4&limit=8"
NEWS_FEATURED_URL = f"{config.SERVER}/forum/octonews.php?forum=2&mode=full"
PATCHNOTES_URL = f"{config.SERVER}/forum/octonews.php?mode=list&forum=4&limit=8"
NEWS_TIMEOUT = 8
NEWS_CACHE_TTL = 300
@@ -77,8 +77,8 @@ FONT_BODY = ("Segoe UI", 9)
FONT_MONO = ("TkDefaultFont", 10)
FONT_VER = ("TkDefaultFont", 8)
NEWS_FEATURED_URL = f"{SERVER}/forum/octonews.php?forum=2&mode=full"
PATCHNOTES_URL = f"{SERVER}/forum/octonews.php?mode=list&forum=4&limit=8"
NEWS_FEATURED_URL = f"{config.SERVER}/forum/octonews.php?forum=2&mode=full"
PATCHNOTES_URL = f"{config.SERVER}/forum/octonews.php?mode=list&forum=4&limit=8"
NEWS_TIMEOUT = 8
NEWS_CACHE_TTL = 300
@@ -108,7 +108,8 @@ def _format_news_date(iso: str) -> str:
def fetch_patch_notes() -> list:
"""Patch-notes list → [{id, title, date, body, url?, author?}, …]"""
req = urllib.request.Request(PATCHNOTES_URL, headers={"User-Agent": UA})
#req = urllib.request.Request(PATCHNOTES_URL, headers={"User-Agent": config.UA})
req = urllib.request.Request(PATCHNOTES_URL)
with secure_urlopen(req, timeout=NEWS_TIMEOUT) as r:
data = json.load(r)
items = data.get("items", [])
@@ -120,7 +121,8 @@ def fetch_patch_notes() -> list:
def fetch_featured_post() -> dict | None:
"""Latest announcements-forum post → {id, title, author?, date, url, html}"""
req = urllib.request.Request(NEWS_FEATURED_URL, headers={"User-Agent": UA})
#req = urllib.request.Request(NEWS_FEATURED_URL, headers={"User-Agent": config.UA})
req = urllib.request.Request(NEWS_FEATURED_URL)
with secure_urlopen(req, timeout=NEWS_TIMEOUT) as r:
data = json.load(r)
return data if isinstance(data, dict) and data.get("id") else None
@@ -215,7 +217,7 @@ class OctoUpdaterApp(tk.Tk):
# Move a pre-1.3 config/cache from beside the .exe into the per-user
# data dir before anything reads them, so first-run detection and
# load_config() below see the relocated files (see _relocate_legacy_data).
_relocate_legacy_data()
#config._relocate_legacy_data()
# Detect first run before anything writes the config.
self._first_run = not os.path.exists(config.CONFIG_FILE)