We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Input plugin "imdb_list" currently failing to fetch lists behind authentication
Message: `There was an error during imdb_list input (Unable to get imdb list: 404 Client Error: Not Found), using cache instead."`

Same issue as, http://flexget.com/ticket/2313 but even with the most recent fix applied it still fails.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `flexget/plugins/input/imdb_list.py`
Content:
```
1 from __future__ import unicode_literals, division, absolute_import
2 import logging
3 import csv
4 import re
5 from cgi import parse_header
6 
7 from flexget import plugin
8 from flexget.event import event
9 from flexget.utils import requests
10 from flexget.utils.imdb import make_url
11 from flexget.utils.cached_input import cached
12 from flexget.utils.tools import decode_html
13 from flexget.entry import Entry
14 from flexget.utils.soup import get_soup
15 
16 log = logging.getLogger('imdb_list')
17 
18 USER_ID_RE = r'^ur\d{7,8}$'
19 
20 
21 class ImdbList(object):
22     """"Creates an entry for each movie in your imdb list."""
23 
24     schema = {
25         'type': 'object',
26         'properties': {
27             'user_id': {
28                 'type': 'string',
29                 'pattern': USER_ID_RE,
30                 'error_pattern': 'user_id must be in the form urXXXXXXX'
31             },
32             'username': {'type': 'string'},
33             'password': {'type': 'string'},
34             'list': {'type': 'string'}
35         },
36         'required': ['list'],
37         'additionalProperties': False
38     }
39 
40     @cached('imdb_list', persist='2 hours')
41     def on_task_input(self, task, config):
42         sess = requests.Session()
43         if config.get('username') and config.get('password'):
44 
45             log.verbose('Logging in ...')
46 
47             # Log in to imdb with our handler
48             params = {'login': config['username'], 'password': config['password']}
49             try:
50                 # First get the login page so we can get the hidden input value
51                 soup = get_soup(sess.get('https://secure.imdb.com/register-imdb/login').content)
52 
53                 # Fix for bs4 bug. see #2313 and github#118
54                 auxsoup = soup.find('div', id='nb20').next_sibling.next_sibling
55                 tag = auxsoup.find('input', attrs={'name': '49e6c'})
56                 if tag:
57                     params['49e6c'] = tag['value']
58                 else:
59                     log.warning('Unable to find required info for imdb login, maybe their login method has changed.')
60                 # Now we do the actual login with appropriate parameters
61                 r = sess.post('https://secure.imdb.com/register-imdb/login', data=params, raise_status=False)
62             except requests.RequestException as e:
63                 raise plugin.PluginError('Unable to login to imdb: %s' % e.message)
64 
65             # IMDb redirects us upon a successful login.
66             # removed - doesn't happen always?
67             # if r.status_code != 302:
68             #     log.warning('It appears logging in to IMDb was unsuccessful.')
69 
70             # try to automatically figure out user_id from watchlist redirect url
71             if not 'user_id' in config:
72                 log.verbose('Getting user_id ...')
73                 try:
74                     response = sess.get('http://www.imdb.com/list/watchlist')
75                 except requests.RequestException as e:
76                     log.error('Error retrieving user ID from imdb: %s' % e.message)
77                     user_id = ''
78                 else:
79                     log.debug('redirected to %s' % response.url)
80                     user_id = response.url.split('/')[-2]
81                 if re.match(USER_ID_RE, user_id):
82                     config['user_id'] = user_id
83                 else:
84                     raise plugin.PluginError('Couldn\'t figure out user_id, please configure it manually.')
85 
86         if not 'user_id' in config:
87             raise plugin.PluginError('Configuration option `user_id` required.')
88 
89         log.verbose('Retrieving list %s ...' % config['list'])
90 
91         # Get the imdb list in csv format
92         try:
93             url = 'http://www.imdb.com/list/export'
94             params = {'list_id': config['list'], 'author_id': config['user_id']}
95             log.debug('Requesting %s' % url)
96             opener = sess.get(url, params=params)
97             mime_type = parse_header(opener.headers['content-type'])[0]
98             log.debug('mime_type: %s' % mime_type)
99             if mime_type != 'text/csv':
100                 raise plugin.PluginError('Didn\'t get CSV export as response. Probably specified list `%s` '
101                                          'does not exist.' % config['list'])
102             csv_rows = csv.reader(opener.iter_lines())
103         except requests.RequestException as e:
104             raise plugin.PluginError('Unable to get imdb list: %s' % e.message)
105 
106         # Create an Entry for each movie in the list
107         entries = []
108         for row in csv_rows:
109             if not row or row[0] == 'position':
110                 # Don't use blank rows or the headings row
111                 continue
112             try:
113                 title = decode_html(row[5]).decode('utf-8')
114                 entries.append(Entry(title=title, url=make_url(row[1]), imdb_id=row[1], imdb_name=title))
115             except IndexError:
116                 log.critical('IndexError! Unable to handle row: %s' % row)
117         return entries
118 
119 
120 @event('plugin.register')
121 def register_plugin():
122     plugin.register(ImdbList, 'imdb_list', api_ver=2)
123
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/flexget/plugins/input/imdb_list.py b/flexget/plugins/input/imdb_list.py
--- a/flexget/plugins/input/imdb_list.py
+++ b/flexget/plugins/input/imdb_list.py
@@ -1,13 +1,13 @@
 from __future__ import unicode_literals, division, absolute_import
 import logging
-import csv
+import feedparser
 import re
 from cgi import parse_header
 
 from flexget import plugin
 from flexget.event import event
 from flexget.utils import requests
-from flexget.utils.imdb import make_url
+from flexget.utils.imdb import make_url, extract_id
 from flexget.utils.cached_input import cached
 from flexget.utils.tools import decode_html
 from flexget.entry import Entry
@@ -88,32 +88,27 @@
 
         log.verbose('Retrieving list %s ...' % config['list'])
 
-        # Get the imdb list in csv format
+        # Get the imdb list in RSS format
         try:
-            url = 'http://www.imdb.com/list/export'
-            params = {'list_id': config['list'], 'author_id': config['user_id']}
+            if config['list'] in ['watchlist', 'ratings', 'checkins']:
+                url = 'http://rss.imdb.com/user/%s/%s' % (config['user_id'], config['list'])
+            else:
+                url = 'http://rss.imdb.com/list/%s' % config['list']
             log.debug('Requesting %s' % url)
-            opener = sess.get(url, params=params)
-            mime_type = parse_header(opener.headers['content-type'])[0]
-            log.debug('mime_type: %s' % mime_type)
-            if mime_type != 'text/csv':
-                raise plugin.PluginError('Didn\'t get CSV export as response. Probably specified list `%s` '
-                                         'does not exist.' % config['list'])
-            csv_rows = csv.reader(opener.iter_lines())
+            try:
+                rss = feedparser.parse(url)
+            except LookupError as e:
+                raise plugin.PluginError('Failed to parse RSS feed for list `%s` correctly: %s' % (config['list'], e))
         except requests.RequestException as e:
             raise plugin.PluginError('Unable to get imdb list: %s' % e.message)
 
         # Create an Entry for each movie in the list
         entries = []
-        for row in csv_rows:
-            if not row or row[0] == 'position':
-                # Don't use blank rows or the headings row
-                continue
+        for entry in rss.entries:
             try:
-                title = decode_html(row[5]).decode('utf-8')
-                entries.append(Entry(title=title, url=make_url(row[1]), imdb_id=row[1], imdb_name=title))
+                entries.append(Entry(title=entry.title, url=entry.link, imdb_id=extract_id(entry.link), imdb_name=entry.title))
             except IndexError:
-                log.critical('IndexError! Unable to handle row: %s' % row)
+                log.critical('IndexError! Unable to handle RSS entry: %s' % entry)
         return entries

{"golden_diff": "diff --git a/flexget/plugins/input/imdb_list.py b/flexget/plugins/input/imdb_list.py\n--- a/flexget/plugins/input/imdb_list.py\n+++ b/flexget/plugins/input/imdb_list.py\n@@ -1,13 +1,13 @@\n from __future__ import unicode_literals, division, absolute_import\n import logging\n-import csv\n+import feedparser\n import re\n from cgi import parse_header\n \n from flexget import plugin\n from flexget.event import event\n from flexget.utils import requests\n-from flexget.utils.imdb import make_url\n+from flexget.utils.imdb import make_url, extract_id\n from flexget.utils.cached_input import cached\n from flexget.utils.tools import decode_html\n from flexget.entry import Entry\n@@ -88,32 +88,27 @@\n \n         log.verbose('Retrieving list %s ...' % config['list'])\n \n-        # Get the imdb list in csv format\n+        # Get the imdb list in RSS format\n         try:\n-            url = 'http://www.imdb.com/list/export'\n-            params = {'list_id': config['list'], 'author_id': config['user_id']}\n+            if config['list'] in ['watchlist', 'ratings', 'checkins']:\n+                url = 'http://rss.imdb.com/user/%s/%s' % (config['user_id'], config['list'])\n+            else:\n+                url = 'http://rss.imdb.com/list/%s' % config['list']\n             log.debug('Requesting %s' % url)\n-            opener = sess.get(url, params=params)\n-            mime_type = parse_header(opener.headers['content-type'])[0]\n-            log.debug('mime_type: %s' % mime_type)\n-            if mime_type != 'text/csv':\n-                raise plugin.PluginError('Didn\\'t get CSV export as response. Probably specified list `%s` '\n-                                         'does not exist.' % config['list'])\n-            csv_rows = csv.reader(opener.iter_lines())\n+            try:\n+                rss = feedparser.parse(url)\n+            except LookupError as e:\n+                raise plugin.PluginError('Failed to parse RSS feed for list `%s` correctly: %s' % (config['list'], e))\n         except requests.RequestException as e:\n             raise plugin.PluginError('Unable to get imdb list: %s' % e.message)\n \n         # Create an Entry for each movie in the list\n         entries = []\n-        for row in csv_rows:\n-            if not row or row[0] == 'position':\n-                # Don't use blank rows or the headings row\n-                continue\n+        for entry in rss.entries:\n             try:\n-                title = decode_html(row[5]).decode('utf-8')\n-                entries.append(Entry(title=title, url=make_url(row[1]), imdb_id=row[1], imdb_name=title))\n+                entries.append(Entry(title=entry.title, url=entry.link, imdb_id=extract_id(entry.link), imdb_name=entry.title))\n             except IndexError:\n-                log.critical('IndexError! Unable to handle row: %s' % row)\n+                log.critical('IndexError! Unable to handle RSS entry: %s' % entry)\n         return entries\n", "issue": "Input plugin \"imdb_list\" currently failing to fetch lists behind authentication\nMessage: `There was an error during imdb_list input (Unable to get imdb list: 404 Client Error: Not Found), using cache instead.\"`\n\nSame issue as, http://flexget.com/ticket/2313 but even with the most recent fix applied it still fails.\n\n", "before_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nimport logging\nimport csv\nimport re\nfrom cgi import parse_header\n\nfrom flexget import plugin\nfrom flexget.event import event\nfrom flexget.utils import requests\nfrom flexget.utils.imdb import make_url\nfrom flexget.utils.cached_input import cached\nfrom flexget.utils.tools import decode_html\nfrom flexget.entry import Entry\nfrom flexget.utils.soup import get_soup\n\nlog = logging.getLogger('imdb_list')\n\nUSER_ID_RE = r'^ur\\d{7,8}$'\n\n\nclass ImdbList(object):\n    \"\"\"\"Creates an entry for each movie in your imdb list.\"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'user_id': {\n                'type': 'string',\n                'pattern': USER_ID_RE,\n                'error_pattern': 'user_id must be in the form urXXXXXXX'\n            },\n            'username': {'type': 'string'},\n            'password': {'type': 'string'},\n            'list': {'type': 'string'}\n        },\n        'required': ['list'],\n        'additionalProperties': False\n    }\n\n    @cached('imdb_list', persist='2 hours')\n    def on_task_input(self, task, config):\n        sess = requests.Session()\n        if config.get('username') and config.get('password'):\n\n            log.verbose('Logging in ...')\n\n            # Log in to imdb with our handler\n            params = {'login': config['username'], 'password': config['password']}\n            try:\n                # First get the login page so we can get the hidden input value\n                soup = get_soup(sess.get('https://secure.imdb.com/register-imdb/login').content)\n\n                # Fix for bs4 bug. see #2313 and github#118\n                auxsoup = soup.find('div', id='nb20').next_sibling.next_sibling\n                tag = auxsoup.find('input', attrs={'name': '49e6c'})\n                if tag:\n                    params['49e6c'] = tag['value']\n                else:\n                    log.warning('Unable to find required info for imdb login, maybe their login method has changed.')\n                # Now we do the actual login with appropriate parameters\n                r = sess.post('https://secure.imdb.com/register-imdb/login', data=params, raise_status=False)\n            except requests.RequestException as e:\n                raise plugin.PluginError('Unable to login to imdb: %s' % e.message)\n\n            # IMDb redirects us upon a successful login.\n            # removed - doesn't happen always?\n            # if r.status_code != 302:\n            #     log.warning('It appears logging in to IMDb was unsuccessful.')\n\n            # try to automatically figure out user_id from watchlist redirect url\n            if not 'user_id' in config:\n                log.verbose('Getting user_id ...')\n                try:\n                    response = sess.get('http://www.imdb.com/list/watchlist')\n                except requests.RequestException as e:\n                    log.error('Error retrieving user ID from imdb: %s' % e.message)\n                    user_id = ''\n                else:\n                    log.debug('redirected to %s' % response.url)\n                    user_id = response.url.split('/')[-2]\n                if re.match(USER_ID_RE, user_id):\n                    config['user_id'] = user_id\n                else:\n                    raise plugin.PluginError('Couldn\\'t figure out user_id, please configure it manually.')\n\n        if not 'user_id' in config:\n            raise plugin.PluginError('Configuration option `user_id` required.')\n\n        log.verbose('Retrieving list %s ...' % config['list'])\n\n        # Get the imdb list in csv format\n        try:\n            url = 'http://www.imdb.com/list/export'\n            params = {'list_id': config['list'], 'author_id': config['user_id']}\n            log.debug('Requesting %s' % url)\n            opener = sess.get(url, params=params)\n            mime_type = parse_header(opener.headers['content-type'])[0]\n            log.debug('mime_type: %s' % mime_type)\n            if mime_type != 'text/csv':\n                raise plugin.PluginError('Didn\\'t get CSV export as response. Probably specified list `%s` '\n                                         'does not exist.' % config['list'])\n            csv_rows = csv.reader(opener.iter_lines())\n        except requests.RequestException as e:\n            raise plugin.PluginError('Unable to get imdb list: %s' % e.message)\n\n        # Create an Entry for each movie in the list\n        entries = []\n        for row in csv_rows:\n            if not row or row[0] == 'position':\n                # Don't use blank rows or the headings row\n                continue\n            try:\n                title = decode_html(row[5]).decode('utf-8')\n                entries.append(Entry(title=title, url=make_url(row[1]), imdb_id=row[1], imdb_name=title))\n            except IndexError:\n                log.critical('IndexError! Unable to handle row: %s' % row)\n        return entries\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(ImdbList, 'imdb_list', api_ver=2)\n", "path": "flexget/plugins/input/imdb_list.py"}], "after_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nimport logging\nimport feedparser\nimport re\nfrom cgi import parse_header\n\nfrom flexget import plugin\nfrom flexget.event import event\nfrom flexget.utils import requests\nfrom flexget.utils.imdb import make_url, extract_id\nfrom flexget.utils.cached_input import cached\nfrom flexget.utils.tools import decode_html\nfrom flexget.entry import Entry\nfrom flexget.utils.soup import get_soup\n\nlog = logging.getLogger('imdb_list')\n\nUSER_ID_RE = r'^ur\\d{7,8}$'\n\n\nclass ImdbList(object):\n    \"\"\"\"Creates an entry for each movie in your imdb list.\"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'user_id': {\n                'type': 'string',\n                'pattern': USER_ID_RE,\n                'error_pattern': 'user_id must be in the form urXXXXXXX'\n            },\n            'username': {'type': 'string'},\n            'password': {'type': 'string'},\n            'list': {'type': 'string'}\n        },\n        'required': ['list'],\n        'additionalProperties': False\n    }\n\n    @cached('imdb_list', persist='2 hours')\n    def on_task_input(self, task, config):\n        sess = requests.Session()\n        if config.get('username') and config.get('password'):\n\n            log.verbose('Logging in ...')\n\n            # Log in to imdb with our handler\n            params = {'login': config['username'], 'password': config['password']}\n            try:\n                # First get the login page so we can get the hidden input value\n                soup = get_soup(sess.get('https://secure.imdb.com/register-imdb/login').content)\n\n                # Fix for bs4 bug. see #2313 and github#118\n                auxsoup = soup.find('div', id='nb20').next_sibling.next_sibling\n                tag = auxsoup.find('input', attrs={'name': '49e6c'})\n                if tag:\n                    params['49e6c'] = tag['value']\n                else:\n                    log.warning('Unable to find required info for imdb login, maybe their login method has changed.')\n                # Now we do the actual login with appropriate parameters\n                r = sess.post('https://secure.imdb.com/register-imdb/login', data=params, raise_status=False)\n            except requests.RequestException as e:\n                raise plugin.PluginError('Unable to login to imdb: %s' % e.message)\n\n            # IMDb redirects us upon a successful login.\n            # removed - doesn't happen always?\n            # if r.status_code != 302:\n            #     log.warning('It appears logging in to IMDb was unsuccessful.')\n\n            # try to automatically figure out user_id from watchlist redirect url\n            if not 'user_id' in config:\n                log.verbose('Getting user_id ...')\n                try:\n                    response = sess.get('http://www.imdb.com/list/watchlist')\n                except requests.RequestException as e:\n                    log.error('Error retrieving user ID from imdb: %s' % e.message)\n                    user_id = ''\n                else:\n                    log.debug('redirected to %s' % response.url)\n                    user_id = response.url.split('/')[-2]\n                if re.match(USER_ID_RE, user_id):\n                    config['user_id'] = user_id\n                else:\n                    raise plugin.PluginError('Couldn\\'t figure out user_id, please configure it manually.')\n\n        if not 'user_id' in config:\n            raise plugin.PluginError('Configuration option `user_id` required.')\n\n        log.verbose('Retrieving list %s ...' % config['list'])\n\n        # Get the imdb list in RSS format\n        try:\n            if config['list'] in ['watchlist', 'ratings', 'checkins']:\n                url = 'http://rss.imdb.com/user/%s/%s' % (config['user_id'], config['list'])\n            else:\n                url = 'http://rss.imdb.com/list/%s' % config['list']\n            log.debug('Requesting %s' % url)\n            try:\n                rss = feedparser.parse(url)\n            except LookupError as e:\n                raise plugin.PluginError('Failed to parse RSS feed for list `%s` correctly: %s' % (config['list'], e))\n        except requests.RequestException as e:\n            raise plugin.PluginError('Unable to get imdb list: %s' % e.message)\n\n        # Create an Entry for each movie in the list\n        entries = []\n        for entry in rss.entries:\n            try:\n                entries.append(Entry(title=entry.title, url=entry.link, imdb_id=extract_id(entry.link), imdb_name=entry.title))\n            except IndexError:\n                log.critical('IndexError! Unable to handle RSS entry: %s' % entry)\n        return entries\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(ImdbList, 'imdb_list', api_ver=2)\n", "path": "flexget/plugins/input/imdb_list.py"}]}