Rename function

merge-requests/30/head
Bob Mottram 2021-12-17 10:04:18 +00:00
parent 974e2d0830
commit 823766088e
2 changed files with 7 additions and 6 deletions

View File

@ -34,7 +34,7 @@ from utils import localActorUrl
from blocking import isBlockedDomain from blocking import isBlockedDomain
from blocking import isBlockedHashtag from blocking import isBlockedHashtag
from filters import isFiltered from filters import isFiltered
from session import getImageBinaryFromUrl from session import downloadImageAnyMimeType
def _removeCDATA(text: str) -> str: def _removeCDATA(text: str) -> str:
@ -152,7 +152,7 @@ def _downloadNewswireFeedFavicon(session, baseDir: str,
return False return False
timeoutSec = 10 timeoutSec = 10
imageData, mimeType = \ imageData, mimeType = \
getImageBinaryFromUrl(session, favUrl, timeoutSec, debug) downloadImageAnyMimeType(session, favUrl, timeoutSec, debug)
if not imageData: if not imageData:
return False return False
if 'image/png' in mimeType: if 'image/png' in mimeType:

View File

@ -394,7 +394,7 @@ def postImage(session, attachImageFilename: str, federationList: [],
def downloadImage(session, baseDir: str, url: str, def downloadImage(session, baseDir: str, url: str,
imageFilename: str, debug: bool, imageFilename: str, debug: bool,
force: bool = False) -> bool: force: bool = False) -> bool:
"""Downloads an image """Downloads an image with an expected mime type
""" """
if not url: if not url:
return None return None
@ -407,7 +407,8 @@ def downloadImage(session, baseDir: str, url: str,
'gif': 'gif', 'gif': 'gif',
'svg': 'svg+xml', 'svg': 'svg+xml',
'webp': 'webp', 'webp': 'webp',
'avif': 'avif' 'avif': 'avif',
'ico': 'x-icon'
} }
sessionHeaders = None sessionHeaders = None
for imFormat, mimeType in imageFormats.items(): for imFormat, mimeType in imageFormats.items():
@ -454,8 +455,8 @@ def downloadImage(session, baseDir: str, url: str,
return False return False
def getImageBinaryFromUrl(session, url: str, timeoutSec: int, debug: bool): def downloadImageAnyMimeType(session, url: str, timeoutSec: int, debug: bool):
"""http GET for an image """http GET for an image with any mime type
""" """
mimeType = 'image/png' mimeType = 'image/png'
contentType = None contentType = None