mirror of
https://github.com/simon987/reddit_feed.git
synced 2025-04-24 12:15:51 +00:00
Remove extra fields
This commit is contained in:
parent
2e222774c1
commit
37cbd70877
@ -20,9 +20,6 @@ def post_process(thing):
|
|||||||
elif "selftext" in thing and thing["selftext"]:
|
elif "selftext" in thing and thing["selftext"]:
|
||||||
thing["urls"].extend(get_links_from_body(thing["selftext"]))
|
thing["urls"].extend(get_links_from_body(thing["selftext"]))
|
||||||
|
|
||||||
if thing["urls"]:
|
|
||||||
print(thing["urls"])
|
|
||||||
|
|
||||||
if "url" in thing and thing["url"] and is_external(thing["url"]):
|
if "url" in thing and thing["url"] and is_external(thing["url"]):
|
||||||
thing["urls"].append(thing["url"])
|
thing["urls"].append(thing["url"])
|
||||||
|
|
||||||
|
25
run.py
25
run.py
@ -14,6 +14,7 @@ from queue import Queue
|
|||||||
|
|
||||||
import pika
|
import pika
|
||||||
import praw
|
import praw
|
||||||
|
import psaw
|
||||||
from praw.endpoints import API_PATH
|
from praw.endpoints import API_PATH
|
||||||
from praw.models import Comment
|
from praw.models import Comment
|
||||||
|
|
||||||
@ -48,26 +49,25 @@ logger.addHandler(StreamHandler(sys.stdout))
|
|||||||
|
|
||||||
|
|
||||||
def serialize(thing):
|
def serialize(thing):
|
||||||
if isinstance(thing, Comment):
|
if isinstance(thing, Comment) or type(thing).__name__ == "comment":
|
||||||
return {
|
return {
|
||||||
"author": str(thing.author),
|
"author": str(thing.author),
|
||||||
"author_flair_text": thing.author_flair_text,
|
"author_flair_text": thing.author_flair_text,
|
||||||
"body": thing.body,
|
"body": thing.body,
|
||||||
"selftext_html": thing.body_html if hasattr(thing, "body_html") else None,
|
"selftext_html": thing.body_html if hasattr(thing, "body_html") else None,
|
||||||
"controversiality": thing.controversiality,
|
"controversiality": thing.controversiality if hasattr(thing, "controversiality") else None,
|
||||||
"created": int(thing.created),
|
"created": int(thing.created),
|
||||||
"created_utc": int(thing.created_utc),
|
"created_utc": int(thing.created_utc),
|
||||||
"downs": thing.downs if hasattr(thing, "downs") else 0,
|
"downs": thing.downs if hasattr(thing, "downs") else 0,
|
||||||
"id": thing.id,
|
"id": thing.id,
|
||||||
"link_id": thing.link_id,
|
"link_id": thing.link_id,
|
||||||
"name": thing.name,
|
"name": thing.name if hasattr(thing, "name") else None,
|
||||||
"parent_id": thing.parent_id,
|
"parent_id": thing.parent_id,
|
||||||
"permalink": thing.permalink,
|
"permalink": thing.permalink if hasattr(thing, "permalink") else None,
|
||||||
"score": thing.score,
|
"score": thing.score,
|
||||||
"subreddit": str(thing.subreddit),
|
"subreddit": str(thing.subreddit),
|
||||||
"subreddit_id": thing.subreddit_id,
|
"subreddit_id": thing.subreddit_id,
|
||||||
"subreddit_type": thing.subreddit_type,
|
"ups": thing.ups if hasattr(thing, "ups") else 0,
|
||||||
"ups": thing.ups,
|
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
@ -77,30 +77,17 @@ def serialize(thing):
|
|||||||
"created_utc": int(thing.created_utc),
|
"created_utc": int(thing.created_utc),
|
||||||
"domain": thing.domain,
|
"domain": thing.domain,
|
||||||
"id": thing.id,
|
"id": thing.id,
|
||||||
"is_crosspostable": thing.is_crosspostable,
|
|
||||||
"is_meta": thing.is_meta,
|
|
||||||
"is_original_content": thing.is_original_content,
|
|
||||||
"is_reddit_media_domain": thing.is_reddit_media_domain,
|
|
||||||
"is_robot_indexable": thing.is_robot_indexable,
|
|
||||||
"is_self": thing.is_self,
|
"is_self": thing.is_self,
|
||||||
"is_video": thing.is_video,
|
|
||||||
"link_flair_text": thing.link_flair_text if hasattr(thing, "link_flair_text") else None,
|
"link_flair_text": thing.link_flair_text if hasattr(thing, "link_flair_text") else None,
|
||||||
"locked": thing.locked,
|
|
||||||
"num_comments": thing.num_comments,
|
"num_comments": thing.num_comments,
|
||||||
"num_crossposts": thing.num_crossposts,
|
|
||||||
"over_18": thing.over_18,
|
"over_18": thing.over_18,
|
||||||
"parent_whitelist_status": thing.parent_whitelist_status,
|
|
||||||
"permalink": thing.permalink,
|
"permalink": thing.permalink,
|
||||||
"pinned": thing.pinned,
|
|
||||||
"score": thing.score,
|
"score": thing.score,
|
||||||
"selftext": thing.selftext if hasattr(thing, "selftext") else None,
|
"selftext": thing.selftext if hasattr(thing, "selftext") else None,
|
||||||
"selftext_html": thing.selftext_html if hasattr(thing, "selftext_html") else None,
|
"selftext_html": thing.selftext_html if hasattr(thing, "selftext_html") else None,
|
||||||
"spoiler": thing.spoiler,
|
|
||||||
"stickied": thing.stickied,
|
"stickied": thing.stickied,
|
||||||
"subreddit": str(thing.subreddit),
|
"subreddit": str(thing.subreddit),
|
||||||
"subreddit_id": thing.subreddit_id,
|
"subreddit_id": thing.subreddit_id,
|
||||||
"subreddit_subscribers": thing.subreddit_subscribers,
|
|
||||||
"subreddit_type": thing.subreddit_type,
|
|
||||||
"title": thing.title,
|
"title": thing.title,
|
||||||
"ups": thing.ups if hasattr(thing, "ups") else 0,
|
"ups": thing.ups if hasattr(thing, "ups") else 0,
|
||||||
"downs": thing.downs if hasattr(thing, "downs") else 0,
|
"downs": thing.downs if hasattr(thing, "downs") else 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user