mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
don't strip params from og:image url #37
This commit is contained in:
parent
bc3795244f
commit
820af0ada2
1 changed files with 4 additions and 4 deletions
|
@ -140,7 +140,8 @@ def opengraph_parse(url):
|
||||||
|
|
||||||
|
|
||||||
def url_to_thumbnail_file(filename) -> File:
|
def url_to_thumbnail_file(filename) -> File:
|
||||||
unused, file_extension = os.path.splitext(filename)
|
filename_for_extension = filename.split('?')[0] if '?' in filename else filename
|
||||||
|
unused, file_extension = os.path.splitext(filename_for_extension)
|
||||||
response = requests.get(filename, timeout=5)
|
response = requests.get(filename, timeout=5)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
new_filename = gibberish(15)
|
new_filename = gibberish(15)
|
||||||
|
@ -199,9 +200,8 @@ def save_post(form, post: Post):
|
||||||
opengraph = opengraph_parse(form.link_url.data)
|
opengraph = opengraph_parse(form.link_url.data)
|
||||||
if opengraph and (opengraph.get('og:image', '') != '' or opengraph.get('og:image:url', '') != ''):
|
if opengraph and (opengraph.get('og:image', '') != '' or opengraph.get('og:image:url', '') != ''):
|
||||||
filename = opengraph.get('og:image') or opengraph.get('og:image:url')
|
filename = opengraph.get('og:image') or opengraph.get('og:image:url')
|
||||||
if '?' in filename:
|
filename_for_extension = filename.split('?')[0] if '?' in filename else filename
|
||||||
filename = filename.split('?')[0]
|
unused, file_extension = os.path.splitext(filename_for_extension)
|
||||||
unused, file_extension = os.path.splitext(filename)
|
|
||||||
if file_extension.lower() in allowed_extensions:
|
if file_extension.lower() in allowed_extensions:
|
||||||
file = url_to_thumbnail_file(filename)
|
file = url_to_thumbnail_file(filename)
|
||||||
if file:
|
if file:
|
||||||
|
|
Loading…
Add table
Reference in a new issue