mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-10 11:40:24 +08:00
Fixes for some obscure encoding errors. UTF8 versions of apostrophe and dash in story titles & chapter titles could cause problems in a few places.
This commit is contained in:
@@ -98,7 +98,10 @@ class FFNet(FanfictionSiteAdapter):
|
||||
elif l.find("<SELECT title='chapter navigation'") != -1:
|
||||
if len(urls) > 0:
|
||||
continue
|
||||
u = l.decode('utf-8')
|
||||
try:
|
||||
u = l.decode('utf-8')
|
||||
except UnicodeEncodeError, e:
|
||||
u = l
|
||||
u = re.sub('&\#[0-9]+;', ' ', u)
|
||||
s2 = bs.BeautifulSoup(u)
|
||||
options = s2.findAll('option')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -9,6 +11,7 @@ import urllib2 as u2
|
||||
import urlparse as up
|
||||
import BeautifulSoup as bs
|
||||
import htmlentitydefs as hdefs
|
||||
import logging
|
||||
|
||||
from adapter import *
|
||||
|
||||
@@ -62,8 +65,6 @@ class FicWad(FanfictionSiteAdapter):
|
||||
if title != "Story Index":
|
||||
result.append((url,title))
|
||||
|
||||
print('Story "%s" by %s' % (self.storyName, self.authorName))
|
||||
|
||||
return result
|
||||
|
||||
def getStoryName(self):
|
||||
|
||||
@@ -61,7 +61,7 @@ class HTMLWriter(FanficWriter):
|
||||
self.basePath = base
|
||||
self.name = re.sub('&\#[0-9]+;', '_', name.replace(" ", "_").replace(":","_"))
|
||||
self.storyTitle = name
|
||||
self.fileName = self.basePath + '/' + self.name + '.html'
|
||||
self.fileName = self.basePath + '/' + re.sub('[^a-zA-Z0-9_\'-]+','',self.name) + '.html'
|
||||
self.authorName = author
|
||||
|
||||
self.inmemory = inmemory
|
||||
@@ -135,7 +135,8 @@ class EPubFanficWriter(FanficWriter):
|
||||
self.basePath = base
|
||||
self.name = re.sub('&\#[0-9]+;', '_', name.replace(" ", "_").replace(":","_"))
|
||||
self.storyTitle = name
|
||||
self.directory = self.basePath + '/' + self.name
|
||||
self.directory = self.basePath + '/' + re.sub('[^a-zA-Z0-9_\'-]+','',self.name)
|
||||
|
||||
self.inmemory = inmemory
|
||||
self.authorName = author
|
||||
|
||||
|
||||
Reference in New Issue
Block a user