mirror of
https://github.com/evilhero/mylar
synced 2025-01-03 05:24:43 +00:00
- Revamped 'getIndex' and 'getComic' commands
This commit is contained in:
parent
9542c47fc2
commit
ae093da9e5
1 changed files with 65 additions and 16 deletions
81
mylar/api.py
81
mylar/api.py
|
@ -134,6 +134,40 @@ class Api(object):
|
||||||
else:
|
else:
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
|
def _selectForComics(self):
|
||||||
|
return 'SELECT \
|
||||||
|
ComicID as id,\
|
||||||
|
ComicName as name,\
|
||||||
|
ComicImageURL as imageURL,\
|
||||||
|
Status as status,\
|
||||||
|
ComicPublisher as publisher,\
|
||||||
|
ComicYear as year,\
|
||||||
|
LatestIssue as latestIssue,\
|
||||||
|
Total as totalIssues,\
|
||||||
|
DetailURL as detailsURL\
|
||||||
|
FROM comics'
|
||||||
|
|
||||||
|
def _selectForIssues(self):
|
||||||
|
return 'SELECT \
|
||||||
|
IssueID as id,\
|
||||||
|
IssueName as name,\
|
||||||
|
ImageURL as imageURL,\
|
||||||
|
Issue_Number as number,\
|
||||||
|
ReleaseDate as releaseDate,\
|
||||||
|
IssueDate as issueDate,\
|
||||||
|
Status as status\
|
||||||
|
FROM issues'
|
||||||
|
|
||||||
|
def _selectForAnnuals(self):
|
||||||
|
return 'SELECT \
|
||||||
|
IssueID as id,\
|
||||||
|
IssueName as name,\
|
||||||
|
Issue_Number as number,\
|
||||||
|
ReleaseDate as releaseDate,\
|
||||||
|
IssueDate as issueDate,\
|
||||||
|
Status as status\
|
||||||
|
FROM annuals'
|
||||||
|
|
||||||
def _dic_from_query(self, query):
|
def _dic_from_query(self, query):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
rows = myDB.select(query)
|
rows = myDB.select(query)
|
||||||
|
@ -183,18 +217,14 @@ class Api(object):
|
||||||
self.data = self._error_with_message('Incorrect username or password.')
|
self.data = self._error_with_message('Incorrect username or password.')
|
||||||
|
|
||||||
def _getIndex(self, **kwargs):
|
def _getIndex(self, **kwargs):
|
||||||
self.data = self._dic_from_query(
|
|
||||||
"SELECT ComicID as id,\
|
query = '{select} FROM comics ORDER BY ComicSortName COLLATE NOCASE'.format(
|
||||||
ComicName as name,\
|
select = self._selectForComics(),
|
||||||
ComicImageURL as imageURL,\
|
id = self.id
|
||||||
Status as status,\
|
)
|
||||||
ComicPublisher as publisher,\
|
|
||||||
ComicYear as year,\
|
self.data = self._dic_from_query(query)
|
||||||
LatestIssue as latestIssue,\
|
|
||||||
Total as totalIssues,\
|
|
||||||
DetailURL as detailsURL\
|
|
||||||
FROM comics \
|
|
||||||
ORDER BY ComicSortName COLLATE NOCASE")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getReadList(self, **kwargs):
|
def _getReadList(self, **kwargs):
|
||||||
|
@ -208,14 +238,33 @@ class Api(object):
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
comic = self._dic_from_query('SELECT * from comics WHERE ComicID="' + self.id + '"')
|
comicQuery = '{select} WHERE ComicID="{id}" ORDER BY ComicSortName COLLATE NOCASE'.format(
|
||||||
issues = self._dic_from_query('SELECT * from issues WHERE ComicID="' + self.id + '"order by Int_IssueNumber DESC')
|
select = self._selectForComics(),
|
||||||
|
id = self.id
|
||||||
|
)
|
||||||
|
comic = self._dic_from_query(comicQuery)
|
||||||
|
|
||||||
|
issuesQuery = '{select} WHERE ComicID="{id}" ORDER BY Int_IssueNumber DESC'.format(
|
||||||
|
select = self._selectForIssues(),
|
||||||
|
id = self.id
|
||||||
|
)
|
||||||
|
issues = self._dic_from_query(issuesQuery)
|
||||||
|
|
||||||
if mylar.CONFIG.ANNUALS_ON:
|
if mylar.CONFIG.ANNUALS_ON:
|
||||||
annuals = self._dic_from_query('SELECT * FROM annuals WHERE ComicID="' + self.id + '"')
|
annualsQuery = '{select} WHERE ComicID="{id}"'.format(
|
||||||
|
select = self._selectForAnnuals(),
|
||||||
|
id = self.id
|
||||||
|
)
|
||||||
|
annuals = self._dic_from_query(annualsQuery)
|
||||||
else:
|
else:
|
||||||
annuals = []
|
annuals = []
|
||||||
|
|
||||||
self.data = {'comic': comic, 'issues': issues, 'annuals': annuals}
|
self.data = {
|
||||||
|
'comic': comic,
|
||||||
|
'issues': issues,
|
||||||
|
'annuals': annuals
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getHistory(self, **kwargs):
|
def _getHistory(self, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue