Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
barrycarey committed Dec 14, 2023
1 parent fd613f1 commit 32d82ec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion redditrepostsleuth/core/db/databasemodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ class RepostSearch(Base):
__tablename__ = 'repost_search'
__table_args__ = (
Index('idx_post_type_searched_at', 'post_type_id', 'searched_at'),
Index('idx_by_subreddit_and_type', 'subreddit', 'source', 'post_type_id', 'matches_found')
Index('idx_by_subreddit_and_type', 'subreddit', 'source', 'post_type_id', 'matches_found'),
Index('idx_source', 'source'),
Index('idx_matches_found', 'matches_found')
)
id = Column(Integer, primary_key=True)
post_id = Column(Integer, ForeignKey('post.id'))
Expand Down
6 changes: 3 additions & 3 deletions redditrepostsleuth/core/util/imagehashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests
from PIL import Image, UnidentifiedImageError
from PIL.Image import DecompressionBombError
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError, Timeout

from redditrepostsleuth.core.db.databasemodels import Post
from redditrepostsleuth.core.exception import ImageConversionException, ImageRemovedException, InvalidImageUrlException
Expand Down Expand Up @@ -67,8 +67,8 @@ def generate_img_by_url_requests(url: str) -> Optional[Image]:
}

try:
res = requests.get(url, headers=headers)
except (ConnectionError) as e:
res = requests.get(url, headers=headers, timeout=7)
except (ConnectionError, Timeout) as e:
raise ImageConversionException(str(e))

if res.status_code != 200:
Expand Down
7 changes: 6 additions & 1 deletion redditrepostsleuth/core/util/onlyfans_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_profile_links(username: str) -> list[str]:
response = fetch_from_util_api(url)

if response.status_code != 200:
log.warning('Non 200 return code %s from Util API')
log.warning('Non 200 return code %s from Util API', response.status_code)
raise UtilApiException(f'Unexpected status {response.status_code} from util API')

profile_links = json.loads(response.text)
Expand Down Expand Up @@ -166,6 +166,11 @@ def get_links_from_comments(username: str) -> list[str]:
response_json = json.loads(response.text)
all_urls = []

if not response_json:
log.warning('Bad data from Util api')
raise UtilApiException(f'Unexpected status {response.status_code} from util API')


if not response_json['data']['children']:
log.warning('No comment data returned for %s', username)
return []
Expand Down
2 changes: 1 addition & 1 deletion redditrepostsleuth/submonitorsvc/monitored_sub_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def handle_only_fans_check(
:return:
"""

if whitelisted_user and whitelisted_user.ignore_high_volume_repost_detection:
if whitelisted_user and whitelisted_user.ignore_adult_promoter_detection:
log.info('User %s is whitelisted, skipping adult promoter check')
return

Expand Down

0 comments on commit 32d82ec

Please sign in to comment.