🛠️ Implemented timeout for `requests calls.
This commit is contained in:
+4
-1
@@ -61,6 +61,8 @@ __ERROR_KEY__ = (
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from constants import REQUESTS_TIMEOUT_SEC
|
||||||
|
|
||||||
|
|
||||||
def getNum():
|
def getNum():
|
||||||
return len(__API_KEYS__["keys"])
|
return len(__API_KEYS__["keys"])
|
||||||
@@ -94,7 +96,8 @@ def getVersion():
|
|||||||
|
|
||||||
# Load from gist
|
# Load from gist
|
||||||
try:
|
try:
|
||||||
respond = requests.get("https://api.github.com/gists/48d01f5a24b4b7b37f19443977c22cd6")
|
respond = requests.get("https://api.github.com/gists/48d01f5a24b4b7b37f19443977c22cd6",
|
||||||
|
timeout=REQUESTS_TIMEOUT_SEC)
|
||||||
if respond.status_code == 200:
|
if respond.status_code == 200:
|
||||||
content = respond.json()["files"]["tidal-api-key.json"]["content"]
|
content = respond.json()["files"]["tidal-api-key.json"]["content"]
|
||||||
__API_KEYS__ = json.loads(content)
|
__API_KEYS__ = json.loads(content)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
CTX_TIDAL: str = "tidal"
|
CTX_TIDAL: str = "tidal"
|
||||||
|
REQUESTS_TIMEOUT_SEC = 45
|
||||||
|
|
||||||
|
|
||||||
class QualityVideo(Enum):
|
class QualityVideo(Enum):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from rich.progress import Progress
|
|||||||
from tidalapi import Album, Mix, Playlist, Session, Track, UserPlaylist, Video
|
from tidalapi import Album, Mix, Playlist, Session, Track, UserPlaylist, Video
|
||||||
|
|
||||||
from tidal_dl_ng.config import Settings
|
from tidal_dl_ng.config import Settings
|
||||||
from tidal_dl_ng.constants import MediaType
|
from tidal_dl_ng.constants import REQUESTS_TIMEOUT_SEC, MediaType
|
||||||
from tidal_dl_ng.helper.decryption import decrypt_file, decrypt_security_token
|
from tidal_dl_ng.helper.decryption import decrypt_file, decrypt_security_token
|
||||||
from tidal_dl_ng.helper.exceptions import MediaUnknown
|
from tidal_dl_ng.helper.exceptions import MediaUnknown
|
||||||
from tidal_dl_ng.helper.path import check_file_exists, format_path_media, path_validate
|
from tidal_dl_ng.helper.path import check_file_exists, format_path_media, path_validate
|
||||||
@@ -134,7 +134,7 @@ class Download:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Streaming, so we can iterate over the response.
|
# Streaming, so we can iterate over the response.
|
||||||
r = requests.get(stream_url, stream=True)
|
r = requests.get(stream_url, stream=True, timeout=REQUESTS_TIMEOUT_SEC)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
total_size_in_bytes = int(r.headers.get("content-length", 0))
|
total_size_in_bytes = int(r.headers.get("content-length", 0))
|
||||||
block_size = 4096
|
block_size = 4096
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import pathlib
|
|||||||
|
|
||||||
import mutagen
|
import mutagen
|
||||||
import requests
|
import requests
|
||||||
|
from constants import REQUESTS_TIMEOUT_SEC
|
||||||
from mutagen import flac, mp4
|
from mutagen import flac, mp4
|
||||||
from mutagen.id3 import APIC, TALB, TCOM, TCOP, TDRC, TIT2, TOPE, TPE1, TRCK, TSRC, USLT
|
from mutagen.id3 import APIC, TALB, TCOM, TCOP, TDRC, TIT2, TOPE, TPE1, TRCK, TSRC, USLT
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ class Metadata:
|
|||||||
|
|
||||||
if url:
|
if url:
|
||||||
try:
|
try:
|
||||||
result = requests.get(url).content
|
result = requests.get(url, timeout=REQUESTS_TIMEOUT_SEC).content
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif path_file:
|
elif path_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user