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:
retiefjimm
2010-10-03 19:23:39 -05:00
parent f75910ce7d
commit ca4b09d69d
3 changed files with 10 additions and 5 deletions
+4 -1
View File
@@ -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')
+3 -2
View File
@@ -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):
+3 -2
View File
@@ -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