Skip to content

Commit

Permalink
Merge pull request #1445 from philborman/master
Browse files Browse the repository at this point in the history
Added python magic library, deluge label changes, cope with goodreads changing authorid
  • Loading branch information
philborman authored Jun 2, 2018
2 parents 45ecc88 + 924d87f commit d7feebb
Show file tree
Hide file tree
Showing 22 changed files with 911 additions and 291 deletions.
9 changes: 9 additions & 0 deletions LazyLibrarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def main():
p.add_option('-p', '--pidfile',
dest='pidfile', default=None,
help="Store the process id in the given file")
p.add_option('--loglevel',
dest='loglevel', default=None,
help="Debug loglevel")

options, args = p.parse_args()

Expand Down Expand Up @@ -120,6 +123,12 @@ def main():
else:
lazylibrarian.shutdown(restart=True, update=True)

if options.loglevel:
try:
lazylibrarian.LOGLEVEL = int(options.loglevel)
except:
pass

if options.datadir:
lazylibrarian.DATADIR = str(options.datadir)
else:
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%endif
<a href="audioWall" class="button btn btn-sm btn-primary"><i class="fa fa-calendar-check"></i> Recent AudioBooks</a>
%if lazylibrarian.CONFIG['USER_ACCOUNTS'] == True:
<a href="rssFeed?user=${user}&type=AudioBook&limit=10" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent additions"><i class="fa fa-rss"></i></a>
<a href="rssFeed?user=${user}&type=AudioBook&limit=10.xml" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent downloads"><i class="fa fa-rss"></i></a>
%endif
</div>
<div class="col-xs-2">
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/books.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a href="bookWall?have=0" class="button btn btn-sm btn-primary"><i class="fa fa-calendar-plus"></i> Additions</a>
<a href="bookWall?have=1" class="button btn btn-sm btn-primary"><i class="fa fa-calendar-alt"></i> Downloads</a>
%if lazylibrarian.CONFIG['USER_ACCOUNTS'] == True:
<a href="rssFeed?user=${user}&type=eBook&limit=10" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent additions"><i class="fa fa-rss"></i></a>
<a href="rssFeed?user=${user}&type=eBook&limit=10.xml" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent downloads"><i class="fa fa-rss"></i></a>
%endif
</div>
%if len(languages) > 1:
Expand Down
4 changes: 3 additions & 1 deletion data/interfaces/bookstrap/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ <h1>${title}</h1>
if ( ftype == 'None' ) {ftype = 'eBook'}
if ( ftype.match(/^[0-9.-]+$/) != null ) {ftype = 'Magazine'}
return ftype;} },
{ targets: [4], 'render': function(data, type, row) {
return '<a data-toggle="tooltip" title="' + row[10] + '">' + row[4] + '</a>';} },
{ targets: [6], 'render': function(data, type, row) {
if ( row[9] < 0 ) { bar = data }
if ( row[9] <= 0 ) { bar = data }
else {
if ( row[9] <= 25 ) { css = 'danger' }
else if ( row[9] <= 50 ) { css = 'warning' }
Expand Down
2 changes: 1 addition & 1 deletion data/interfaces/bookstrap/magazines.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%endif
<a href="magWall" class="button btn btn-sm btn-primary"><i class="fa fa-calendar-check"></i> Recent Issues</a>
%if lazylibrarian.CONFIG['USER_ACCOUNTS'] == True:
<a href="rssFeed?user=${user}&type=Magazine&limit=10" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent additions"><i class="fa fa-rss"></i></a>
<a href="rssFeed?user=${user}&type=Magazine&limit=10.xml" class="button btn btn-sm btn-primary" data-toggle="tooltip" title="RSS feed of recent downloads"><i class="fa fa-rss"></i></a>
%endif
</div>
<div class="clearfix visible-xs"><hr/></div>
Expand Down
13 changes: 10 additions & 3 deletions lazylibrarian/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,23 @@ def _dic_from_query(query):

return rows_as_dic

def getRSSFeed(self, **kwargs):
def _getRSSFeed(self, **kwargs):
if 'feed' in kwargs:
ftype = kwargs['feed']
else:
ftype = 'book'
ftype = 'eBook'

if 'limit' in kwargs:
limit = kwargs['limit']
else:
limit = '10'
limit = 10

# url might end in .xml
if not limit.isdigit():
try:
limit = int(limit.split('.')[0])
except (IndexError, ValueError):
limit = 10

userid = 0
scheme, netloc, path, qs, anchor = urlsplit(cherrypy.url())
Expand Down
23 changes: 21 additions & 2 deletions lazylibrarian/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def scheduleJob(action='Start', target=None):
if not authcount:
minutes = 60
else:
minutes = int(minutes / authcount)
# Allow a few minutes per task - interval starts from END of previous task
minutes = int(minutes / authcount) - 5

if minutes < 10: # set a minimum interval of 10 minutes so we don't upset goodreads/librarything api
minutes = 10
Expand Down Expand Up @@ -633,7 +634,7 @@ def showJobs():
jobname = job.split(' ')[0].split('.')[2]

# jobinterval = job.split('[')[1].split(']')[0]
jobtime = job.split('at: ')[1].split('.')[0]
jobtime = job.split('at: ')[1].split('.')[0].strip(')')
jobtime = next_run(jobtime)
timeparts = jobtime.split(' ')
if timeparts[0] == '1' and timeparts[1].endswith('s'):
Expand Down Expand Up @@ -776,6 +777,24 @@ def logHeader():
except ImportError:
header += "cryptography: module missing\n"

try:
import magic
except ImportError:
try:
import lib.magic as magic
except ImportError:
magic = None

if magic:
try:
# noinspection PyProtectedMember
ver = magic.libmagic._name
except AttributeError:
ver = 'missing'
header += "magic library %s\n" % ver
else:
header += "magic module missing\n"

return header


Expand Down
Loading

0 comments on commit d7feebb

Please sign in to comment.