mirror of
https://github.com/mvt-project/mvt.git
synced 2026-10-31 18:24:10 +01:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a77d3f74aa | ||
|
|
e69a02169c | ||
|
|
2e5bf5f678 | ||
|
|
f65d77036a | ||
|
|
00a00ca6e9 | ||
|
|
2792988626 | ||
|
|
711f7cedc1 | ||
|
|
d8c3d1e418 | ||
|
|
856c008bc0 | ||
|
|
5820bc95c1 | ||
|
|
7609760cfb | ||
|
|
7d985f3c97 | ||
|
|
dcfcf51988 | ||
|
|
869f3a110c | ||
|
|
4495a46688 | ||
|
|
d4b1c6bd25 | ||
|
|
efbd4bbdc0 |
+1
-15
@@ -3,16 +3,11 @@
|
||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||
# https://license.mvt.re/1.1/
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from tld import get_tld
|
||||
|
||||
from .config import settings
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
SHORTENER_DOMAINS = [
|
||||
"0rz.tw",
|
||||
"1drv.ms",
|
||||
@@ -380,16 +375,7 @@ class URL:
|
||||
|
||||
def unshorten(self) -> Optional[str]:
|
||||
"""Unshorten the URL by requesting an HTTP HEAD response."""
|
||||
|
||||
if settings.NETWORK_ACCESS_ALLOWED is False:
|
||||
log.info(
|
||||
"Network access disabled (MVT_NETWORK_ACCESS_ALLOWED=False), "
|
||||
"skipping unshorten for %s",
|
||||
self.url,
|
||||
)
|
||||
return ""
|
||||
|
||||
res = requests.head(self.url, timeout=settings.NETWORK_TIMEOUT)
|
||||
res = requests.head(self.url)
|
||||
if str(res.status_code).startswith("30"):
|
||||
return res.headers["Location"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user