mirror of https://github.com/evilhero/mylar
Fixed feedparser error. Added sab pause logic
Added logic to pause\resume sab queue, so queue will stay paused if it was paused before adding a issue. Also resolved feedparser error when adding issue
This commit is contained in:
parent
25513ccba7
commit
5bdb577ebf
|
@ -23,7 +23,7 @@ dognzb_APIkey = mylar.DOGNZB_APIKEY
|
|||
|
||||
LOG = mylar.LOG_DIR
|
||||
|
||||
import lib.feedparser
|
||||
import lib.feedparser as feedparser
|
||||
import urllib
|
||||
import os, errno
|
||||
import string
|
||||
|
@ -409,10 +409,26 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
|
|||
savefile = str(mylar.PROG_DIR) + "/" + str(filenzb) + ".nzb"
|
||||
|
||||
urllib.urlretrieve(linkapi, str(savefile))
|
||||
#print (str(mylar.RENAME_FILES))
|
||||
#pause sab first because it downloads too quick (cbr's are small!)
|
||||
pauseapi = str(mylar.SAB_HOST) + "/api?mode=pause&apikey=" + str(mylar.SAB_APIKEY)
|
||||
urllib.urlopen(pauseapi);
|
||||
#print (str(mylar.RENAME_FILES))
|
||||
|
||||
#check sab for current pause status
|
||||
sabqstatusapi = str(mylar.SAB_HOST) + "/api?mode=qstatus&output=xml&apikey=" + str(mylar.SAB_APIKEY)
|
||||
from xml.dom.minidom import parseString
|
||||
import urllib2
|
||||
file = urllib2.urlopen(sabqstatusapi);
|
||||
data = file.read()
|
||||
file.close()
|
||||
dom = parseString(data)
|
||||
for node in dom.getElementsByTagName('paused'):
|
||||
pausestatus = node.firstChild.wholeText
|
||||
#print pausestatus
|
||||
if pausestatus != 'True':
|
||||
#pause sab first because it downloads too quick (cbr's are small!)
|
||||
pauseapi = str(mylar.SAB_HOST) + "/api?mode=pause&apikey=" + str(mylar.SAB_APIKEY)
|
||||
urllib.urlopen(pauseapi);
|
||||
#print "Queue paused"
|
||||
#else:
|
||||
#print "Queue already paused"
|
||||
|
||||
if mylar.RENAME_FILES == 1:
|
||||
#print ("Saved file to: " + str(savefile))
|
||||
|
@ -488,9 +504,15 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
|
|||
#myDB = db.DBConnection()
|
||||
#myDB.upsert("sablog", newValueDict, controlValueDict)
|
||||
else: logger.info(u"Couldn't locate file in SAB - are you sure it's being downloaded?")
|
||||
#let's unpause queue now that we did our jobs.
|
||||
resumeapi = str(mylar.SAB_HOST) + "/api?mode=resume&apikey=" + str(mylar.SAB_APIKEY)
|
||||
urllib.urlopen(resumeapi);
|
||||
#resume sab if it was running before we started
|
||||
if pausestatus != 'True':
|
||||
#let's unpause queue now that we did our jobs.
|
||||
resumeapi = str(mylar.SAB_HOST) + "/api?mode=resume&apikey=" + str(mylar.SAB_APIKEY)
|
||||
urllib.urlopen(resumeapi);
|
||||
#print "Queue resumed"
|
||||
#else:
|
||||
#print "Queue already paused"
|
||||
|
||||
#raise an exception to break out of loop
|
||||
foundc = "yes"
|
||||
done = True
|
||||
|
@ -570,4 +592,3 @@ def searchforissue(issueid=None, new=False):
|
|||
else:
|
||||
pass
|
||||
#print ("not found!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue