1
0

Fixed OP's post property. Handled situation when comment and/or subject doesn't exists.

This commit is contained in:
Alexander Andreev 2020-07-18 04:42:19 +04:00
parent 0ed1e896ca
commit 3223c0721a
3 changed files with 22 additions and 6 deletions

View File

@ -24,8 +24,13 @@ class DvachParser(Parser):
return "2ch.hk"
@property
def op(self) -> str:
return f"{self._op_post['subject']}\n{self._op_post['comment']}"
def op(self) -> Optional[str]:
op = ""
if 'sub' in self._op_post:
op = f"{self._op_post['subject']}\n"
if 'com' in self._op_post:
op += self._op_post['comment']
return op if not op == "" else None
def _parse_post(self, post) -> Optional[List[FileInfo]]:
if not 'files' in post: return None

View File

@ -24,11 +24,13 @@ class FourChanParser(Parser):
return "4chan.org"
@property
def op(self) -> str:
def op(self) -> Optional[str]:
op = ""
if 'sub' in self._op_post:
return f"{self._op_post['sub']}\n{self._op_post['com']}"
else:
return self._op_post['com']
op = f"{self._op_post['sub']}\n"
if 'com' in self._op_post:
op += self._op_post['com']
return op if not op == "" else None
def _parse_post(self, post: dict) -> List[FileInfo]:
if not 'tim' in post: return None

View File

@ -26,6 +26,15 @@ class LainchanParser(Parser):
def imageboard(self) -> str:
return "lainchan.org"
@property
def op(self) -> Optional[str]:
op = ""
if 'sub' in self._op_post:
op = f"{self._op_post['sub']}\n"
if 'com' in self._op_post:
op += self._op_post['com']
return op if not op == "" else None
def _parse_post(self, post) -> List[FileInfo]:
if not 'tim' in post: return None