Skip to content

Commit

Permalink
fix: unable to distinguish thread/post from Postlog
Browse files Browse the repository at this point in the history
  • Loading branch information
lumina37 committed Mar 31, 2024
1 parent 3aea83c commit 86af9f8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions aiotieba/api/get_bawu_postlogs/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bs4

from ...exception import TbErrorExt
from ...helper import default_datetime
from ...helper import default_datetime, removeprefix
from .._classdef import Containers


Expand Down Expand Up @@ -96,11 +96,18 @@ def from_tbdata(data_tag: bs4.element.Tag) -> "Postlog":
url: str = title_item['href']
tid = int(url[3 : url.find('?')])
pid = int(url[url.rfind('#') + 1 :])
pid = pid if pid != tid else 0
title = title_item.string
title: str = title_item['title']

text_item = post_content_item.div
text = text_item.string[12:]

if pid == tid or not title.startswith('回复:'):
# is thread
pid = 0
text = f"{title}\n{text}"
else:
title = removeprefix(title, '回复:')

medias = [Media_postlog(tag) for tag in text_item.next_sibling('a', class_=None)]

op_type_item = left_cell_item.next_sibling
Expand Down

0 comments on commit 86af9f8

Please sign in to comment.