Posts Reference
Posts
- class pykemo.posts.posts.Post(*, id, creator_id, service, title, content, substring, embed, shared_file, added=None, published, edited=None, file=None, attachments=<factory>, creator, is_revision=False, prev_id=None, next_id=None)
Post with content.
- Parameters:
id (
PostID) – The ID of the post.creator_id (
str) – The creator’s ID that owns the post content (not the user that uploaded it).service (
ServiceLike) – The services that provides the content.title (
str) – The title of the post.content (
str) – The content string of the post.substring (
str) – The sub-string for the post description.embed (
dict) – A dictionary denoting the embed.shared_file (
bool) – Wether the post has a shared file.added (Optional[
datetime.datetime]) – When was the post added.published (
datetime.datetime) – When was the post published.edited (Optional[
datetime.datetime]) – When was the post last edited.file (Optional[
File]) – The file that the posts uses when previewed.attachments (list[
File]) – All the files under this post.creator (
Creator) – The creator of this post.is_revision (
bool) – Flag to see if this post is a revision of another.prev_id (Optional[
PostID]) – If available, the ID of the “previous” post.next_id (Optional[
PostID]) – If available, the ID of the “next” post.
- before(date)
Verifies if the post was published before a certain date.
- Returns:
The result of
Post.published < date- Return type:
bool- Parameters:
date (datetime)
- async fetch_comments()
Fetches the comments of the post.
Warning
This is designed for internal purposes, as it is recommended to use the
comments()property instead. However, it can also be used as-is to prevent using a potentially outdated field.- Returns:
A list of the comments of this post. Might be empty if there is n osession available.
- Return type:
list[
Comment]
- async flagged()
- Returns:
Wether the post is flagged for reimport.
- Return type:
bool
- async next_post()
Tries to load the next post by its ID.
- Returns:
The post, already loaded; or
Noneif it wasn’t found.- Return type:
Optional[
Post]
- async prev_post()
Tries to load the previous post by its ID.
- Returns:
The post, already loaded; or
Noneif it wasn’t found.- Return type:
Optional[
Post]
- async revisions()
- Returns:
All the revisions of this post.
- Return type:
list[
PostRevision]
- sanitized_title()
Converts the title of the post into one apt for a system filename.
- Returns:
A new path, already sanitized.
- Return type:
PathLike
- async save(path=None, *, force=True, verbose=True, pos=0, verbose_children=None)
Tries to save all the files in the post. Even if one file fails, it still tries to download the rest.
- Parameters:
path (
PathLike|Path|None) – The optional path where to store all the files. If it ends with'/*', it will use its default name inside such folder.force (
bool, optional) – Wether to overwrite existing files, defaults toTrueverbose (
bool, optional) – Wether to track progress, defaults toTruepos (
int, optional) – The position order of the progress bar, defaults to 0verbose_children (
bool, optional) – Wether to track progress for files, defaults to value ofverbose
- Returns:
Trueif the download of all files was successful, orFalseif not.- Return type:
bool
- set_underlying_session(ks)
Quietly sets the session which the post uses for its requests.
- Parameters:
session (
KemoSession) – The session instance.ks (KemoSession)
- Returns:
The same instance of the post, for convenience.
- Return type:
- since(date)
Verifies if the post was published since a certain date.
- Returns:
The result of
Post.published >= date- Return type:
bool- Parameters:
date (datetime)
- property url: UrlLike
- Returns:
The full URL of the post.
- Return type:
UrlLike
- class pykemo.posts.post_revisions.PostRevision(*, revision_id, post)
A post revision is an edit made to a post, at any given time.
- Parameters:
revision_id (
str) – The ID of the revision itself.post (
Post) – The underlying post of the revision. This is a post in itself, a copy of how the post was at that time.
Comments
Comment of a post. Usually instantiated through
Post.comments()id (
str) – The ID of the comment itself.parent_id (Optional[
str]) – The ID of the parent comment. Used when the comment itself is a response to another.commenter_id (
str) – The ID of the author of the comment.commenter_name (
str) – The name of the author of the commentcontent (
str) – The actual content of the comment.published (
datetime.datetime) – When was the comment created.revisions (list[
CommentRevision]) – Subsequent edits of the comment.commenter (
Creator) – The creator of this comment.post (
Post) – The parent post this comment belongs to.The direct URL of the comment.
UrlLikeA comment revision. A revision is an edit that can be applied to any given comment by its author, provided that they wanted to changes its contents at some point.
id (
int) – The ID of the revision. Usually an integer indicating the number of the revision.content (
str) – The modified contents of the message.added (
datetime.datetime) – When was this revision applied.