Skip to content

Commit

Permalink
new: text helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
uburuntu committed Sep 7, 2020
1 parent 153ee7b commit 658af11
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api2ch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Async API Wrapper for 2ch Imageboard with typings"""

from .api import Api2ch, Api2chAsync, Api2chBase, Api2chError
from .config import API_BASE, api_mirrors, downloads_dir
from .config import API_BASE, BOARDS, api_mirrors, downloads_dir
from .helpers import download_thread_media
from .models.auxiliary import NewsAbuItem, Tag, TopItem
from .models.base import Base, Request, Response
Expand All @@ -13,10 +13,10 @@
from .models.response import ResponseBoards, ResponseBoardsByTypes, ResponseCatalog, ResponseCatalogByDate, ResponsePage, \
ResponseSinglePost, ResponseThread, ResponseThreadPostsByNum, ResponseThreadPostsByPost, ResponseThreads
from .models.thread import Thread, ThreadWithStats
from .utils import parse_url
from .utils import clear_html, convert_html, parse_url

__author__ = 'uburuntu'
__email__ = 'github@rmbk.me'

__license__ = 'MIT'
__version__ = '1.1.0'
__version__ = '1.1.1'
15 changes: 15 additions & 0 deletions api2ch/models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
from api2ch.config import API_BASE
from api2ch.models.base import Base
from api2ch.models.file import File, Image, Sticker, Video
from api2ch.utils import clear_html, convert_html


class Post(Base):
subject: str

@property
def header(self):
return clear_html(self.subject)

comment: str

@property
def body(self):
return convert_html(self.comment)

@property
def body_text(self):
return clear_html(self.comment)

files: List[Union[Image, Video, Sticker, File]]
timestamp: int
date: str
Expand Down
15 changes: 15 additions & 0 deletions api2ch/models/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from api2ch.config import API_BASE
from api2ch.models.base import Base
from api2ch.models.post import Post
from api2ch.utils import clear_html, convert_html


class Thread(Base):
Expand All @@ -12,7 +13,21 @@ class Thread(Base):

class ThreadWithStats(Thread):
subject: str

@property
def header(self):
return clear_html(self.subject)

comment: str

@property
def body(self):
return convert_html(self.comment)

@property
def body_text(self):
return clear_html(self.comment)

num: int

@property
Expand Down

0 comments on commit 658af11

Please sign in to comment.