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
This commit is contained in:
Giao Phan 2018-06-22 11:12:18 -07:00 committed by evilhero
parent 69e7fa7ef8
commit 22de99943b
1 changed files with 9 additions and 4 deletions

View File

@ -17,7 +17,7 @@
# along with Mylar. If not, see <http://www.gnu.org/licenses/>. # along with Mylar. If not, see <http://www.gnu.org/licenses/>.
import mylar 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 simplejson as simplejson
import cherrypy import cherrypy
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
@ -39,6 +39,7 @@ class OPDS(object):
self.cmd = None self.cmd = None
self.PAGE_SIZE=30 self.PAGE_SIZE=30
self.img = None self.img = None
self.issue_id = None
self.file = None self.file = None
self.filename = None self.filename = None
self.kwargs = None self.kwargs = None
@ -82,6 +83,8 @@ class OPDS(object):
if self.img: if self.img:
return serve_file(path=self.img, content_type='image/jpeg') return serve_file(path=self.img, content_type='image/jpeg')
if self.file and self.filename: 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) return serve_download(path=self.file, name=self.filename)
if isinstance(self.data, basestring): if isinstance(self.data, basestring):
return self.data return self.data
@ -504,9 +507,11 @@ class OPDS(object):
if not comic: if not comic:
self.data = self._error_with_message('Comic Not Found in Watchlist') self.data = self._error_with_message('Comic Not Found in Watchlist')
return return
self.issue_id = issue['IssueID']
self.file = os.path.join(comic['ComicLocation'],issue['Location']) self.file = os.path.join(comic['ComicLocation'],issue['Location'])
self.filename = issue['Location'] self.filename = issue['Location']
else: else:
self.issue_id = issue['IssueID']
self.file = issue['Location'] self.file = issue['Location']
self.filename = os.path.split(issue['Location'])[1] self.filename = os.path.split(issue['Location'])[1]
return return
@ -572,7 +577,7 @@ class OPDS(object):
myDB = db.DBConnection() myDB = db.DBConnection()
links = [] links = []
entries = [] entries = []
rlist = self._dic_from_query("SELECT * from readlist") rlist = self._dic_from_query("SELECT * from readlist where status!='Read'")
readlist = [] readlist = []
for book in rlist: for book in rlist:
fileexists = False fileexists = False
@ -602,7 +607,7 @@ class OPDS(object):
issue['image'] = None issue['image'] = None
issue['thumbnail'] = None issue['thumbnail'] = None
issue['updated'] = annualentry['IssueDate'] issue['updated'] = annualentry['IssueDate']
if not os.path.isfile(fileloc): if not os.path.isfile(issue['fileloc']):
fileexists = False fileexists = False
if fileexists: if fileexists:
readlist.append(issue) readlist.append(issue)