mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
images > 2000px tend to be real photos instead of 4chan screenshots
This commit is contained in:
parent
9840f7bc53
commit
cfce14b9f3
1 changed files with 13 additions and 12 deletions
|
@ -793,18 +793,19 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
# Alert regarding fascist meme content
|
# Alert regarding fascist meme content
|
||||||
try:
|
if img_width < 2000: # images > 2000px tend to be real photos instead of 4chan screenshots.
|
||||||
image_text = pytesseract.image_to_string(Image.open(BytesIO(source_image)).convert('L'), timeout=30)
|
try:
|
||||||
except FileNotFoundError as e:
|
image_text = pytesseract.image_to_string(Image.open(BytesIO(source_image)).convert('L'), timeout=30)
|
||||||
image_text = ''
|
except FileNotFoundError as e:
|
||||||
if 'Anonymous' in image_text and ('No.' in image_text or ' N0' in image_text): # chan posts usually contain the text 'Anonymous' and ' No.12345'
|
image_text = ''
|
||||||
post = Post.query.filter_by(image_id=file.id).first()
|
if 'Anonymous' in image_text and ('No.' in image_text or ' N0' in image_text): # chan posts usually contain the text 'Anonymous' and ' No.12345'
|
||||||
notification = Notification(title='Review this',
|
post = Post.query.filter_by(image_id=file.id).first()
|
||||||
user_id=1,
|
notification = Notification(title='Review this',
|
||||||
author_id=post.user_id,
|
user_id=1,
|
||||||
url=url_for('activitypub.post_ap', post_id=post.id))
|
author_id=post.user_id,
|
||||||
db.session.add(notification)
|
url=url_for('activitypub.post_ap', post_id=post.id))
|
||||||
db.session.commit()
|
db.session.add(notification)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
# create a summary from markdown if present, otherwise use html if available
|
# create a summary from markdown if present, otherwise use html if available
|
||||||
|
|
Loading…
Add table
Reference in a new issue