mirror of https://gitlab.com/bashrc2/epicyon
Rename function
parent
974e2d0830
commit
823766088e
|
@ -34,7 +34,7 @@ from utils import localActorUrl
|
|||
from blocking import isBlockedDomain
|
||||
from blocking import isBlockedHashtag
|
||||
from filters import isFiltered
|
||||
from session import getImageBinaryFromUrl
|
||||
from session import downloadImageAnyMimeType
|
||||
|
||||
|
||||
def _removeCDATA(text: str) -> str:
|
||||
|
@ -152,7 +152,7 @@ def _downloadNewswireFeedFavicon(session, baseDir: str,
|
|||
return False
|
||||
timeoutSec = 10
|
||||
imageData, mimeType = \
|
||||
getImageBinaryFromUrl(session, favUrl, timeoutSec, debug)
|
||||
downloadImageAnyMimeType(session, favUrl, timeoutSec, debug)
|
||||
if not imageData:
|
||||
return False
|
||||
if 'image/png' in mimeType:
|
||||
|
|
|
@ -394,7 +394,7 @@ def postImage(session, attachImageFilename: str, federationList: [],
|
|||
def downloadImage(session, baseDir: str, url: str,
|
||||
imageFilename: str, debug: bool,
|
||||
force: bool = False) -> bool:
|
||||
"""Downloads an image
|
||||
"""Downloads an image with an expected mime type
|
||||
"""
|
||||
if not url:
|
||||
return None
|
||||
|
@ -407,7 +407,8 @@ def downloadImage(session, baseDir: str, url: str,
|
|||
'gif': 'gif',
|
||||
'svg': 'svg+xml',
|
||||
'webp': 'webp',
|
||||
'avif': 'avif'
|
||||
'avif': 'avif',
|
||||
'ico': 'x-icon'
|
||||
}
|
||||
sessionHeaders = None
|
||||
for imFormat, mimeType in imageFormats.items():
|
||||
|
@ -454,8 +455,8 @@ def downloadImage(session, baseDir: str, url: str,
|
|||
return False
|
||||
|
||||
|
||||
def getImageBinaryFromUrl(session, url: str, timeoutSec: int, debug: bool):
|
||||
"""http GET for an image
|
||||
def downloadImageAnyMimeType(session, url: str, timeoutSec: int, debug: bool):
|
||||
"""http GET for an image with any mime type
|
||||
"""
|
||||
mimeType = 'image/png'
|
||||
contentType = None
|
||||
|
|
Loading…
Reference in New Issue