Use pubDate and enclosure length for newznab
This commit is contained in:
1 parent
17e01689d9
commit
b225980ce7
1 file changed
+6
-17
@@ -117,29 +117,18 @@ class Newznab(NZBProvider, RSS):
|
|||||||
results = []
|
results = []
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|
||||||
date = ''
|
nzb_id = self.getTextElement(nzb, "guid").split('/')[-1:].pop()
|
||||||
size = 0
|
|
||||||
for item in nzb:
|
|
||||||
if item.attrib.get('name') == 'size':
|
|
||||||
size = item.attrib.get('value')
|
|
||||||
elif item.attrib.get('name') == 'usenetdate':
|
|
||||||
date = item.attrib.get('value')
|
|
||||||
|
|
||||||
if date is '': log.debug('Date not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
|
|
||||||
if size is 0: log.debug('Size not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
|
|
||||||
|
|
||||||
id = self.getTextElement(nzb, "guid").split('/')[-1:].pop()
|
|
||||||
new = {
|
new = {
|
||||||
'id': 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(date).timetuple()))),
|
'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, 'pubDate')).timetuple()))),
|
||||||
'size': int(size) / 1024 / 1024,
|
'size': int(self.getElement(nzb, "enclosure").attrib['length']) / 1024 / 1024,
|
||||||
'url': (self.getUrl(host['host'], self.urls['download']) % 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']), id),
|
'detail_url': '%sdetails/%s' % (cleanHost(host['host']), nzb_id),
|
||||||
'content': self.getTextElement(nzb, "description"),
|
'content': self.getTextElement(nzb, "description"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user