deepsift 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepsift/__init__.py +39 -0
- deepsift/__main__.py +8 -0
- deepsift/cli.py +171 -0
- deepsift/filters.py +111 -0
- deepsift/models/__init__.py +17 -0
- deepsift/models/base.py +100 -0
- deepsift/models/comment.py +38 -0
- deepsift/models/enums.py +243 -0
- deepsift/models/post.py +29 -0
- deepsift/scraper.py +397 -0
- deepsift/sources/__init__.py +14 -0
- deepsift/sources/arctic_shift.py +263 -0
- deepsift/sources/base.py +102 -0
- deepsift/sources/dummy.py +207 -0
- deepsift/sources/registry.py +24 -0
- deepsift/storage/__init__.py +10 -0
- deepsift/storage/base.py +37 -0
- deepsift/storage/parquet.py +86 -0
- deepsift-0.2.0.dist-info/METADATA +115 -0
- deepsift-0.2.0.dist-info/RECORD +24 -0
- deepsift-0.2.0.dist-info/WHEEL +5 -0
- deepsift-0.2.0.dist-info/entry_points.txt +3 -0
- deepsift-0.2.0.dist-info/licenses/LICENSE +21 -0
- deepsift-0.2.0.dist-info/top_level.txt +1 -0
deepsift/models/enums.py
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Enumerations of all known Arctic Shift / Reddit API fields for Posts and Comments.
|
|
3
|
+
"""
|
|
4
|
+
import difflib
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from typing import Iterable, Set, Optional, Union
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class FieldEnum(str, Enum):
|
|
10
|
+
"""Base enumeration providing string interop, descriptions, validation, and typo hints."""
|
|
11
|
+
description: str
|
|
12
|
+
|
|
13
|
+
def __new__(cls, value: str, description: str = ""):
|
|
14
|
+
obj = str.__new__(cls, value)
|
|
15
|
+
obj._value_ = value
|
|
16
|
+
obj.description = description
|
|
17
|
+
obj.__doc__ = description
|
|
18
|
+
return obj
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
return self.value
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def get_description(cls, value: Union[str, "FieldEnum"]) -> str:
|
|
25
|
+
"""Returns the description for a field, or empty string if not found."""
|
|
26
|
+
val = value.value if isinstance(value, cls) else str(value).lower().strip()
|
|
27
|
+
member = cls._value2member_map_.get(val)
|
|
28
|
+
return member.description if member else ""
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def has_field(cls, value: Union[str, "FieldEnum"]) -> bool:
|
|
32
|
+
"""Checks if a field exists in this enumeration."""
|
|
33
|
+
val = value.value if isinstance(value, cls) else str(value).lower().strip()
|
|
34
|
+
return val in cls._value2member_map_
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def validate(cls, value: Union[str, "FieldEnum"]) -> str:
|
|
38
|
+
"""
|
|
39
|
+
Validates that a field is in this enumeration.
|
|
40
|
+
Returns canonical field string or raises ValueError with typo suggestions.
|
|
41
|
+
"""
|
|
42
|
+
val = value.value if isinstance(value, cls) else str(value).strip()
|
|
43
|
+
if val in cls._value2member_map_:
|
|
44
|
+
return val
|
|
45
|
+
val_lower = val.lower()
|
|
46
|
+
if val_lower in cls._value2member_map_:
|
|
47
|
+
return val_lower
|
|
48
|
+
|
|
49
|
+
matches = difflib.get_close_matches(val_lower, [m.value for m in cls], n=1, cutoff=0.55)
|
|
50
|
+
hint = f" Did you mean '{matches[0]}'?" if matches else ""
|
|
51
|
+
raise ValueError(f"Invalid {cls.__name__} field '{val}'.{hint}")
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def validate_many(cls, fields: Optional[Union[str, "FieldEnum", Iterable[Union[str, "FieldEnum"]]]]) -> Optional[Set[str]]:
|
|
55
|
+
"""
|
|
56
|
+
Validates one or more fields. Returns a validated Set[str] or None if fields is None.
|
|
57
|
+
"""
|
|
58
|
+
if fields is None:
|
|
59
|
+
return None
|
|
60
|
+
if isinstance(fields, (str, cls)):
|
|
61
|
+
fields = [fields]
|
|
62
|
+
validated = set()
|
|
63
|
+
for f in fields:
|
|
64
|
+
validated.add(cls.validate(f))
|
|
65
|
+
return validated
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def all_fields(cls) -> Set[str]:
|
|
69
|
+
"""Returns a set of all canonical field strings in this enumeration."""
|
|
70
|
+
return {m.value for m in cls}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class PostField(FieldEnum):
|
|
74
|
+
"""All known Reddit / Arctic Shift post API fields with descriptions."""
|
|
75
|
+
ALL_AWARDINGS = ("all_awardings", "List of Reddit awards received by this post, including coin values and icons.")
|
|
76
|
+
ALLOW_LIVE_COMMENTS = ("allow_live_comments", "Whether live comment mode is enabled for the submission.")
|
|
77
|
+
ARCHIVED = ("archived", "Whether the post is archived and no longer accepts votes or comments.")
|
|
78
|
+
AUTHOR = ("author", "Reddit username of the post submitter.")
|
|
79
|
+
AUTHOR_FLAIR_BACKGROUND_COLOR = ("author_flair_background_color", "Background hex color code for the author user flair.")
|
|
80
|
+
AUTHOR_FLAIR_CSS_CLASS = ("author_flair_css_class", "CSS class name applied to author flair in old Reddit styling.")
|
|
81
|
+
AUTHOR_FLAIR_RICHTEXT = ("author_flair_richtext", "Structured rich text components and emojis for author flair.")
|
|
82
|
+
AUTHOR_FLAIR_TEMPLATE_ID = ("author_flair_template_id", "UUID template ID of author flair preset used.")
|
|
83
|
+
AUTHOR_FLAIR_TEXT = ("author_flair_text", "Plaintext content of the author user flair.")
|
|
84
|
+
AUTHOR_FLAIR_TEXT_COLOR = ("author_flair_text_color", "Text color scheme ('dark' or 'light') for author flair.")
|
|
85
|
+
AUTHOR_FLAIR_TYPE = ("author_flair_type", "Type of author flair, usually 'text' or 'richtext'.")
|
|
86
|
+
AUTHOR_FULLNAME = ("author_fullname", "Full Reddit account ID with 't2_' prefix of the author.")
|
|
87
|
+
AUTHOR_IS_BLOCKED = ("author_is_blocked", "Whether the author is blocked by the viewing account context.")
|
|
88
|
+
AUTHOR_PATREON_FLAIR = ("author_patreon_flair", "Whether the author has Patreon flair integration active.")
|
|
89
|
+
AUTHOR_PREMIUM = ("author_premium", "Whether the author holds an active Reddit Premium subscription.")
|
|
90
|
+
AWARDERS = ("awarders", "List of users who awarded this post.")
|
|
91
|
+
BANNED_BY = ("banned_by", "Moderator or system actor that removed this post.")
|
|
92
|
+
CAN_GILD = ("can_gild", "Whether the submission can receive Reddit awards.")
|
|
93
|
+
CAN_MOD_POST = ("can_mod_post", "Whether viewing user has moderator permissions on this post.")
|
|
94
|
+
CATEGORY = ("category", "Categorical tag of the post.")
|
|
95
|
+
CLICKED = ("clicked", "Whether the post link was clicked by the authenticated session.")
|
|
96
|
+
CONTENT_CATEGORIES = ("content_categories", "List of content categories assigned to the subreddit or post.")
|
|
97
|
+
CONTEST_MODE = ("contest_mode", "Whether comment scores are randomized and hidden in contest mode.")
|
|
98
|
+
CREATED_UTC = ("created_utc", "Unix timestamp (UTC seconds) when the post was created.")
|
|
99
|
+
DISCUSSION_TYPE = ("discussion_type", "Type of discussion (e.g. 'CHAT' for live chat posts).")
|
|
100
|
+
DISTINGUISHED = ("distinguished", "Distinguished status ('moderator', 'admin', or null).")
|
|
101
|
+
DOMAIN = ("domain", "Domain of the submitted URL (e.g. 'self.resumes', 'i.redd.it').")
|
|
102
|
+
DOWNS = ("downs", "Legacy downvote count (always 0 in modern Reddit API).")
|
|
103
|
+
EDITED = ("edited", "False if unedited, or Unix timestamp UTC seconds when last edited.")
|
|
104
|
+
FLAIR = ("flair", "General flair metadata object or alias if present.")
|
|
105
|
+
GILDED = ("gilded", "Number of times the post received Reddit Gold.")
|
|
106
|
+
GILDINGS = ("gildings", "Dictionary mapping award types to counts received.")
|
|
107
|
+
HIDDEN = ("hidden", "Whether the post has been marked hidden by the user.")
|
|
108
|
+
HIDE_SCORE = ("hide_score", "Whether the post score is currently hidden to users.")
|
|
109
|
+
ID = ("id", "Base36 unique alphanumeric ID of the post (e.g. '1c6z2px').")
|
|
110
|
+
IS_BLANK = ("is_blank", "Flag indicating if post body is empty.")
|
|
111
|
+
IS_CREATED_FROM_ADS_UI = ("is_created_from_ads_ui", "Whether post was submitted through Reddit advertising UI.")
|
|
112
|
+
IS_CROSSPOSTABLE = ("is_crosspostable", "Whether this post can be crossposted to other subreddits.")
|
|
113
|
+
IS_GALLERY = ("is_gallery", "Whether the post contains multiple images in Reddit gallery format.")
|
|
114
|
+
IS_META = ("is_meta", "Whether the submission was flagged as subreddit meta discussion.")
|
|
115
|
+
IS_ORIGINAL_CONTENT = ("is_original_content", "Whether the submitter flagged the submission as Original Content.")
|
|
116
|
+
IS_REDDIT_MEDIA_DOMAIN = ("is_reddit_media_domain", "Whether media is hosted on Reddit infrastructure.")
|
|
117
|
+
IS_ROBOT_INDEXABLE = ("is_robot_indexable", "Whether web crawler search bots are allowed to index this post.")
|
|
118
|
+
IS_SELF = ("is_self", "True if text submission (self-post), False if link or media.")
|
|
119
|
+
IS_VIDEO = ("is_video", "True if this post is a native Reddit video.")
|
|
120
|
+
LIKES = ("likes", "Voting state of viewing user (True for upvote, False for downvote).")
|
|
121
|
+
LINK_FLAIR_BACKGROUND_COLOR = ("link_flair_background_color", "Background hex color code for the link flair.")
|
|
122
|
+
LINK_FLAIR_CSS_CLASS = ("link_flair_css_class", "CSS class name applied to post flair in old Reddit styling.")
|
|
123
|
+
LINK_FLAIR_RICHTEXT = ("link_flair_richtext", "Structured rich text components and emojis for link flair.")
|
|
124
|
+
LINK_FLAIR_TEMPLATE_ID = ("link_flair_template_id", "UUID template ID of link flair preset used.")
|
|
125
|
+
LINK_FLAIR_TEXT = ("link_flair_text", "Plaintext label of the post link flair (e.g. 'Resume Review').")
|
|
126
|
+
LINK_FLAIR_TEXT_COLOR = ("link_flair_text_color", "Text color scheme ('dark' or 'light') for link flair.")
|
|
127
|
+
LINK_FLAIR_TYPE = ("link_flair_type", "Type of post flair, typically 'text' or 'richtext'.")
|
|
128
|
+
LOCKED = ("locked", "Whether comments are locked and disabled on this post.")
|
|
129
|
+
MEDIA = ("media", "Embedded media metadata object (player dimensions, provider specs).")
|
|
130
|
+
MEDIA_EMBED = ("media_embed", "Raw HTML embed code dictionary for external media.")
|
|
131
|
+
MEDIA_METADATA = ("media_metadata", "Dictionary of image/media assets for galleries and inline images.")
|
|
132
|
+
MEDIA_ONLY = ("media_only", "Subreddit setting flag indicating whether media-only is enforced.")
|
|
133
|
+
NAME = ("name", "Full Reddit thing identifier with 't3_' prefix (e.g. 't3_1c6z2px').")
|
|
134
|
+
NO_FOLLOW = ("no_follow", "Whether links in this post have HTML rel='nofollow' attached.")
|
|
135
|
+
NUM_COMMENTS = ("num_comments", "Total count of comments (top-level and nested) on this post.")
|
|
136
|
+
NUM_CROSSPOSTS = ("num_crossposts", "Number of times this post was crossposted to other subreddits.")
|
|
137
|
+
NUM_DUPLICATES = ("num_duplicates", "Number of duplicate link submissions detected on Reddit.")
|
|
138
|
+
OVER_18 = ("over_18", "Whether the post is flagged as Not Safe For Work (NSFW / 18+).")
|
|
139
|
+
PARENT_WHITELIST_STATUS = ("parent_whitelist_status", "Subreddit advertising whitelist status inherited from parent.")
|
|
140
|
+
PERMALINK = ("permalink", "Relative URL path to the submission on reddit.com.")
|
|
141
|
+
PINNED = ("pinned", "Whether the submission is pinned to submitter user profile.")
|
|
142
|
+
POST_HINT = ("post_hint", "Hint about content type ('image', 'link', 'hosted:video', 'rich:video').")
|
|
143
|
+
PREVIEW = ("preview", "Thumbnail preview resolutions and image variants generated by Reddit.")
|
|
144
|
+
PWLS = ("pwls", "Parent whitelist status integer code for advertising tier.")
|
|
145
|
+
QUARANTINE = ("quarantine", "Whether the subreddit containing this post is quarantined.")
|
|
146
|
+
REMOVAL_REASON = ("removal_reason", "Internal removal note or reason identifier if removed by moderators.")
|
|
147
|
+
REMOVED_BY = ("removed_by", "Actor who removed the post (e.g. 'moderator', 'automod_filtered').")
|
|
148
|
+
REMOVED_BY_CATEGORY = ("removed_by_category", "Category explaining removal ('moderator', 'deleted', 'automod_filtered').")
|
|
149
|
+
RETRIEVED_ON = ("retrieved_on", "Unix timestamp when Arctic Shift/Pushshift archived this record.")
|
|
150
|
+
SAVED = ("saved", "Whether the post is saved to the viewer Reddit account bookmarks.")
|
|
151
|
+
SCORE = ("score", "Net score of the post (upvotes minus downvotes).")
|
|
152
|
+
SECURE_MEDIA = ("secure_media", "HTTPS-secure media metadata object.")
|
|
153
|
+
SECURE_MEDIA_EMBED = ("secure_media_embed", "HTTPS-secure HTML embed dictionary.")
|
|
154
|
+
SELFTEXT = ("selftext", "Body text in Markdown format for text submissions.")
|
|
155
|
+
SELFTEXT_HTML = ("selftext_html", "HTML-rendered version of the post Markdown selftext body.")
|
|
156
|
+
SEND_REPLIES = ("send_replies", "Whether author opted to receive inbox notifications for replies.")
|
|
157
|
+
SPOILER = ("spoiler", "Whether the post has been marked with a spoiler tag.")
|
|
158
|
+
STICKIED = ("stickied", "Whether the post is stickied / pinned to the top of the subreddit.")
|
|
159
|
+
SUBREDDIT = ("subreddit", "Name of the subreddit without prefix (e.g. 'resumes').")
|
|
160
|
+
SUBREDDIT_ID = ("subreddit_id", "Full subreddit ID with 't5_' prefix (e.g. 't5_2qr79').")
|
|
161
|
+
SUBREDDIT_NAME_PREFIXED = ("subreddit_name_prefixed", "Subreddit name prefixed with 'r/' (e.g. 'r/resumes').")
|
|
162
|
+
SUBREDDIT_SUBSCRIBERS = ("subreddit_subscribers", "Subscriber count of the subreddit at archiving time.")
|
|
163
|
+
SUBREDDIT_TYPE = ("subreddit_type", "Visibility status of subreddit ('public', 'restricted', 'private').")
|
|
164
|
+
SUGGESTED_SORT = ("suggested_sort", "Recommended comment sorting order ('confidence', 'top', 'new', 'qa').")
|
|
165
|
+
THUMBNAIL = ("thumbnail", "URL of thumbnail image or placeholder ('self', 'default', 'nsfw').")
|
|
166
|
+
THUMBNAIL_HEIGHT = ("thumbnail_height", "Height of thumbnail image in pixels.")
|
|
167
|
+
THUMBNAIL_WIDTH = ("thumbnail_width", "Width of thumbnail image in pixels.")
|
|
168
|
+
TITLE = ("title", "Submission title text.")
|
|
169
|
+
TOP_AWARDED_TYPE = ("top_awarded_type", "Type or tier of top award if heavily awarded.")
|
|
170
|
+
TOTAL_AWARDS_RECEIVED = ("total_awards_received", "Aggregate count of all awards received on this post.")
|
|
171
|
+
TREATMENT_TAGS = ("treatment_tags", "Special UI treatment tags applied by Reddit.")
|
|
172
|
+
UPS = ("ups", "Upvotes count (matches score in modern Reddit API).")
|
|
173
|
+
UPVOTE_RATIO = ("upvote_ratio", "Ratio of upvotes to total votes (e.g. 0.95 for 95% upvoted).")
|
|
174
|
+
URL = ("url", "Target URL (external link, media file, or permalink if self-post).")
|
|
175
|
+
URL_OVERRIDDEN_BY_DEST = ("url_overridden_by_dest", "Original destination link before Reddit URL overrides.")
|
|
176
|
+
VIEW_COUNT = ("view_count", "Total post view count (typically null for public API).")
|
|
177
|
+
VISITED = ("visited", "Whether the post has been visited by the viewing user session.")
|
|
178
|
+
WHITELIST_STATUS = ("whitelist_status", "Subreddit advertising whitelist tier status string.")
|
|
179
|
+
WLS = ("wls", "Subreddit advertising whitelist tier integer code.")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class CommentField(FieldEnum):
|
|
183
|
+
"""All known Reddit / Arctic Shift comment API fields with descriptions."""
|
|
184
|
+
ALL_AWARDINGS = ("all_awardings", "List of Reddit awards received by this comment.")
|
|
185
|
+
ARCHIVED = ("archived", "Whether the comment is archived and cannot receive new votes or replies.")
|
|
186
|
+
ASSOCIATED_AWARD = ("associated_award", "Details of award that generated this comment if applicable.")
|
|
187
|
+
AUTHOR = ("author", "Reddit username of the comment author.")
|
|
188
|
+
AUTHOR_FLAIR_BACKGROUND_COLOR = ("author_flair_background_color", "Background hex color code for author user flair.")
|
|
189
|
+
AUTHOR_FLAIR_CSS_CLASS = ("author_flair_css_class", "CSS class name applied to author flair in old Reddit styling.")
|
|
190
|
+
AUTHOR_FLAIR_RICHTEXT = ("author_flair_richtext", "Structured rich text components and emojis for author flair.")
|
|
191
|
+
AUTHOR_FLAIR_TEMPLATE_ID = ("author_flair_template_id", "UUID template ID of author flair preset used.")
|
|
192
|
+
AUTHOR_FLAIR_TEXT = ("author_flair_text", "Plaintext content of the author user flair.")
|
|
193
|
+
AUTHOR_FLAIR_TEXT_COLOR = ("author_flair_text_color", "Text color scheme ('dark' or 'light') for author flair.")
|
|
194
|
+
AUTHOR_FLAIR_TYPE = ("author_flair_type", "Type of author flair, usually 'text' or 'richtext'.")
|
|
195
|
+
AUTHOR_FULLNAME = ("author_fullname", "Full Reddit account ID with 't2_' prefix of the author.")
|
|
196
|
+
AUTHOR_IS_BLOCKED = ("author_is_blocked", "Whether the author is blocked by viewing account context.")
|
|
197
|
+
AUTHOR_PATREON_FLAIR = ("author_patreon_flair", "Whether the author has Patreon flair integration active.")
|
|
198
|
+
AUTHOR_PREMIUM = ("author_premium", "Whether the author holds an active Reddit Premium subscription.")
|
|
199
|
+
AWARDERS = ("awarders", "List of users who awarded this comment.")
|
|
200
|
+
BANNED_BY = ("banned_by", "Moderator or system actor that removed this comment.")
|
|
201
|
+
BODY = ("body", "Body text of the comment in Markdown format.")
|
|
202
|
+
BODY_HTML = ("body_html", "HTML-rendered version of the comment Markdown body.")
|
|
203
|
+
CAN_GILD = ("can_gild", "Whether the comment can receive Reddit awards.")
|
|
204
|
+
CAN_MOD_POST = ("can_mod_post", "Whether viewing user has moderator permissions on this comment.")
|
|
205
|
+
COLLAPSED = ("collapsed", "Whether comment is collapsed by default in Reddit UI.")
|
|
206
|
+
COLLAPSED_BECAUSE_CROWD_CONTROL = ("collapsed_because_crowd_control", "Whether comment was auto-collapsed by Reddit Crowd Control.")
|
|
207
|
+
COLLAPSED_REASON = ("collapsed_reason", "Explanation why comment was collapsed (e.g. 'low score').")
|
|
208
|
+
COMMENT_ID = ("comment_id", "Normalized base36 comment ID without prefix (alias of id).")
|
|
209
|
+
COMMENT_TYPE = ("comment_type", "Type tag for special comments (e.g. moderator note, prediction).")
|
|
210
|
+
CONTROVERSIALITY = ("controversiality", "Controversiality metric (1 if balanced upvotes/downvotes, 0 otherwise).")
|
|
211
|
+
CREATED_UTC = ("created_utc", "Unix timestamp (UTC seconds) when the comment was posted.")
|
|
212
|
+
DISTINGUISHED = ("distinguished", "Distinguished status ('moderator', 'admin', or null).")
|
|
213
|
+
DOWNS = ("downs", "Legacy downvote count (always 0 in modern Reddit API).")
|
|
214
|
+
EDITED = ("edited", "False if unedited, or Unix timestamp UTC seconds when last edited.")
|
|
215
|
+
GILDED = ("gilded", "Number of times the comment received Reddit Gold.")
|
|
216
|
+
GILDINGS = ("gildings", "Dictionary mapping award types to counts received.")
|
|
217
|
+
ID = ("id", "Base36 unique alphanumeric ID of the comment (e.g. 'c6z2pxa').")
|
|
218
|
+
IS_SUBMITTER = ("is_submitter", "True if comment author is original submitter (OP) of the post.")
|
|
219
|
+
LIKES = ("likes", "Voting state of viewing user (True for upvote, False for downvote).")
|
|
220
|
+
LINK_ID = ("link_id", "Full ID with 't3_' prefix of parent post this comment belongs to.")
|
|
221
|
+
LOCKED = ("locked", "Whether replies to this comment are locked and disabled.")
|
|
222
|
+
NAME = ("name", "Full Reddit thing identifier with 't1_' prefix (e.g. 't1_c6z2pxa').")
|
|
223
|
+
NO_FOLLOW = ("no_follow", "Whether links in this comment have HTML rel='nofollow' attached.")
|
|
224
|
+
PARENT_ID = ("parent_id", "Immediate parent ID ('t3_' for submission/top-level, 't1_' for comment).")
|
|
225
|
+
PERMALINK = ("permalink", "Relative URL path to the comment on reddit.com.")
|
|
226
|
+
POST_ID = ("post_id", "Base36 ID of the parent post without 't3_' prefix.")
|
|
227
|
+
QUARANTINE = ("quarantine", "Whether the subreddit containing this comment is quarantined.")
|
|
228
|
+
REMOVAL_REASON = ("removal_reason", "Internal removal note or reason identifier if removed by moderators.")
|
|
229
|
+
RETRIEVED_ON = ("retrieved_on", "Unix timestamp when Arctic Shift/Pushshift archived this record.")
|
|
230
|
+
SAVED = ("saved", "Whether comment is saved to viewer Reddit account bookmarks.")
|
|
231
|
+
SCORE = ("score", "Net score of the comment (upvotes minus downvotes).")
|
|
232
|
+
SCORE_HIDDEN = ("score_hidden", "Whether comment score is temporarily hidden by subreddit rule.")
|
|
233
|
+
SEND_REPLIES = ("send_replies", "Whether author opted to receive inbox notifications for replies.")
|
|
234
|
+
STICKIED = ("stickied", "Whether comment is stickied / pinned to top of comment section.")
|
|
235
|
+
SUBREDDIT = ("subreddit", "Name of the subreddit without prefix (e.g. 'resumes').")
|
|
236
|
+
SUBREDDIT_ID = ("subreddit_id", "Full subreddit ID with 't5_' prefix (e.g. 't5_2qr79').")
|
|
237
|
+
SUBREDDIT_NAME_PREFIXED = ("subreddit_name_prefixed", "Subreddit name prefixed with 'r/' (e.g. 'r/resumes').")
|
|
238
|
+
SUBREDDIT_TYPE = ("subreddit_type", "Visibility status of subreddit ('public', 'restricted', 'private').")
|
|
239
|
+
TOP_AWARDED_TYPE = ("top_awarded_type", "Type or tier of top award if heavily awarded.")
|
|
240
|
+
TOTAL_AWARDS_RECEIVED = ("total_awards_received", "Aggregate count of all awards received on this comment.")
|
|
241
|
+
TREATMENT_TAGS = ("treatment_tags", "Special UI treatment tags applied by Reddit.")
|
|
242
|
+
UNREPLIABLE_REASON = ("unrepliable_reason", "Reason why replies cannot be posted (e.g. blocked user, locked thread).")
|
|
243
|
+
UPS = ("ups", "Upvotes count (matches score in modern Reddit API).")
|
deepsift/models/post.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Post data model for Reddit posts.
|
|
3
|
+
"""
|
|
4
|
+
from typing import Dict, Any
|
|
5
|
+
from deepsift.models.enums import PostField
|
|
6
|
+
from deepsift.models.base import RedditEntity
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Post(RedditEntity):
|
|
10
|
+
"""
|
|
11
|
+
Representation of an Arctic Shift Reddit post.
|
|
12
|
+
Dynamically supports all 105 PostField enumerations.
|
|
13
|
+
"""
|
|
14
|
+
_field_enum = PostField
|
|
15
|
+
REQUIRED_FIELDS = frozenset({"id", "created_utc", "subreddit"})
|
|
16
|
+
|
|
17
|
+
def __init__(self, data: Dict[str, Any]):
|
|
18
|
+
super().__init__(data)
|
|
19
|
+
if "id" in self._data and isinstance(self._data["id"], str):
|
|
20
|
+
self._data["id"] = self._data["id"].replace("t3_", "")
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_api_dict(cls, data: Dict[str, Any]) -> "Post":
|
|
24
|
+
return cls(data)
|
|
25
|
+
|
|
26
|
+
def __repr__(self) -> str:
|
|
27
|
+
post_id = self._data.get("id", "")
|
|
28
|
+
title = self._data.get("title", "")
|
|
29
|
+
return f"<Post id={post_id!r} title={title[:30]!r}>" if title else f"<Post id={post_id!r}>"
|