mirror of
https://github.com/evilhero/mylar
synced 2025-02-22 14:00:32 +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"
|
cherrypy.response.headers['Content-Type'] = "text/xml"
|
||||||
return error
|
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):
|
def _dic_from_query(self, query):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
@ -381,7 +388,7 @@ class OPDS(object):
|
||||||
'id': escape('comic:%s - %s' % (issue['ComicName'], issue['Issue_Number'])),
|
'id': escape('comic:%s - %s' % (issue['ComicName'], issue['Issue_Number'])),
|
||||||
'updated': updated,
|
'updated': updated,
|
||||||
'content': escape('%s' % (metainfo[0]['summary'])),
|
'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',
|
'kind': 'acquisition',
|
||||||
'rel': 'file',
|
'rel': 'file',
|
||||||
'author': metainfo[0]['writer'],
|
'author': metainfo[0]['writer'],
|
||||||
|
@ -435,7 +442,8 @@ class OPDS(object):
|
||||||
thumbnail = issuebook['ImageURL']
|
thumbnail = issuebook['ImageURL']
|
||||||
else:
|
else:
|
||||||
title = escape('%03d: %s Annual %s - %s' % (index + number, issuebook['ComicName'], issuebook['Issue_Number'], issuebook['IssueName']))
|
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
|
number +=1
|
||||||
if not issuebook['Location']:
|
if not issuebook['Location']:
|
||||||
continue
|
continue
|
||||||
|
@ -451,7 +459,7 @@ class OPDS(object):
|
||||||
'id': escape('comic:%s - %s' % (issuebook['ComicName'], issuebook['Issue_Number'])),
|
'id': escape('comic:%s - %s' % (issuebook['ComicName'], issuebook['Issue_Number'])),
|
||||||
'updated': updated,
|
'updated': updated,
|
||||||
'content': escape('%s' % (metainfo[0]['summary'])),
|
'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',
|
'kind': 'acquisition',
|
||||||
'rel': 'file',
|
'rel': 'file',
|
||||||
'author': metainfo[0]['writer'],
|
'author': metainfo[0]['writer'],
|
||||||
|
@ -572,7 +580,7 @@ class OPDS(object):
|
||||||
if bookentry['Location']:
|
if bookentry['Location']:
|
||||||
fileexists = True
|
fileexists = True
|
||||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], bookentry['Location'])
|
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['image'] = bookentry['ImageURL_ALT']
|
||||||
issue['thumbnail'] = bookentry['ImageURL']
|
issue['thumbnail'] = bookentry['ImageURL']
|
||||||
if bookentry['DateAdded']:
|
if bookentry['DateAdded']:
|
||||||
|
@ -585,7 +593,7 @@ class OPDS(object):
|
||||||
if annualentry['Location']:
|
if annualentry['Location']:
|
||||||
fileexists = True
|
fileexists = True
|
||||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
||||||
issue['filename'] = annualentry['Location']
|
issue['filename'] = self._uni(annualentry['Location'])
|
||||||
issue['image'] = None
|
issue['image'] = None
|
||||||
issue['thumbnail'] = None
|
issue['thumbnail'] = None
|
||||||
issue['updated'] = annualentry['IssueDate']
|
issue['updated'] = annualentry['IssueDate']
|
||||||
|
@ -663,7 +671,7 @@ class OPDS(object):
|
||||||
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( bookentry['ComicID'],)).fetchone()
|
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( bookentry['ComicID'],)).fetchone()
|
||||||
fileexists = True
|
fileexists = True
|
||||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], bookentry['Location'])
|
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['image'] = bookentry['ImageURL_ALT']
|
||||||
issue['thumbnail'] = bookentry['ImageURL']
|
issue['thumbnail'] = bookentry['ImageURL']
|
||||||
if bookentry['DateAdded']:
|
if bookentry['DateAdded']:
|
||||||
|
@ -677,7 +685,7 @@ class OPDS(object):
|
||||||
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( annualentry['ComicID'],))
|
comic = myDB.selectone("SELECT * from comics WHERE ComicID=?", ( annualentry['ComicID'],))
|
||||||
fileexists = True
|
fileexists = True
|
||||||
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
issue['fileloc'] = os.path.join(comic['ComicLocation'], annualentry['Location'])
|
||||||
issue['filename'] = annualentry['Location']
|
issue['filename'] = self._uni(annualentry['Location'])
|
||||||
issue['image'] = None
|
issue['image'] = None
|
||||||
issue['thumbnail'] = None
|
issue['thumbnail'] = None
|
||||||
issue['updated'] = annualentry['IssueDate']
|
issue['updated'] = annualentry['IssueDate']
|
||||||
|
@ -685,7 +693,7 @@ class OPDS(object):
|
||||||
if book['Location']:
|
if book['Location']:
|
||||||
fileexists = True
|
fileexists = True
|
||||||
issue['fileloc'] = book['Location']
|
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['image'] = None
|
||||||
issue['thumbnail'] = None
|
issue['thumbnail'] = None
|
||||||
issue['updated'] = book['IssueDate']
|
issue['updated'] = book['IssueDate']
|
||||||
|
|
Loading…
Reference in a new issue