Repository: Flexget/Flexget

Issue:
Flexget throwing RSS error
```
2016-04-13 21:44 CRITICAL task Torrentz BUG: Unhandled error in plugin rss: request() got an unexpected keyword argument 'raise_status'
2016-04-13 21:44 CRITICAL manager Torrentz An unexpected crash has occurred. Writing crash report to /root/.flexget/crash_report.2016.04.13.214428777146.log. Please verify you are running the latest version of flexget by using "flexget -V" from CLI or by using version_checker plugin at http://flexget.com/wiki/Plugins/version_checker. You are currently using version 1.2.510
2016-04-13 21:44 WARNING task Torrentz Aborting task (plugin: rss)
2016-04-13 21:44 CRITICAL task KATtv BUG: Unhandled error in plugin rss: request() got an unexpected keyword argument 'raise_status'
2016-04-13 21:44 CRITICAL manager KATtv An unexpected crash has occurred. Writing crash report to /root/.flexget/crash_report.2016.04.13.214428821304.log. Please verify you are running the latest version of flexget by using "flexget -V" from CLI or by using version_checker plugin at http://flexget.com/wiki/Plugins/version_checker. You are currently using version 1.2.510
2016-04-13 21:44 WARNING task KATtv Aborting task (plugin: rss)
2016-04-13 21:44 CRITICAL task Extratorrent BUG: Unhandled error in plugin rss: request() got an unexpected keyword argument 'raise_status'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flexget/task.py", line 438, in _runplugin
return method(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/event.py", line 22, in call
return self.func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/utils/cached_input.py", line 142, in wrapped_func
response = func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/plugin.py", line 124, in wrapped_func
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flexget/plugins/input/rss.py", line 235, in on_task_input
response = task.requests.get(config['url'], timeout=60, headers=headers, raise_status=False, auth=auth)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 480, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/cfscrape/__init__.py", line 25, in request
resp = super(CloudflareScraper, self).request(method, url, *args, **kwargs)
TypeError: request() got an unexpected keyword argument 'raise_status'
```



Discussion:
what version are you on?

1.2.513

This is a problem with the rss and the cfscraper plugin. Easy fix is to stop using the cfscraper plugin. I have opened an issue on the cloudflare-scrape github, but he hasn't answered, so I might have to fix it manually. Sadly, I don't have time. I might be able to look at it in a week or so.


Resolving patch:
diff --git a/flexget/plugins/operate/cfscraper.py b/flexget/plugins/operate/cfscraper.py
--- a/flexget/plugins/operate/cfscraper.py
+++ b/flexget/plugins/operate/cfscraper.py
@@ -5,9 +5,10 @@
  
 from flexget import plugin, validator
 from flexget.event import event
+from flexget.utils.requests import Session
  
 log = logging.getLogger('cfscraper')
- 
+
  
 class CFScraper(object):
     """
@@ -27,8 +28,14 @@ def on_task_start(self, task, config):
         except ImportError as e:
             log.debug('Error importing cfscrape: %s' % e)
             raise plugin.DependencyError('cfscraper', 'cfscrape', 'cfscrape module required. ImportError: %s' % e)
+
+        class CFScrapeWrapper(Session, cfscrape.CloudflareScraper):
+            """
+            This class allows the FlexGet session to inherit from CFScraper instead of the requests.Session directly.
+            """
+
         if config is True:
-            task.requests = cfscrape.create_scraper(task.requests)
+            task.requests = CFScrapeWrapper.create_scraper(task.requests)
  
  
 @event('plugin.register')
diff --git a/flexget/utils/requests.py b/flexget/utils/requests.py
--- a/flexget/utils/requests.py
+++ b/flexget/utils/requests.py
@@ -167,9 +167,9 @@ class Session(requests.Session):
 
     """
 
-    def __init__(self, timeout=30, max_retries=1):
+    def __init__(self, timeout=30, max_retries=1, *args, **kwargs):
         """Set some defaults for our session if not explicitly defined."""
-        requests.Session.__init__(self)
+        super(Session, self).__init__(*args, **kwargs)
         self.timeout = timeout
         self.stream = True
         self.adapters['http://'].max_retries = max_retries
@@ -231,7 +231,7 @@ def request(self, method, url, *args, **kwargs):
 
         try:
             log.debug('Fetching %s' % url)
-            result = requests.Session.request(self, method, url, *args, **kwargs)
+            result = super(Session, self).request(method, url, *args, **kwargs)
         except requests.Timeout:
             # Mark this site in known unresponsive list
             set_unresponsive(url)


Test patch: