adapter_literotica: Fix for one-shot aver_rating #1285

This commit is contained in:
Jim Miller 2025-12-04 09:26:32 -06:00
parent 46293f2d02
commit af6695e27f

View file

@ -276,6 +276,12 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
self.story.setMetadata('datePublished', dateval) self.story.setMetadata('datePublished', dateval)
self.story.setMetadata('dateUpdated', 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. ## one-shots assumed completed.
self.story.setMetadata('status','Completed') self.story.setMetadata('status','Completed')
@ -345,11 +351,7 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
json_state = json.loads(state) json_state = json.loads(state)
# logger.debug(json.dumps(json_state, sort_keys=True,indent=2, separators=(',', ':'))) # logger.debug(json.dumps(json_state, sort_keys=True,indent=2, separators=(',', ':')))
all_rates = [] all_rates = []
## one-shot if 'series' in json_state:
if 'story' in json_state:
all_rates = [ float(json_state['story']['data']['rate_all']) ]
## series
elif 'series' in json_state:
all_rates = [ float(x['rate_all']) for x in json_state['series']['works'] ] 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 ## Extract dates from chapter approval dates if dates_from_chapters is enabled