mirror of https://github.com/evilhero/mylar
OPDS Story Arcs (part 1)
This commit is contained in:
parent
c612c56841
commit
b4d913807a
|
@ -31,7 +31,7 @@ from cherrypy.lib.static import serve_file, serve_download
|
||||||
import datetime
|
import datetime
|
||||||
from mylar.webserve import serve_template
|
from mylar.webserve import serve_template
|
||||||
|
|
||||||
cmd_list = ['root', 'Publishers', 'AllTitles', 'StoryArcs', 'ReadList', 'Comic', 'Publisher', 'Issue']
|
cmd_list = ['root', 'Publishers', 'AllTitles', 'StoryArcs', 'ReadList', 'Comic', 'Publisher', 'Issue', 'StoryArc']
|
||||||
|
|
||||||
class OPDS(object):
|
class OPDS(object):
|
||||||
|
|
||||||
|
@ -291,17 +291,21 @@ class OPDS(object):
|
||||||
if index <= len(issues):
|
if index <= len(issues):
|
||||||
subset = issues[index:(index+30)]
|
subset = issues[index:(index+30)]
|
||||||
for issue in subset:
|
for issue in subset:
|
||||||
if issue['DateAdded']:
|
if 'DateAdded' in issue and issue['DateAdded']:
|
||||||
updated = issue['DateAdded']
|
updated = issue['DateAdded']
|
||||||
else:
|
else:
|
||||||
updated = issue['ReleaseDate']
|
updated = issue['ReleaseDate']
|
||||||
|
if 'DateAdded' in issue:
|
||||||
|
title = escape('%s - %s' % (issue['Issue_Number'], issue['IssueName']))
|
||||||
|
else:
|
||||||
|
title = escape('Annual %s - %s' (issue['Issue_Number'], issue['IssueName']))
|
||||||
fileloc = os.path.join(comic['ComicLocation'],issue['Location'])
|
fileloc = os.path.join(comic['ComicLocation'],issue['Location'])
|
||||||
metainfo = mylar.helpers.IssueDetails(fileloc)
|
metainfo = mylar.helpers.IssueDetails(fileloc)
|
||||||
if not metainfo:
|
if not metainfo:
|
||||||
metainfo = [{'writer': 'Unknown','summary': ''}]
|
metainfo = [{'writer': 'Unknown','summary': ''}]
|
||||||
entries.append(
|
entries.append(
|
||||||
{
|
{
|
||||||
'title': escape('%s - %s' % (issue['Issue_Number'], issue['IssueName'])),
|
'title': title,
|
||||||
'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'])),
|
||||||
|
@ -350,6 +354,59 @@ class OPDS(object):
|
||||||
self.filename = issue['Location']
|
self.filename = issue['Location']
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _StoryArcs(self, **kwargs):
|
||||||
|
index = 0
|
||||||
|
if 'index' in kwargs:
|
||||||
|
index = int(kwargs['index'])
|
||||||
|
myDB = db.DBConnection()
|
||||||
|
links = []
|
||||||
|
entries=[]
|
||||||
|
arcs = []
|
||||||
|
storyArcs = mylar.helpers.listStoryArcs()
|
||||||
|
for arc in storyArcs:
|
||||||
|
issuecount = 0
|
||||||
|
arcname = ''
|
||||||
|
updated = '0000-00-00'
|
||||||
|
arclist = myDB.select("SELECT * from readinglist WHERE StoryArcID=?", (arc,))
|
||||||
|
for issue in arclist:
|
||||||
|
if issue['Status'] == 'Downloaded':
|
||||||
|
issuecount += 1
|
||||||
|
arcname = issue['StoryArc']
|
||||||
|
if issue['IssueDate'] > updated:
|
||||||
|
updated = issue['IssueDate']
|
||||||
|
if issuecount > 0:
|
||||||
|
arcs.append({'StoryArcName': arcname, 'StoryArcID': arc, 'IssueCount': issuecount})
|
||||||
|
subset = arcs[index:(index + 30)]
|
||||||
|
for arc in subset:
|
||||||
|
entries.append(
|
||||||
|
{
|
||||||
|
'title': '%s (%s)' % (arc['StoryArcName'],arc['IssueCount']),
|
||||||
|
'id': escape('storyarc:%s' % (arc['StoryArcID'])),
|
||||||
|
'updated': updated,
|
||||||
|
'content': '%s (%s)' % (arc['StoryArcName'],arc['IssueCount']),
|
||||||
|
'href': '/opds?cmd=StoryArc&arcid=%s' % (quote_plus(arc['StoryArcID'])),
|
||||||
|
'kind': 'acquisition',
|
||||||
|
'rel': 'subsection',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
feed = {}
|
||||||
|
feed['title'] = 'Mylar OPDS - Story Arcs'
|
||||||
|
feed['id'] = 'StoryArcs'
|
||||||
|
feed['updated'] = mylar.helpers.now()
|
||||||
|
links.append(getLink(href='/opds',type='application/atom+xml; profile=opds-catalog; kind=navigation', rel='start', title='Home'))
|
||||||
|
links.append(getLink(href='/opds?cmd=StoryArcs',type='application/atom+xml; profile=opds-catalog; kind=navigation',rel='self'))
|
||||||
|
if len(arcs) > (index + 30):
|
||||||
|
links.append(
|
||||||
|
getLink(href='/opds?cmd=StoryArcs&index=%s' % (index+30), type='application/atom+xml; profile=opds-catalog; kind=navigation', rel='next'))
|
||||||
|
if index >= 30:
|
||||||
|
links.append(
|
||||||
|
getLink(href='/opds?cmd=StoryArcs&index=%s' % (index-30), type='application/atom+xml; profile=opds-catalog; kind=navigation', rel='previous'))
|
||||||
|
|
||||||
|
feed['links'] = links
|
||||||
|
feed['entries'] = entries
|
||||||
|
self.data = feed
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def getLink(href=None, type=None, rel=None, title=None):
|
def getLink(href=None, type=None, rel=None, title=None):
|
||||||
link = {}
|
link = {}
|
||||||
|
|
Loading…
Reference in New Issue