We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't log in into myepisodes
When usin the myepisodes plugin you get the warning "Login to myepisodes.com failed, please check your account data or see if the site is down."
It seems that they have changed so you have to access their site with www.myepisodes.com. 

I made a copy of the plugin and changed all the urls to www.myepisodes.com and it worked


--- 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/services/myepisodes.py`
Content:
```
1 from __future__ import unicode_literals, division, absolute_import
2 import logging
3 import urllib
4 import urllib2
5 import re
6 import cookielib
7 from datetime import datetime
8 
9 from sqlalchemy import Column, Integer, String, DateTime
10 
11 from flexget import db_schema
12 from flexget.plugin import register_plugin, DependencyError, PluginWarning
13 
14 try:
15     from flexget.plugins.api_tvdb import lookup_series
16 except ImportError:
17     raise DependencyError(issued_by='myepisodes', missing='api_tvdb',
18                           message='myepisodes requires the `api_tvdb` plugin')
19 
20 
21 log = logging.getLogger('myepisodes')
22 Base = db_schema.versioned_base('myepisodes', 0)
23 
24 
25 class MyEpisodesInfo(Base):
26     __tablename__ = 'myepisodes'
27 
28     id = Column(Integer, primary_key=True)
29     series_name = Column(String, unique=True)
30     myepisodes_id = Column(Integer, unique=True)
31     updated = Column(DateTime)
32 
33     def __init__(self, series_name, myepisodes_id):
34         self.series_name = series_name
35         self.myepisodes_id = myepisodes_id
36         self.updated = datetime.now()
37 
38     def __repr__(self):
39         return '<MyEpisodesInfo(series_name=%s, myepisodes_id=%s)>' % (self.series_name, self.myepisodes_id)
40 
41 
42 class MyEpisodes(object):
43     """
44     Marks a series episode as acquired in your myepisodes.com account.
45 
46     Simple Example:
47 
48     Most shows are recognized automatically from their TVDBname.
49     And of course the plugin needs to know your MyEpisodes.com account details.
50 
51     tasks:
52       tvshows:
53         myepisodes:
54           username: <username>
55           password: <password>
56         series:
57          - human target
58          - chuck
59 
60     Advanced Example:
61 
62     In some cases, the TVDB name is either not unique or won't even be discovered.
63     In that case you need to specify the MyEpisodes id manually using the set plugin.
64 
65     tasks:
66       tvshows:
67         myepisodes:
68           username: <username>
69           password: <password>
70         series:
71          - human target:
72              set:
73                myepisodes_id: 5111
74          - chuck
75 
76     How to find the MyEpisodes id: http://matrixagents.org/screencasts/myep_example-20110507-131555.png
77     """
78 
79     schema = {
80         'type': 'object',
81         'properties': {
82             'username': {'type': 'string'},
83             'password': {'type': 'string'}
84         },
85         'required': ['username', 'password'],
86         'additionalProperties': False
87     }
88 
89     def on_task_exit(self, task, config):
90         """Mark all accepted episodes as acquired on MyEpisodes"""
91         if not task.accepted:
92             # Nothing accepted, don't do anything
93             return
94 
95         username = config['username']
96         password = config['password']
97 
98         cookiejar = cookielib.CookieJar()
99         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
100         baseurl = urllib2.Request('http://myepisodes.com/login.php?')
101         loginparams = urllib.urlencode({'username': username,
102                                         'password': password,
103                                         'action': 'Login'})
104         try:
105             logincon = opener.open(baseurl, loginparams)
106             loginsrc = logincon.read()
107         except urllib2.URLError as e:
108             log.error('Error logging in to myepisodes: %s' % e)
109             return
110 
111         if str(username) not in loginsrc:
112             raise PluginWarning(('Login to myepisodes.com failed, please check '
113                                  'your account data or see if the site is down.'), log)
114 
115         for entry in task.accepted:
116             try:
117                 self.mark_episode(task, entry, opener)
118             except PluginWarning as w:
119                 log.warning(str(w))
120 
121     def lookup_myepisodes_id(self, entry, opener, session):
122         """Populates myepisodes_id field for an entry, and returns the id.
123 
124         Call will also set entry field `myepisode_id` if successful.
125 
126         Return:
127             myepisode id
128 
129         Raises:
130             LookupError if entry does not have field series_name
131         """
132 
133         # Don't need to look it up if we already have it.
134         if entry.get('myepisodes_id'):
135             return entry['myepisodes_id']
136 
137         if not entry.get('series_name'):
138             raise LookupError('Cannot lookup myepisodes id for entries without series_name')
139         series_name = entry['series_name']
140 
141         # First check if we already have a myepisodes id stored for this series
142         myepisodes_info = session.query(MyEpisodesInfo).\
143             filter(MyEpisodesInfo.series_name == series_name.lower()).first()
144         if myepisodes_info:
145             entry['myepisodes_id'] = myepisodes_info.myepisodes_id
146             return myepisodes_info.myepisodes_id
147 
148         # Get the series name from thetvdb to increase match chance on myepisodes
149         if entry.get('tvdb_series_name'):
150             query_name = entry['tvdb_series_name']
151         else:
152             try:
153                 series = lookup_series(name=series_name, tvdb_id=entry.get('tvdb_id'))
154                 query_name = series.seriesname
155             except LookupError as e:
156                 log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)
157                 query_name = series_name
158 
159         baseurl = urllib2.Request('http://myepisodes.com/search.php?')
160         params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})
161         try:
162             con = opener.open(baseurl, params)
163             txt = con.read()
164         except urllib2.URLError as e:
165             log.error('Error searching for myepisodes id: %s' % e)
166 
167         matchObj = re.search(r'&showid=([0-9]*)">' + query_name + '</a>', txt, re.MULTILINE | re.IGNORECASE)
168         if matchObj:
169             myepisodes_id = matchObj.group(1)
170             db_item = session.query(MyEpisodesInfo).filter(MyEpisodesInfo.myepisodes_id == myepisodes_id).first()
171             if db_item:
172                 log.info('Changing name to `%s` for series with myepisodes_id %s' %
173                     (series_name.lower(), myepisodes_id))
174                 db_item.series_name = series_name.lower()
175             else:
176                 session.add(MyEpisodesInfo(series_name.lower(), myepisodes_id))
177             entry['myepisodes_id'] = myepisodes_id
178             return myepisodes_id
179 
180     def mark_episode(self, task, entry, opener):
181         """Mark episode as acquired.
182 
183         Required entry fields:
184             - series_name
185             - series_season
186             - series_episode
187 
188         Raises:
189             PluginWarning if operation fails
190         """
191 
192         if 'series_season' not in entry or 'series_episode' not in entry or 'series_name' not in entry:
193             raise PluginWarning(
194                 'Can\'t mark entry `%s` in myepisodes without series_season, series_episode and series_name fields' %
195                 entry['title'], log)
196 
197         if not self.lookup_myepisodes_id(entry, opener, session=task.session):
198             raise PluginWarning('Couldn\'t get myepisodes id for `%s`' % entry['title'], log)
199 
200         myepisodes_id = entry['myepisodes_id']
201         season = entry['series_season']
202         episode = entry['series_episode']
203 
204         if task.manager.options.test:
205             log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))
206         else:
207             baseurl2 = urllib2.Request(
208                 'http://myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %
209                 (myepisodes_id, season, episode))
210             opener.open(baseurl2)
211             log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))
212 
213 
214 register_plugin(MyEpisodes, 'myepisodes', api_ver=2)
215
```
--- 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/services/myepisodes.py b/flexget/plugins/services/myepisodes.py
--- a/flexget/plugins/services/myepisodes.py
+++ b/flexget/plugins/services/myepisodes.py
@@ -97,7 +97,7 @@
 
         cookiejar = cookielib.CookieJar()
         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
-        baseurl = urllib2.Request('http://myepisodes.com/login.php?')
+        baseurl = urllib2.Request('http://www.myepisodes.com/login.php?')
         loginparams = urllib.urlencode({'username': username,
                                         'password': password,
                                         'action': 'Login'})
@@ -156,7 +156,7 @@
                 log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)
                 query_name = series_name
 
-        baseurl = urllib2.Request('http://myepisodes.com/search.php?')
+        baseurl = urllib2.Request('http://www.myepisodes.com/search.php?')
         params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})
         try:
             con = opener.open(baseurl, params)
@@ -205,7 +205,7 @@
             log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))
         else:
             baseurl2 = urllib2.Request(
-                'http://myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %
+                'http://www.myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %
                 (myepisodes_id, season, episode))
             opener.open(baseurl2)
             log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))

{"golden_diff": "diff --git a/flexget/plugins/services/myepisodes.py b/flexget/plugins/services/myepisodes.py\n--- a/flexget/plugins/services/myepisodes.py\n+++ b/flexget/plugins/services/myepisodes.py\n@@ -97,7 +97,7 @@\n \n         cookiejar = cookielib.CookieJar()\n         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))\n-        baseurl = urllib2.Request('http://myepisodes.com/login.php?')\n+        baseurl = urllib2.Request('http://www.myepisodes.com/login.php?')\n         loginparams = urllib.urlencode({'username': username,\n                                         'password': password,\n                                         'action': 'Login'})\n@@ -156,7 +156,7 @@\n                 log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)\n                 query_name = series_name\n \n-        baseurl = urllib2.Request('http://myepisodes.com/search.php?')\n+        baseurl = urllib2.Request('http://www.myepisodes.com/search.php?')\n         params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})\n         try:\n             con = opener.open(baseurl, params)\n@@ -205,7 +205,7 @@\n             log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n         else:\n             baseurl2 = urllib2.Request(\n-                'http://myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %\n+                'http://www.myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %\n                 (myepisodes_id, season, episode))\n             opener.open(baseurl2)\n             log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n", "issue": "Can't log in into myepisodes\nWhen usin the myepisodes plugin you get the warning \"Login to myepisodes.com failed, please check your account data or see if the site is down.\"\nIt seems that they have changed so you have to access their site with www.myepisodes.com. \n\nI made a copy of the plugin and changed all the urls to www.myepisodes.com and it worked\n\n", "before_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nimport logging\nimport urllib\nimport urllib2\nimport re\nimport cookielib\nfrom datetime import datetime\n\nfrom sqlalchemy import Column, Integer, String, DateTime\n\nfrom flexget import db_schema\nfrom flexget.plugin import register_plugin, DependencyError, PluginWarning\n\ntry:\n    from flexget.plugins.api_tvdb import lookup_series\nexcept ImportError:\n    raise DependencyError(issued_by='myepisodes', missing='api_tvdb',\n                          message='myepisodes requires the `api_tvdb` plugin')\n\n\nlog = logging.getLogger('myepisodes')\nBase = db_schema.versioned_base('myepisodes', 0)\n\n\nclass MyEpisodesInfo(Base):\n    __tablename__ = 'myepisodes'\n\n    id = Column(Integer, primary_key=True)\n    series_name = Column(String, unique=True)\n    myepisodes_id = Column(Integer, unique=True)\n    updated = Column(DateTime)\n\n    def __init__(self, series_name, myepisodes_id):\n        self.series_name = series_name\n        self.myepisodes_id = myepisodes_id\n        self.updated = datetime.now()\n\n    def __repr__(self):\n        return '<MyEpisodesInfo(series_name=%s, myepisodes_id=%s)>' % (self.series_name, self.myepisodes_id)\n\n\nclass MyEpisodes(object):\n    \"\"\"\n    Marks a series episode as acquired in your myepisodes.com account.\n\n    Simple Example:\n\n    Most shows are recognized automatically from their TVDBname.\n    And of course the plugin needs to know your MyEpisodes.com account details.\n\n    tasks:\n      tvshows:\n        myepisodes:\n          username: <username>\n          password: <password>\n        series:\n         - human target\n         - chuck\n\n    Advanced Example:\n\n    In some cases, the TVDB name is either not unique or won't even be discovered.\n    In that case you need to specify the MyEpisodes id manually using the set plugin.\n\n    tasks:\n      tvshows:\n        myepisodes:\n          username: <username>\n          password: <password>\n        series:\n         - human target:\n             set:\n               myepisodes_id: 5111\n         - chuck\n\n    How to find the MyEpisodes id: http://matrixagents.org/screencasts/myep_example-20110507-131555.png\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'username': {'type': 'string'},\n            'password': {'type': 'string'}\n        },\n        'required': ['username', 'password'],\n        'additionalProperties': False\n    }\n\n    def on_task_exit(self, task, config):\n        \"\"\"Mark all accepted episodes as acquired on MyEpisodes\"\"\"\n        if not task.accepted:\n            # Nothing accepted, don't do anything\n            return\n\n        username = config['username']\n        password = config['password']\n\n        cookiejar = cookielib.CookieJar()\n        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))\n        baseurl = urllib2.Request('http://myepisodes.com/login.php?')\n        loginparams = urllib.urlencode({'username': username,\n                                        'password': password,\n                                        'action': 'Login'})\n        try:\n            logincon = opener.open(baseurl, loginparams)\n            loginsrc = logincon.read()\n        except urllib2.URLError as e:\n            log.error('Error logging in to myepisodes: %s' % e)\n            return\n\n        if str(username) not in loginsrc:\n            raise PluginWarning(('Login to myepisodes.com failed, please check '\n                                 'your account data or see if the site is down.'), log)\n\n        for entry in task.accepted:\n            try:\n                self.mark_episode(task, entry, opener)\n            except PluginWarning as w:\n                log.warning(str(w))\n\n    def lookup_myepisodes_id(self, entry, opener, session):\n        \"\"\"Populates myepisodes_id field for an entry, and returns the id.\n\n        Call will also set entry field `myepisode_id` if successful.\n\n        Return:\n            myepisode id\n\n        Raises:\n            LookupError if entry does not have field series_name\n        \"\"\"\n\n        # Don't need to look it up if we already have it.\n        if entry.get('myepisodes_id'):\n            return entry['myepisodes_id']\n\n        if not entry.get('series_name'):\n            raise LookupError('Cannot lookup myepisodes id for entries without series_name')\n        series_name = entry['series_name']\n\n        # First check if we already have a myepisodes id stored for this series\n        myepisodes_info = session.query(MyEpisodesInfo).\\\n            filter(MyEpisodesInfo.series_name == series_name.lower()).first()\n        if myepisodes_info:\n            entry['myepisodes_id'] = myepisodes_info.myepisodes_id\n            return myepisodes_info.myepisodes_id\n\n        # Get the series name from thetvdb to increase match chance on myepisodes\n        if entry.get('tvdb_series_name'):\n            query_name = entry['tvdb_series_name']\n        else:\n            try:\n                series = lookup_series(name=series_name, tvdb_id=entry.get('tvdb_id'))\n                query_name = series.seriesname\n            except LookupError as e:\n                log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)\n                query_name = series_name\n\n        baseurl = urllib2.Request('http://myepisodes.com/search.php?')\n        params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})\n        try:\n            con = opener.open(baseurl, params)\n            txt = con.read()\n        except urllib2.URLError as e:\n            log.error('Error searching for myepisodes id: %s' % e)\n\n        matchObj = re.search(r'&showid=([0-9]*)\">' + query_name + '</a>', txt, re.MULTILINE | re.IGNORECASE)\n        if matchObj:\n            myepisodes_id = matchObj.group(1)\n            db_item = session.query(MyEpisodesInfo).filter(MyEpisodesInfo.myepisodes_id == myepisodes_id).first()\n            if db_item:\n                log.info('Changing name to `%s` for series with myepisodes_id %s' %\n                    (series_name.lower(), myepisodes_id))\n                db_item.series_name = series_name.lower()\n            else:\n                session.add(MyEpisodesInfo(series_name.lower(), myepisodes_id))\n            entry['myepisodes_id'] = myepisodes_id\n            return myepisodes_id\n\n    def mark_episode(self, task, entry, opener):\n        \"\"\"Mark episode as acquired.\n\n        Required entry fields:\n            - series_name\n            - series_season\n            - series_episode\n\n        Raises:\n            PluginWarning if operation fails\n        \"\"\"\n\n        if 'series_season' not in entry or 'series_episode' not in entry or 'series_name' not in entry:\n            raise PluginWarning(\n                'Can\\'t mark entry `%s` in myepisodes without series_season, series_episode and series_name fields' %\n                entry['title'], log)\n\n        if not self.lookup_myepisodes_id(entry, opener, session=task.session):\n            raise PluginWarning('Couldn\\'t get myepisodes id for `%s`' % entry['title'], log)\n\n        myepisodes_id = entry['myepisodes_id']\n        season = entry['series_season']\n        episode = entry['series_episode']\n\n        if task.manager.options.test:\n            log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n        else:\n            baseurl2 = urllib2.Request(\n                'http://myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %\n                (myepisodes_id, season, episode))\n            opener.open(baseurl2)\n            log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n\n\nregister_plugin(MyEpisodes, 'myepisodes', api_ver=2)\n", "path": "flexget/plugins/services/myepisodes.py"}], "after_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nimport logging\nimport urllib\nimport urllib2\nimport re\nimport cookielib\nfrom datetime import datetime\n\nfrom sqlalchemy import Column, Integer, String, DateTime\n\nfrom flexget import db_schema\nfrom flexget.plugin import register_plugin, DependencyError, PluginWarning\n\ntry:\n    from flexget.plugins.api_tvdb import lookup_series\nexcept ImportError:\n    raise DependencyError(issued_by='myepisodes', missing='api_tvdb',\n                          message='myepisodes requires the `api_tvdb` plugin')\n\n\nlog = logging.getLogger('myepisodes')\nBase = db_schema.versioned_base('myepisodes', 0)\n\n\nclass MyEpisodesInfo(Base):\n    __tablename__ = 'myepisodes'\n\n    id = Column(Integer, primary_key=True)\n    series_name = Column(String, unique=True)\n    myepisodes_id = Column(Integer, unique=True)\n    updated = Column(DateTime)\n\n    def __init__(self, series_name, myepisodes_id):\n        self.series_name = series_name\n        self.myepisodes_id = myepisodes_id\n        self.updated = datetime.now()\n\n    def __repr__(self):\n        return '<MyEpisodesInfo(series_name=%s, myepisodes_id=%s)>' % (self.series_name, self.myepisodes_id)\n\n\nclass MyEpisodes(object):\n    \"\"\"\n    Marks a series episode as acquired in your myepisodes.com account.\n\n    Simple Example:\n\n    Most shows are recognized automatically from their TVDBname.\n    And of course the plugin needs to know your MyEpisodes.com account details.\n\n    tasks:\n      tvshows:\n        myepisodes:\n          username: <username>\n          password: <password>\n        series:\n         - human target\n         - chuck\n\n    Advanced Example:\n\n    In some cases, the TVDB name is either not unique or won't even be discovered.\n    In that case you need to specify the MyEpisodes id manually using the set plugin.\n\n    tasks:\n      tvshows:\n        myepisodes:\n          username: <username>\n          password: <password>\n        series:\n         - human target:\n             set:\n               myepisodes_id: 5111\n         - chuck\n\n    How to find the MyEpisodes id: http://matrixagents.org/screencasts/myep_example-20110507-131555.png\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'username': {'type': 'string'},\n            'password': {'type': 'string'}\n        },\n        'required': ['username', 'password'],\n        'additionalProperties': False\n    }\n\n    def on_task_exit(self, task, config):\n        \"\"\"Mark all accepted episodes as acquired on MyEpisodes\"\"\"\n        if not task.accepted:\n            # Nothing accepted, don't do anything\n            return\n\n        username = config['username']\n        password = config['password']\n\n        cookiejar = cookielib.CookieJar()\n        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))\n        baseurl = urllib2.Request('http://www.myepisodes.com/login.php?')\n        loginparams = urllib.urlencode({'username': username,\n                                        'password': password,\n                                        'action': 'Login'})\n        try:\n            logincon = opener.open(baseurl, loginparams)\n            loginsrc = logincon.read()\n        except urllib2.URLError as e:\n            log.error('Error logging in to myepisodes: %s' % e)\n            return\n\n        if str(username) not in loginsrc:\n            raise PluginWarning(('Login to myepisodes.com failed, please check '\n                                 'your account data or see if the site is down.'), log)\n\n        for entry in task.accepted:\n            try:\n                self.mark_episode(task, entry, opener)\n            except PluginWarning as w:\n                log.warning(str(w))\n\n    def lookup_myepisodes_id(self, entry, opener, session):\n        \"\"\"Populates myepisodes_id field for an entry, and returns the id.\n\n        Call will also set entry field `myepisode_id` if successful.\n\n        Return:\n            myepisode id\n\n        Raises:\n            LookupError if entry does not have field series_name\n        \"\"\"\n\n        # Don't need to look it up if we already have it.\n        if entry.get('myepisodes_id'):\n            return entry['myepisodes_id']\n\n        if not entry.get('series_name'):\n            raise LookupError('Cannot lookup myepisodes id for entries without series_name')\n        series_name = entry['series_name']\n\n        # First check if we already have a myepisodes id stored for this series\n        myepisodes_info = session.query(MyEpisodesInfo).\\\n            filter(MyEpisodesInfo.series_name == series_name.lower()).first()\n        if myepisodes_info:\n            entry['myepisodes_id'] = myepisodes_info.myepisodes_id\n            return myepisodes_info.myepisodes_id\n\n        # Get the series name from thetvdb to increase match chance on myepisodes\n        if entry.get('tvdb_series_name'):\n            query_name = entry['tvdb_series_name']\n        else:\n            try:\n                series = lookup_series(name=series_name, tvdb_id=entry.get('tvdb_id'))\n                query_name = series.seriesname\n            except LookupError as e:\n                log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)\n                query_name = series_name\n\n        baseurl = urllib2.Request('http://www.myepisodes.com/search.php?')\n        params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})\n        try:\n            con = opener.open(baseurl, params)\n            txt = con.read()\n        except urllib2.URLError as e:\n            log.error('Error searching for myepisodes id: %s' % e)\n\n        matchObj = re.search(r'&showid=([0-9]*)\">' + query_name + '</a>', txt, re.MULTILINE | re.IGNORECASE)\n        if matchObj:\n            myepisodes_id = matchObj.group(1)\n            db_item = session.query(MyEpisodesInfo).filter(MyEpisodesInfo.myepisodes_id == myepisodes_id).first()\n            if db_item:\n                log.info('Changing name to `%s` for series with myepisodes_id %s' %\n                    (series_name.lower(), myepisodes_id))\n                db_item.series_name = series_name.lower()\n            else:\n                session.add(MyEpisodesInfo(series_name.lower(), myepisodes_id))\n            entry['myepisodes_id'] = myepisodes_id\n            return myepisodes_id\n\n    def mark_episode(self, task, entry, opener):\n        \"\"\"Mark episode as acquired.\n\n        Required entry fields:\n            - series_name\n            - series_season\n            - series_episode\n\n        Raises:\n            PluginWarning if operation fails\n        \"\"\"\n\n        if 'series_season' not in entry or 'series_episode' not in entry or 'series_name' not in entry:\n            raise PluginWarning(\n                'Can\\'t mark entry `%s` in myepisodes without series_season, series_episode and series_name fields' %\n                entry['title'], log)\n\n        if not self.lookup_myepisodes_id(entry, opener, session=task.session):\n            raise PluginWarning('Couldn\\'t get myepisodes id for `%s`' % entry['title'], log)\n\n        myepisodes_id = entry['myepisodes_id']\n        season = entry['series_season']\n        episode = entry['series_episode']\n\n        if task.manager.options.test:\n            log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n        else:\n            baseurl2 = urllib2.Request(\n                'http://www.myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %\n                (myepisodes_id, season, episode))\n            opener.open(baseurl2)\n            log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))\n\n\nregister_plugin(MyEpisodes, 'myepisodes', api_ver=2)\n", "path": "flexget/plugins/services/myepisodes.py"}]}