mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 08:52:55 +01:00
Brought fimfiction.net published date parsing into line with new site layout
This commit is contained in:
parent
a3402170ad
commit
2cd89b2e55
1 changed files with 9 additions and 4 deletions
|
|
@ -94,7 +94,11 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter):
|
||||||
self.story.setMetadata("authorId", author) # The author's name will be unique
|
self.story.setMetadata("authorId", author) # The author's name will be unique
|
||||||
self.story.setMetadata("authorUrl", "http://%s/user/%s" % (self.getSiteDomain(),author))
|
self.story.setMetadata("authorUrl", "http://%s/user/%s" % (self.getSiteDomain(),author))
|
||||||
|
|
||||||
self.chapterUrls = [(chapter.text, "http://"+self.getSiteDomain() + chapter['href']) for chapter in soup.findAll("a", {"class":"chapter_link"})]
|
chapterDates = []
|
||||||
|
|
||||||
|
for chapter in soup.findAll("a", {"class":"chapter_link"}):
|
||||||
|
chapterDates.append(chapter.span.extract().text.strip("()"))
|
||||||
|
self.chapterUrls.append((chapter.text.strip(), "http://"+self.getSiteDomain() + chapter['href']))
|
||||||
|
|
||||||
self.story.setMetadata('numChapters',len(self.chapterUrls))
|
self.story.setMetadata('numChapters',len(self.chapterUrls))
|
||||||
|
|
||||||
|
|
@ -138,9 +142,10 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter):
|
||||||
# than miss an update, we hardcode the year of creation and update to be 2011.
|
# than miss an update, we hardcode the year of creation and update to be 2011.
|
||||||
|
|
||||||
# Get the date of creation from the first chapter
|
# Get the date of creation from the first chapter
|
||||||
datePublished_soup = bs.BeautifulSoup(self._fetchUrl(self.chapterUrls[0][1])).find("div", {"class":"calendar"})
|
datePublished_text = chapterDates[0]
|
||||||
datePublished_soup.find('span').extract()
|
day, month = datePublished_text.split()
|
||||||
datePublished = makeDate("2011"+datePublished_soup.text, "%Y%b%d")
|
day = re.sub(r"[^\d.]+", '', day)
|
||||||
|
datePublished = makeDate("2011"+month+day, "%Y%b%d")
|
||||||
self.story.setMetadata("datePublished", datePublished)
|
self.story.setMetadata("datePublished", datePublished)
|
||||||
dateUpdated_soup = bs.BeautifulSoup(data).find("div", {"class":"calendar"})
|
dateUpdated_soup = bs.BeautifulSoup(data).find("div", {"class":"calendar"})
|
||||||
dateUpdated_soup.find('span').extract()
|
dateUpdated_soup.find('span').extract()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue