Browse Source

Newznab age wrong. fix #1171

pull/1178/head
Ruud 13 years ago
parent
commit
439cda8b63
  1. 28
      couchpotato/core/providers/nzb/newznab/main.py

28
couchpotato/core/providers/nzb/newznab/main.py

@ -53,7 +53,7 @@ class Newznab(NZBProvider, RSS):
'r': host['api_key'], 'r': host['api_key'],
'i': 58, 'i': 58,
}) })
url = "%s?%s" % (cleanHost(host['host']) + 'rss', arguments) url = '%s?%s' % (cleanHost(host['host']) + 'rss', arguments)
cache_key = 'newznab.%s.feed.%s' % (host['host'], arguments) cache_key = 'newznab.%s.feed.%s' % (host['host'], arguments)
results = self.createItems(url, cache_key, host, for_feed = True) results = self.createItems(url, cache_key, host, for_feed = True)
@ -87,7 +87,7 @@ class Newznab(NZBProvider, RSS):
'apikey': host['api_key'], 'apikey': host['api_key'],
'extended': 1 'extended': 1
}) })
url = "%s&%s" % (self.getUrl(host['host'], self.urls['search']), arguments) url = '%s&%s' % (self.getUrl(host['host'], self.urls['search']), arguments)
cache_key = 'newznab.%s.%s.%s' % (host['host'], movie['library']['identifier'], cat_id) cache_key = 'newznab.%s.%s.%s' % (host['host'], movie['library']['identifier'], cat_id)
@ -111,19 +111,33 @@ class Newznab(NZBProvider, RSS):
results = [] results = []
for nzb in nzbs: for nzb in nzbs:
nzb_id = self.getTextElement(nzb, "guid").split('/')[-1:].pop() date = None
for item in nzb:
if item.attrib.get('name') == 'usenetdate':
date = item.attrib.get('value')
break
if not date:
date = self.getTextElement(nzb, 'pubDate')
nzb_id = self.getTextElement(nzb, 'guid').split('/')[-1:].pop()
name = self.getTextElement(nzb, 'title')
if not name:
continue
new = { new = {
'id': nzb_id, 'id': nzb_id,
'provider': self.getName(), 'provider': self.getName(),
'provider_extra': host['host'], 'provider_extra': host['host'],
'type': 'nzb', 'type': 'nzb',
'name': self.getTextElement(nzb, "title"), 'name': self.getTextElement(nzb, 'title'),
'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, 'pubDate')).timetuple()))), 'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))),
'size': int(self.getElement(nzb, "enclosure").attrib['length']) / 1024 / 1024, 'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024,
'url': (self.getUrl(host['host'], self.urls['download']) % nzb_id) + self.getApiExt(host), 'url': (self.getUrl(host['host'], self.urls['download']) % nzb_id) + self.getApiExt(host),
'download': self.download, 'download': self.download,
'detail_url': '%sdetails/%s' % (cleanHost(host['host']), nzb_id), 'detail_url': '%sdetails/%s' % (cleanHost(host['host']), nzb_id),
'content': self.getTextElement(nzb, "description"), 'content': self.getTextElement(nzb, 'description'),
} }
if not for_feed: if not for_feed:

Loading…
Cancel
Save