Skip to content

Commit

Permalink
mappings: Reddit capture NoneType for media_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed May 16, 2023
1 parent 2410fae commit b1412d5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions resources/mappings/field_mapping_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,17 @@ def value_count(x):
if is_text:
post_record.post_type = lbsn.Post.TEXT
elif is_media:
if is_media.get("type") == "imgur.com":
media_type = is_media.get("type")
if media_type and media_type == "imgur.com":
post_record.post_type = lbsn.Post.IMAGE
elif is_media.get("type").startswith("youtube"):
elif media_type and media_type.startswith("youtube"):
post_record.post_type = lbsn.Post.VIDEO
else:
# dig deeper
media_type = is_media.get("oembed").get("type")
if media_type == "video":
if media_type and media_type == "video":
post_record.post_type = lbsn.Post.VIDEO
elif media_type == "rich":
elif media_type and media_type == "rich":
post_record.post_type = lbsn.Post.OTHER
elif is_url:
if is_url.endswith((".jpg", ".webp", ".jpeg", ".png", ".gif")):
Expand Down

0 comments on commit b1412d5

Please sign in to comment.