2015-06-15 19:09:01 +00:00
|
|
|
# coding=utf-8
|
|
|
|
#
|
|
|
|
# This file is part of SickGear.
|
|
|
|
#
|
|
|
|
|
2017-01-27 14:23:35 +00:00
|
|
|
import feedparser
|
2014-06-29 10:05:33 +00:00
|
|
|
|
2018-01-15 17:54:36 +00:00
|
|
|
from sickbeard import logger
|
2014-07-15 05:53:32 +00:00
|
|
|
from sickbeard.exceptions import ex
|
2014-07-15 02:00:53 +00:00
|
|
|
|
|
|
|
|
2015-06-15 19:09:01 +00:00
|
|
|
class RSSFeeds:
|
|
|
|
|
|
|
|
def __init__(self, provider=None):
|
|
|
|
self.provider = provider
|
2014-08-31 19:56:18 +00:00
|
|
|
|
2018-01-15 17:54:36 +00:00
|
|
|
def get_feed(self, url, **kwargs):
|
|
|
|
|
|
|
|
if self.provider and self.provider.check_auth_cookie():
|
|
|
|
response = self.provider.get_url(url, **kwargs)
|
|
|
|
if not self.provider.should_skip() and response:
|
|
|
|
try:
|
|
|
|
data = feedparser.parse(response)
|
|
|
|
data['rq_response'] = self.provider.session.response
|
|
|
|
if data and 'entries' in data:
|
|
|
|
return data
|
|
|
|
|
|
|
|
if data and 'error' in data.feed:
|
|
|
|
err_code = data.feed['error']['code']
|
|
|
|
err_desc = data.feed['error']['description']
|
|
|
|
logger.log(u'RSS error:[%s] code:[%s]' % (err_desc, err_code), logger.DEBUG)
|
|
|
|
else:
|
|
|
|
logger.log(u'RSS error loading url: ' + url, logger.DEBUG)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
logger.log(u'RSS error: ' + ex(e), logger.DEBUG)
|