Repository: Flexget/Flexget

Issue:
Tasks failing after migration from cfscraper to cloudscraper
Since #2381 one of my tasks stopped returning new entries.
After checking the log I noticed `cloudscraper` returns a ReCaptcha related error during the `rmz` automatic url-rewrite (a problem `cfscrape` doesn't have).
Upon further investigation, it seems that `cloudscraper` has this issue when importing an existing requests session generated by Flexget, since removing the last `task.requests` (for testing purposes) from https://github.com/Flexget/Flexget/blob/a4037da07f7d7707650596670c467ab3b7e748c9/flexget/plugins/operate/cfscraper.py#L39 results in a successful processing of the task.

Another finding: Disabling `urlrewriting` also did not trigger a ReCaptcha error (therefore completing the task) even without meddling with any of Flexget's .py's, however it also doesn't return a download URL if [rmz.py](https://github.com/Flexget/Flexget/blob/master/flexget/components/sites/sites/rmz.py) is not processed.
### Expected behaviour:
Task returning proper entries with populated urls

### Actual behaviour:
Task failing due to `cloudscraper` bumping into ReCaptcha during `rmz`url-rewrite
### Steps to reproduce:
- Step 1: 
#### Config:
```
tasks:
  cftask:
    disable:
      - seen
      - seen_info_hash
      - retry_failed
      # - urlrewriting
    cfscraper: yes
    rss: http://rmz.cr/feed
    series:
      # Random entry from the feed below#
      - Days of our lives
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
$ flexget execute --tasks cftask
2019-05-09 00:34 VERBOSE  task_queue                   There are 1 tasks to execute. Shutdown will commence when they have completed.
2019-05-09 00:34 VERBOSE  details       cftask         Produced 100 entries.
2019-05-09 00:34 VERBOSE  series.db     cftask         identified by is currently on `auto` for Days of our lives. Multiple id types may be accepted until it locks in on the appropriate type.
2019-05-09 00:34 VERBOSE  task          cftask         ACCEPTED: `[RR/NF/UL/OL/CU] Days of our Lives S54E160 720p WEB HEVC x265-RMTeam (198MB)` by series plugin because choosing first acceptable match
2019-05-09 00:35 WARNING  urlrewriter   cftask         URL rewriting rmz failed: Captcha
2019-05-09 00:35 ERROR    entry         cftask         Failed [RR/NF/UL/OL/CU] Days of our Lives S54E160 720p WEB HEVC x265-RMTeam (198MB) (None)
2019-05-09 00:35 VERBOSE  task          cftask         FAILED: `[RR/NF/UL/OL/CU] Days of our Lives S54E160 720p WEB HEVC x265-RMTeam (198MB)` by urlrewriting plugin
2019-05-09 00:35 VERBOSE  details       cftask         Summary - Accepted: 0 (Rejected: 0 Undecided: 99 Failed: 1)
```
</details>

### Additional information:

- FlexGet version: 2.20.26
- Python version: 2.7.14
- Installation method: pip
- Using daemon (yes/no): yes
- OS and version: Windows 10 (1809)



Discussion:

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
@@ -6,6 +6,7 @@
 from flexget import plugin
 from flexget.event import event
 from flexget.utils.requests import Session
+from collections import OrderedDict
 
 log = logging.getLogger('cfscraper')
 
@@ -36,6 +37,18 @@ class CFScrapeWrapper(Session, cloudscraper.CloudScraper):
             """
 
         if config is True:
+            task.requests.headers = (
+                OrderedDict(
+                    [
+                        ('User-Agent', task.requests.headers['User-Agent']),
+                        ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
+                        ('Accept-Language', 'en-US,en;q=0.5'),
+                        ('Accept-Encoding', 'gzip, deflate'),
+                        ('Connection',  'close'),
+                        ('Upgrade-Insecure-Requests', '1')
+                    ]
+                )
+            )
             task.requests = CFScrapeWrapper.create_scraper(task.requests)
 
 


Test patch: