예제 #1
0
파일: my716.py 프로젝트: sffxzzp/novelpush
	def downChap(self, i):
		cinfo = self.chapters[i]
		print('\t%s' % cinfo['title'].encode('gbk', 'ignore').decode('gbk'))
		ccont = json.loads(weblib().get(cinfo['url']), True)
		if ccont['ok'] == True:
			content = '  %s' % ccont['chapter']['body'].replace('\n', '<br />  ')
		else:
			content = ''
		fn = '%d.html' % (i+1)
		filelib().write('%s/%s' % (self.path, fn), self.filecont % {'title': cinfo['title'], 'content': content}, encoding='utf-8')
예제 #2
0
	def checkStart(self):
		self.path = 'books/%s/%s' % (self.name, self.sresult[self.selection]['id'])
		if not filelib().exists(self.path):
			filelib().mkdir(self.path)
		count = 0
		for filename in os.listdir(self.path):
			if filename.endswith('html') and filename != 'titlepage.html':
				count += 1
			elif filename == 'cover.jpg':
				self.hasCover = True
		return count
예제 #3
0
	def loadcfg(self, path):
		cfgfile = filelib().json(path)
		try:
			self.enabled = cfgfile['enabled']
		except:
			self.enabled = False
		if self.enabled:
			try:
				self.debug = cfgfile['debug']
				self.url = cfgfile['url']
				self.baseurl = findstr('(http[s]?://.*?)/', self.url)[0]
				self.idrule = cfgfile['idrule']
				self.searchurl = cfgfile['searchurl']
				self.sidrule = cfgfile['sidrule']
				self.stitlerule = cfgfile['stitlerule']
				self.surlrule = cfgfile['surlrule']
				self.sauthorrule = cfgfile['sauthorrule']
				self.coverrule = cfgfile['coverrule']
				self.timerule = cfgfile['timerule']
				self.lastrule = cfgfile['lastrule']
				self.desrule = cfgfile['desrule']
				self.listleft = cfgfile['listleft']
				self.listright = cfgfile['listright']
				self.listrule = cfgfile['listrule']
				self.chaprule = cfgfile['chaprule']
				self.chapclean = cfgfile['chapclean']
				self.chapcleanre = cfgfile['chapcleanre']
				self.output = cfgfile['output']
			except:
				pass
예제 #4
0
	def downChap(self, i):
		cinfo = self.chapters[i]
		print('\t%s' % cinfo['title'].encode('gbk', 'ignore').decode('gbk'))
		ccont = weblib().get(cinfo['url'], chardet=True)
		content = findstr(self.chaprule, ccont)[0]
		for item in self.chapclean:
			content = content.replace(item, '')
		for item in self.chapcleanre:
			content = re.sub(item, '', content)
		content = re.sub('<br.*?>', '<br />  ', content)
		cinfo['content'] = '  %s' % content
		fn = '%d.html' % (i+1)
		book = self.sresult[self.selection]
		chapdata = self.output
		chapdata = chapdata.replace('\\n', '\n').replace('{title}', cinfo['title']).replace('{author}', book['author']).replace('{url}', cinfo['url']).replace('{content}', cinfo['content'])
		filelib().write('%s/%s' % (self.path, fn), chapdata, encoding='utf-8')
예제 #5
0
파일: gebiqu.py 프로젝트: sffxzzp/novelpush
 def downChap(self, i):
     cinfo = self.chapters[i]
     print('\t%s' % cinfo['title'].encode('gbk', 'ignore').decode('gbk'))
     ccont = weblib().get(cinfo['url'], chardet=True)
     try:
         content = findstr('<div id="content">([\s\S]*?)</div>',
                           ccont)[0].replace('&nbsp;', '').replace(
                               '  ', '').replace('www.gebiqu.com', '')
         content = re.sub('<br ?/?><br ?/?>', '<br />  ', content)
     except:
         content = ''
     fn = '%d.html' % (i + 1)
     filelib().write('%s/%s' % (self.path, fn),
                     self.filecont % {
                         'title': cinfo['title'],
                         'content': content
                     },
                     encoding='utf-8')
예제 #6
0
	def makeBook(self):
		# check epubpath if book already created.
		self.epubpath = '%s/%s.epub' % ('output', self.binfo['title'])
		if not filelib().exists(self.epubpath):
			print(lang['makeEpub'])
			# copy needed files to target folder.
			filelib().copy(self.cssfile, self.path)
			filelib().copy(self.coverfile, self.path)
			# create epub file.
			book = epublib(self.path)
			book.setMeta({
				'title': self.binfo['title'],
				'author': self.binfo['author'],
				'des': self.binfo['des']
			})
			for i in range(0, self.count):
				book.addChap(i+1, self.chapters[i]['title'])
			book.makeEpub()
			print(lang['makeEpubComplete'])
		else:
			print(lang['epubAlreadyExists'])
예제 #7
0
	def getConfig(self):
		cfgfile = filelib().json(self.settings)
		if not cfgfile:
			self.initConfig()
		else:
			if 'Last' in cfgfile:
				if 'Plugin' in cfgfile['Last']:
					self.lastPlugin = cfgfile['Last']['Plugin']
				if 'Search' in cfgfile['Last']:
					self.lastSearch = cfgfile['Last']['Search']
				if 'Select' in cfgfile['Last']:
					self.lastSelect = cfgfile['Last']['Select']
			if 'SMTP' in cfgfile:
				valid = True
				for name in ['Server', 'SSL', 'Port', 'Username', 'Password', 'FromEmail', 'ToEmail']:
					if name not in cfgfile['SMTP']:
						valid = False
				if valid:
					self.smtp = cfgfile['SMTP']
				else:
					self.initConfig()
			else:
				self.initConfig()
예제 #8
0
	def writeConfig(self, cfgfile):
		filelib().write(self.settings, json.dumps(cfgfile, ensure_ascii=False), encoding='utf-8')