From ff0421d1ee7a66ad8cbbd896c0f1db04d7d5863a Mon Sep 17 00:00:00 2001 From: Cybr Wizrd Date: Fri, 20 Mar 2015 02:47:43 -0400 Subject: [PATCH] - Inject a function into Feedparser so that we can get the newznab:attr from the RSS feed. Now we can use it to get file sizes from the DOGNZB RSS. The complete list of possible attributes is available at http://newznab.readthedocs.org/en/latest/misc/api/#predefined-attributes , but it's a much smaller subset for comics and size is pretty much the only interesting one. --- mylar/rsscheck.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mylar/rsscheck.py b/mylar/rsscheck.py index 199e158a..f70b171c 100755 --- a/mylar/rsscheck.py +++ b/mylar/rsscheck.py @@ -12,6 +12,23 @@ from StringIO import StringIO import mylar from mylar import db, logger, ftpsshup, helpers +def _start_newznab_attr(self, attrsD): + logger.fdebug('RSS newznab attributes', str(attrsD)) + context = self._getContext() + + context.setdefault('newznab', feedparser.FeedParserDict()) + context['newznab'].setdefault('tags', feedparser.FeedParserDict()) + + name = attrsD.get('name') + value = attrsD.get('value') + + if name == 'category': + context['newznab'].setdefault('categories', []).append(value) + else: + context['newznab'][name] = value + +feedparser._FeedParserMixin._start_newznab_attr = _start_newznab_attr + def tehMain(forcerss=None): logger.info('RSS Feed Check was last run at : ' + str(mylar.RSS_LASTRUN)) firstrun = "no" @@ -391,11 +408,9 @@ def nzbs(provider=None, forcerss=False): if site == 'dognzb': #because the rss of dog doesn't carry the enclosure item, we'll use the newznab size value tmpsz = 0 - #for attr in entry['newznab:attrib']: - # if attr('@name') == 'size': - # tmpsz = attr['@value'] - # logger.fdebug('size retrieved as ' + str(tmpsz)) - # break + if 'newznab' in entry and 'size' in entry['newznab']: + tmpsz = entry['newznab']['size'] + feeddata.append({ 'Site': site, 'Title': entry.title, #ft['feed'].entries[i].title,