From 22de99943bc63039e33d27c3333ca490f2a4b8fc Mon Sep 17 00:00:00 2001 From: Giao Phan Date: Fri, 22 Jun 2018 11:12:18 -0700 Subject: [PATCH] OPDS enhancements Fix bug for reading list Mark a comic as read if it's downloaded through the OPDS feed Reading list will not show Read comics --- mylar/opds.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mylar/opds.py b/mylar/opds.py index 3dab952a..b32ed6f2 100644 --- a/mylar/opds.py +++ b/mylar/opds.py @@ -17,7 +17,7 @@ # along with Mylar. If not, see . import mylar -from mylar import db, mb, importer, search, PostProcessor, versioncheck, logger +from mylar import db, mb, importer, search, PostProcessor, versioncheck, logger, readinglist import simplejson as simplejson import cherrypy from xml.sax.saxutils import escape @@ -39,6 +39,7 @@ class OPDS(object): self.cmd = None self.PAGE_SIZE=30 self.img = None + self.issue_id = None self.file = None self.filename = None self.kwargs = None @@ -82,6 +83,8 @@ class OPDS(object): if self.img: return serve_file(path=self.img, content_type='image/jpeg') if self.file and self.filename: + if self.issue_id: + readinglist.Readinglist(IssueID=self.issue_id).markasRead() return serve_download(path=self.file, name=self.filename) if isinstance(self.data, basestring): return self.data @@ -434,7 +437,7 @@ class OPDS(object): title = escape('%03d: %s #%s - %s (In stores %s)' % (index + number, issuebook['ComicName'], issuebook['Issue_Number'], issuebook['IssueName'], issuebook['ReleaseDate'])) image = issuebook['ImageURL_ALT'] thumbnail = issuebook['ImageURL'] - else: + else: title = escape('%03d: %s #%s - %s (Added to Mylar %s, in stores %s)' % (index + number, issuebook['ComicName'], issuebook['Issue_Number'], issuebook['IssueName'], issuebook['DateAdded'], issuebook['ReleaseDate'])) image = issuebook['ImageURL_ALT'] thumbnail = issuebook['ImageURL'] @@ -504,9 +507,11 @@ class OPDS(object): if not comic: self.data = self._error_with_message('Comic Not Found in Watchlist') return + self.issue_id = issue['IssueID'] self.file = os.path.join(comic['ComicLocation'],issue['Location']) self.filename = issue['Location'] else: + self.issue_id = issue['IssueID'] self.file = issue['Location'] self.filename = os.path.split(issue['Location'])[1] return @@ -572,7 +577,7 @@ class OPDS(object): myDB = db.DBConnection() links = [] entries = [] - rlist = self._dic_from_query("SELECT * from readlist") + rlist = self._dic_from_query("SELECT * from readlist where status!='Read'") readlist = [] for book in rlist: fileexists = False @@ -602,7 +607,7 @@ class OPDS(object): issue['image'] = None issue['thumbnail'] = None issue['updated'] = annualentry['IssueDate'] - if not os.path.isfile(fileloc): + if not os.path.isfile(issue['fileloc']): fileexists = False if fileexists: readlist.append(issue)