Compare commits

..

2 Commits

Author SHA1 Message Date
Uyanide f30a51204f feat: include appversion in UA 2026-03-31 15:13:58 +02:00
Uyanide 8362fa71a4 fix: sp 2026-03-31 15:13:58 +02:00
3 changed files with 12 additions and 5 deletions
-1
View File
@@ -1 +0,0 @@
__version__ = "0.1.5"
+4 -1
View File
@@ -10,10 +10,12 @@ from pathlib import Path
from platformdirs import user_cache_dir, user_config_dir
from dotenv import load_dotenv
from loguru import logger
from importlib.metadata import version
# Application
APP_NAME = "lrcfetch"
APP_AUTHOR = "Uyanide"
APP_VERSION = version(APP_NAME)
# Paths
CACHE_DIR = user_cache_dir(APP_NAME, APP_AUTHOR)
@@ -46,6 +48,7 @@ SPOTIFY_SECRET_URL = (
)
SPOTIFY_SP_DC = os.environ.get("SPOTIFY_SP_DC", "")
SPOTIFY_TOKEN_CACHE_FILE = os.path.join(CACHE_DIR, "spotify_token.json")
SPOTIFY_APP_VERSION = "1.2.87.284.g3ff41c13"
# Netease api
NETEASE_SEARCH_URL = "https://music.163.com/api/cloudsearch/pc"
@@ -63,7 +66,7 @@ PREFERRED_PLAYER = os.environ.get("LRCFETCH_PLAYER", "spotify")
# User-Agents
UA_BROWSER = "Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0"
UA_LRCFETCH = "LRCFetch (https://github.com/Uyanide/lrcfetch)"
UA_LRCFETCH = f"LRCFetch {APP_VERSION} (https://github.com/Uyanide/lrcfetch)"
os.makedirs(CACHE_DIR, exist_ok=True)
+8 -3
View File
@@ -30,6 +30,7 @@ from .base import BaseFetcher
from ..models import TrackMeta, LyricResult, CacheStatus
from ..config import (
HTTP_TIMEOUT,
SPOTIFY_APP_VERSION,
TTL_NOT_FOUND,
TTL_NETWORK_ERROR,
SPOTIFY_TOKEN_URL,
@@ -189,8 +190,9 @@ class SpotifyFetcher(BaseFetcher):
headers = {
"User-Agent": UA_BROWSER,
"Accept": "*/*",
"Referer": "https://open.spotify.com/",
"Cookie": f"sp_dc={SPOTIFY_SP_DC}",
"Accept": "application/json",
}
with httpx.Client(headers=headers) as client:
@@ -292,9 +294,12 @@ class SpotifyFetcher(BaseFetcher):
url = f"{SPOTIFY_LYRICS_URL}{track.trackid}?format=json&vocalRemoval=false&market=from_token"
headers = {
"User-Agent": UA_BROWSER,
"Authorization": f"Bearer {token}",
"App-Platform": "WebPlayer",
"Accept": "application/json",
"Authorization": f"Bearer {token}",
"Referer": "https://open.spotify.com/",
"App-Platform": "WebPlayer",
"Spotify-App-Version": SPOTIFY_APP_VERSION,
"Origin": "https://open.spotify.com",
}
try: