From 83bceb8154750fb60bc5dc0f378c4f25dfcfdb32 Mon Sep 17 00:00:00 2001 From: Dminti Snegirev Date: Wed, 11 Apr 2018 22:01:37 +0300 Subject: [PATCH] Fix www.webnovel.com adapter with volumes (#293) --- fanficfare/adapters/adapter_webnovelcom.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fanficfare/adapters/adapter_webnovelcom.py b/fanficfare/adapters/adapter_webnovelcom.py index 3bcd7c4d..ac9774ac 100644 --- a/fanficfare/adapters/adapter_webnovelcom.py +++ b/fanficfare/adapters/adapter_webnovelcom.py @@ -192,14 +192,15 @@ class WWWWebNovelComAdapter(BaseSiteAdapter): jsondata = json.loads(self._fetchUrl( "https://" + self.getSiteDomain() + "/apiajax/chapter/GetChapterList?_csrfToken=" + csrf_token + "&bookId=" + self.story.getMetadata( 'storyId'))) - for chap in jsondata["data"]["chapterItems"]: - # Only allow free and VIP type 1 chapters - if chap['isVip'] not in {0, 1}: - continue + for volume in jsondata["data"]["volumeItems"]: + for chap in volume["chapterItems"]: + # Only allow free and VIP type 1 chapters + if chap['isVip'] not in {0, 1}: + continue - chap_title = 'Chapter ' + unicode(chap['chapterIndex']) + ' - ' + chap['chapterName'] - chap_Url = url.rstrip('/') + '/' + chap['chapterId'] - self.chapterUrls.append((chap_title, chap_Url)) + chap_title = 'Chapter ' + unicode(chap['index']) + ' - ' + chap['name'] + chap_Url = url.rstrip('/') + '/' + chap['id'] + self.chapterUrls.append((chap_title, chap_Url)) self.story.setMetadata('numChapters', len(self.chapterUrls))