fix brief parsing

This commit is contained in:
Your Name 2023-06-05 13:30:40 -04:00 committed by Henri Dickson
parent db96a267fc
commit aa4b862d71
2 changed files with 8 additions and 4 deletions

View file

@ -73,7 +73,7 @@ class DoubanDramaTestCase(TestCase):
self.assertEqual(item.performer, ["安蘭けい", "柚希礼音", "遠野あすか", "霧矢大夢", "龍真咲"])
self.assertEqual(len(resource.related_resources), 4)
crawl_related_resources_task(resource.id) # force the async job to run now
productions = list(item.productions.all())
productions = list(item.productions.all().order_by("title"))
self.assertEqual(len(productions), 4)
self.assertEqual(productions[0].opening_date, "2008-06-20")
self.assertEqual(productions[0].closing_date, "2008-08-04")

View file

@ -133,10 +133,14 @@ class DoubanDrama(AbstractSite):
)
data["other_title"] = other_title_elem
plot_elem = h.xpath("//div[@id='link-report']/text()")
plot_elem = h.xpath("//div[@class='pure-text']/div[@class='full']/text()")
if len(plot_elem) == 0:
plot_elem = h.xpath("//div[@class='abstract']/text()")
data["brief"] = "\n".join(plot_elem) if len(plot_elem) > 0 else ""
plot_elem = h.xpath(
"//div[@class='pure-text']/div[@class='abstract']/text()"
)
if len(plot_elem) == 0:
plot_elem = h.xpath("//div[@class='pure-text']/text()")
data["brief"] = "\n".join(plot_elem)
data["genre"] = [
s.strip()