mirror of
https://github.com/evilhero/mylar
synced 2025-02-22 22:10:30 +00:00
FIX:(#238) Usenet Retention settings have no effect (Thnx TheLabRatt), FIX:(#240) added some checks for NZBGet values and fixed some invalid strings
This commit is contained in:
parent
8ce830d703
commit
c3faf642a7
3 changed files with 33 additions and 11 deletions
|
@ -30,7 +30,10 @@ def Startit(searchName, searchIssue, searchYear):
|
|||
if mylar.USE_MAXSIZE:
|
||||
size_constraints = size_constraints + "&maxsize=" + str(mylar.MAXSIZE)
|
||||
|
||||
feed = feedparser.parse("http://nzbindex.nl/rss/alt.binaries.comics.dcp/?sort=agedesc&" + str(size_constraints) + "&dq=%s&max=25&more=1" %joinSearch)
|
||||
if mylar.USENET_RETENTION != None:
|
||||
max_age = "&age=" + str(mylar.USENET_RETENTION)
|
||||
|
||||
feed = feedparser.parse("http://nzbindex.nl/rss/alt.binaries.comics.dcp/?sort=agedesc&" + str(size_constraints) + str(max_age) + "&dq=%s&max=25&more=1" %joinSearch)
|
||||
|
||||
totNum = len(feed.entries)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import lib.simplejson as json
|
||||
import mylar
|
||||
from mylar import logger, helpers
|
||||
import urllib2
|
||||
import urllib2, datetime
|
||||
|
||||
|
||||
def searchit(cm):
|
||||
|
@ -39,18 +39,26 @@ def searchit(cm):
|
|||
url = item['nzb']
|
||||
title = item['name']
|
||||
size = item['size']
|
||||
nzbdate = datetime.datetime.fromtimestamp(item['postdate'])
|
||||
nzbage = abs(( datetime.datetime.now()-nzbdate).days )
|
||||
if nzbage <= int(mylar.USENET_RETENTION):
|
||||
entries.append({
|
||||
'title': str(title),
|
||||
'link': str(url)
|
||||
})
|
||||
#logger.fdebug('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
else:
|
||||
logger.fdebug('%s outside usenet retention: %s days.' % (title, nzbage))
|
||||
|
||||
entries.append({
|
||||
'title': str(title),
|
||||
'link': str(url)
|
||||
})
|
||||
#resultlist.append((title, size, url, provider))
|
||||
logger.fdebug('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
#logger.fdebug('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
|
||||
except Exception, e:
|
||||
logger.error(u"An unknown error occurred trying to parse the feed: %s" % e)
|
||||
|
||||
if len(entries) >= 1:
|
||||
mres['entries'] = entries
|
||||
else:
|
||||
mres = "no results"
|
||||
return mres
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
|
|||
# --------
|
||||
providercount = int(nzbp + newznabs)
|
||||
logger.fdebug("there are : " + str(providercount) + " search providers you have selected.")
|
||||
logger.fdebug("Usenet Retetion : " + str(mylar.USENET_RETENTION) + " days")
|
||||
nzbpr = nzbp-1
|
||||
findit = 'no'
|
||||
|
||||
|
@ -346,6 +347,11 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
|
|||
if nzbprov != 'nzbx':
|
||||
# Add a user-agent
|
||||
#print ("user-agent:" + str(mylar.USER_AGENT))
|
||||
### IF USENET_RETENTION is set, honour it
|
||||
### For newznab sites, that means appending "&maxage=<whatever>" on the URL
|
||||
if mylar.USENET_RETENTION != None:
|
||||
findurl = findurl + "&maxage=" + str(mylar.USENET_RETENTION)
|
||||
|
||||
request = urllib2.Request(findurl)
|
||||
request.add_header('User-Agent', str(mylar.USER_AGENT))
|
||||
opener = urllib2.build_opener()
|
||||
|
@ -702,12 +708,17 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
|
|||
from xmlrpclib import ServerProxy
|
||||
if mylar.NZBGET_HOST[:4] == 'http':
|
||||
tmpapi = "http://"
|
||||
nzbget_host = mylar.NZBGET_HOST[7]
|
||||
nzbget_host = mylar.NZBGET_HOST[7:]
|
||||
elif mylar.NZBGET_HOST[:5] == 'https':
|
||||
tmpapi = "https://"
|
||||
nzbget_host = mylar.NZBGET_HOST[8]
|
||||
tmpapi = tmpapi + str(mylar.NZBGET_USERNAME) + ":" + str(mylar.NZBGET_PASSWORD)
|
||||
tmpapi = tmpapi + "@" + nzbget_host + ":" + str(mylar.NZBGET_PORT) + "/xmlrpc"
|
||||
nzbget_host = mylar.NZBGET_HOST[8:]
|
||||
else:
|
||||
logger.error("You have an invalid nzbget hostname specified. Exiting")
|
||||
return
|
||||
logger.info("nzbget_host:" + str(nzbget_host))
|
||||
logger.info("tmpapi:" + str(tmpapi))
|
||||
tmpapi = str(tmpapi) + str(mylar.NZBGET_USERNAME) + ":" + str(mylar.NZBGET_PASSWORD)
|
||||
tmpapi = str(tmpapi) + "@" + str(nzbget_host) + ":" + str(mylar.NZBGET_PORT) + "/xmlrpc"
|
||||
server = ServerProxy(tmpapi)
|
||||
send_to_nzbget = server.appendurl(nzbname, mylar.NZBGET_CATEGORY, mylar.NZBGET_PRIORITY, True, str(linkapi))
|
||||
if send_to_nzbget is True:
|
||||
|
|
Loading…
Reference in a new issue