mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-08 12:36:11 +02:00
fallback for broken lastlogin data
about 20% of the time the data-time attibute is simply absent. I haven't figured out a pattern as to why (it seems to come and go for any given story), but the date is still present in the title so it can be parsed out in that case.
This commit is contained in:
parent
8912f4ee18
commit
15ac85a7fb
1 changed files with 8 additions and 1 deletions
|
|
@ -314,7 +314,14 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter):
|
|||
span = listItems[1].find('span',{'data-time':re.compile(r'^\d+$')})
|
||||
## <span data-time="1435421997" title="Saturday 27th of June 2015 @4:19pm">Jun 27th, 2015</span>
|
||||
## No timezone adjustment is done.
|
||||
lastLogin = datetime.fromtimestamp(float(span['data-time']))
|
||||
if span != None:
|
||||
lastLogin = datetime.fromtimestamp(float(span['data-time']))
|
||||
## Sometimes, for reasons that are unclear, data-time is not present. Parse the date out of the title instead.
|
||||
else:
|
||||
span = listItems[1].find('span', title=True)
|
||||
loginRegex = re.search('([a-zA-Z ]+)([0-9]+)(th of|nd of|rd of)([a-zA-Z ]+[0-9]+)', span['title'])
|
||||
loginString = loginRegex.group(2) + loginRegex.group(4)
|
||||
lastLogin = datetime.strptime(loginString, "%d %B %Y")
|
||||
self.story.setMetadata("authorLastLogin", lastLogin)
|
||||
|
||||
def ordinal_date_string_to_date(self, datestring):
|
||||
|
|
|
|||
Loading…
Reference in a new issue