mirror of
https://github.com/evilhero/mylar
synced 2025-02-21 13:36:52 +00:00
Unicode Fix for OPDS
This commit is contained in:
parent
a0ebd3ad7e
commit
745b515b6f
1 changed files with 16 additions and 8 deletions
|
@ -96,6 +96,13 @@ class OPDS(object):
|
|||
cherrypy.response.headers['Content-Type'] = "text/xml"
|
||||
return error
|
||||
|
||||
def _uni(self, instr):
|
||||
outstr = ""
|
||||
try:
|
||||
outstr = unicode(instr, "ascii")
|
||||
except UnicodeError:
|
||||
outstr = unicode(instr, "utf-8")
|
||||
return outstr
|
||||
|
||||
def _dic_from_query(self, query):
|
||||
myDB = db.DBConnection()
|
||||
|
@ -381,7 +388,7 @@ class OPDS(object):
|
|||
'id': escape('comic:%s - %s' % (issue['ComicName'], issue['Issue_Number'])),
|
||||
'updated': updated,
|
||||
'content': escape('%s' % (metainfo[0]['summary'])),
|
||||
'href': '%s?cmd=Issue&issueid=%s&file=%s' % (self.opdsroot, quote_plus(issue['IssueID']),quote_plus(issue['Location'])),
|
||||
'href': '%s?cmd=Issue&issueid=%s&file=%s' % (self.opdsroot, quote_plus(issue['IssueID']),quote_plus(self._uni(issue['Location']))),
|
||||
'kind': 'acquisition',
|
||||
'rel': 'file',
|
||||
'author': metainfo[0]['writer'],
|
||||
|
@ -435,7 +442,8 @@ class OPDS(object):
|
|||
thumbnail = issuebook['ImageURL']
|
||||
else:
|
||||
title = escape('%03d: %s Annual %s - %s' % (index + number, issuebook['ComicName'], issuebook['Issue_Number'], issuebook['IssueName']))
|
||||
logger.info("%s - %s" % (comic['ComicLocation'], issuebook['Location']))
|
||||
# logger.info("%s - %s" % (comic['ComicLocation'], issuebook['Location']))
|
||||
location = self._uni(issuebook['Location'])
|
||||
number +=1
|
||||
if not issuebook['Location']:
|
||||
continue
|
||||
|
@ -451,7 +459,7 @@ class OPDS(object):
|
|||
'id': escape('comic:%s - %s' % (issuebook['ComicName'], issuebook['Issue_Number'])),
|
||||
'updated': updated,
|
||||
'content': escape('%s' % (metainfo[0]['summary'])),
|
||||
'href': '%s?cmd=Issue&issueid=%s&file=%s' % (self.opdsroot, quote_plus(issuebook['IssueID']),quote_plus(issuebook['Location'])),
|
||||
'href': '%s?cmd=Issue&issueid=%s&file=%s' % (self.opdsroot, quote_plus(issuebook['IssueID']),quote_plus(location)),
|
||||
'kind': 'acquisition',
|
||||
'rel': 'file',
|
||||
'author': metainfo[0]['writer'],
|
||||
|
@ -572,7 +580,7 @@ class OPDS(object):
|
|||
if bookentry['Location']:
|
||||
fileexists = True
|
||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], bookentry['Location'])
|
||||
issue['filename'] = bookentry['Location']
|
||||
issue['filename'] = self._uni(bookentry['Location'])
|
||||
issue['image'] = bookentry['ImageURL_ALT']
|
||||
issue['thumbnail'] = bookentry['ImageURL']
|
||||
if bookentry['DateAdded']:
|
||||
|
@ -585,7 +593,7 @@ class OPDS(object):
|
|||
if annualentry['Location']:
|
||||
fileexists = True
|
||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
||||
issue['filename'] = annualentry['Location']
|
||||
issue['filename'] = self._uni(annualentry['Location'])
|
||||
issue['image'] = None
|
||||
issue['thumbnail'] = None
|
||||
issue['updated'] = annualentry['IssueDate']
|
||||
|
@ -663,7 +671,7 @@ class OPDS(object):
|
|||
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( bookentry['ComicID'],)).fetchone()
|
||||
fileexists = True
|
||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], bookentry['Location'])
|
||||
issue['filename'] = bookentry['Location']
|
||||
issue['filename'] = self._uni(bookentry['Location'])
|
||||
issue['image'] = bookentry['ImageURL_ALT']
|
||||
issue['thumbnail'] = bookentry['ImageURL']
|
||||
if bookentry['DateAdded']:
|
||||
|
@ -677,7 +685,7 @@ class OPDS(object):
|
|||
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( annualentry['ComicID'],))
|
||||
fileexists = True
|
||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
||||
issue['filename'] = annualentry['Location']
|
||||
issue['filename'] = self._uni(annualentry['Location'])
|
||||
issue['image'] = None
|
||||
issue['thumbnail'] = None
|
||||
issue['updated'] = annualentry['IssueDate']
|
||||
|
@ -685,7 +693,7 @@ class OPDS(object):
|
|||
if book['Location']:
|
||||
fileexists = True
|
||||
issue['fileloc'] = book['Location']
|
||||
issue['filename'] = os.path.split(book['Location'])[1]
|
||||
issue['filename'] = self._uni(os.path.split(book['Location'])[1])
|
||||
issue['image'] = None
|
||||
issue['thumbnail'] = None
|
||||
issue['updated'] = book['IssueDate']
|
||||
|
|
Loading…
Reference in a new issue