From af6695e27f7b2a02ea3440d547d608417029ed5a Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 4 Dec 2025 09:26:32 -0600 Subject: [PATCH] adapter_literotica: Fix for one-shot aver_rating #1285 --- fanficfare/adapters/adapter_literotica.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fanficfare/adapters/adapter_literotica.py b/fanficfare/adapters/adapter_literotica.py index 4a0fefc9..90fd16bf 100644 --- a/fanficfare/adapters/adapter_literotica.py +++ b/fanficfare/adapters/adapter_literotica.py @@ -276,6 +276,12 @@ class LiteroticaSiteAdapter(BaseSiteAdapter): self.story.setMetadata('datePublished', dateval) self.story.setMetadata('dateUpdated', dateval) + ## one-shots don't have same json data to get aver_rating + ## from below. This kludge matches the data_approve + rateall = re.search(r'rate_all:([\d\.]+)',data) + if rateall: + self.story.setMetadata('averrating', '%4.2f' % float(rateall.group(1))) + ## one-shots assumed completed. self.story.setMetadata('status','Completed') @@ -345,11 +351,7 @@ class LiteroticaSiteAdapter(BaseSiteAdapter): json_state = json.loads(state) # logger.debug(json.dumps(json_state, sort_keys=True,indent=2, separators=(',', ':'))) all_rates = [] - ## one-shot - if 'story' in json_state: - all_rates = [ float(json_state['story']['data']['rate_all']) ] - ## series - elif 'series' in json_state: + if 'series' in json_state: all_rates = [ float(x['rate_all']) for x in json_state['series']['works'] ] ## Extract dates from chapter approval dates if dates_from_chapters is enabled