mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 13:44:14 +01:00
Update user-agent to something newer
This commit is contained in:
parent
46077b7cd2
commit
ce43d1ba4a
@ -4,13 +4,13 @@ import pathlib
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
from json import dumps
|
||||
from random import sample
|
||||
from shutil import which
|
||||
|
||||
from requests import codes
|
||||
from requests import post
|
||||
from requests import Timeout
|
||||
from svtplay_dl.utils.http import FIREFOX_UA
|
||||
from svtplay_dl.utils.output import formatname
|
||||
from svtplay_dl.utils.proc import run_program
|
||||
from svtplay_dl.utils.stream import subtitle_filter
|
||||
@ -185,14 +185,10 @@ def _sublanguage(stream, config, subfixes):
|
||||
def query(self):
|
||||
_ = parse(self)
|
||||
random_sentences = " ".join(sample(_, len(_) if len(_) < 8 else 8)).replace("\r\n", "")
|
||||
url = "https://whatlanguage.herokuapp.com"
|
||||
payload = {"query": random_sentences}
|
||||
# Note: requests handles json from version 2.4.2 and onwards so i use json.dumps for now.
|
||||
headers = {"content-type": "application/json"}
|
||||
url = "https://svtplay-dl.se/langdetect/"
|
||||
headers = {"User-Agent": f"{FIREFOX_UA} {platform.machine()}"}
|
||||
try:
|
||||
# Note: reasonable timeout i guess? svtplay-dl is mainly used while multitasking i presume,
|
||||
# and it is heroku after all (fast enough)
|
||||
r = post(url, data=dumps(payload), headers=headers, timeout=30)
|
||||
r = post(url, json={"query": random_sentences}, headers=headers, timeout=30)
|
||||
if r.status_code == codes.ok:
|
||||
try:
|
||||
response = r.json()
|
||||
|
@ -10,7 +10,7 @@ from svtplay_dl.utils.output import formatname
|
||||
from svtplay_dl.utils.parser import Options
|
||||
|
||||
# Used for UA spoofing in get_http_data()
|
||||
FIREFOX_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.3"
|
||||
FIREFOX_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
|
||||
|
||||
retry = Retry(total=5, read=5, connect=5, backoff_factor=0.3, status_forcelist=(500, 502, 504))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user