internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pymedusa/Medusa

Issue:
Failed to edit groups & required words
**Describe the bug**
When I try to edit groups or required words, nothing happen and I got an error 500.

**Screenshots**

![firefox_2019-07-09_14-13-02](https://user-images.githubusercontent.com/12187295/60894908-e8a37800-a263-11e9-8c69-79998dd22513.png)
![firefox_2019-07-09_14-13-31](https://user-images.githubusercontent.com/12187295/60894909-e93c0e80-a263-11e9-8025-9415126c326c.png)
![firefox_2019-07-09_16-05-24](https://user-images.githubusercontent.com/12187295/60894910-e93c0e80-a263-11e9-9af8-523b76d1a9de.png)

**Medusa (please complete the following information):**
 - OS: Linux-4.19.50-v7+-armv7l-with-debian-10.0
 - Branch: develop
 - Commit: b07e3b5d9d98e86c2499a17790f7d8d1c636fb6f
 - Python version: 3.7.3 (default, Apr  3 2019, 05:39:12)  [GCC 8.2.0]
 - Database version: 44.14






Discussion:

Resolving patch:
diff --git a/medusa/tv/series.py b/medusa/tv/series.py
--- a/medusa/tv/series.py
+++ b/medusa/tv/series.py
@@ -626,13 +626,13 @@ def blacklist(self):
         return bw_list.blacklist
 
     @blacklist.setter
-    def blacklist(self, value):
+    def blacklist(self, group_names):
         """
         Set the anime's blacklisted release groups.
 
-        :param value: A list of blacklist release groups.
+        :param group_names: A list of blacklist release group names.
         """
-        self.release_groups.set_black_keywords(short_group_names([v['name'] for v in value]))
+        self.release_groups.set_black_keywords(short_group_names(group_names))
 
     @property
     def whitelist(self):
@@ -641,13 +641,13 @@ def whitelist(self):
         return bw_list.whitelist
 
     @whitelist.setter
-    def whitelist(self, value):
+    def whitelist(self, group_names):
         """
         Set the anime's whitelisted release groups.
 
-        :param value: A list of whitelist release groups.
+        :param group_names: A list of whitelist release group names.
         """
-        self.release_groups.set_white_keywords(short_group_names([v['name'] for v in value]))
+        self.release_groups.set_white_keywords(short_group_names(group_names))
 
     @staticmethod
     def normalize_status(series_status):


Test patch:
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: qBittorrent: Unable to set priority for Torrent

### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]`
**Operating System**: `Windows-10-10.0.18362-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.14`
**Commit**: pymedusa/Medusa@d0c136d7a528a471b51676140bd35d24d97f65c6
**Link to Log**: **No Log available**
### ERROR
<pre>
2019-12-29 19:19:49 ERROR    SNATCHQUEUE-SNATCH-161511 :: [d0c136d] qBittorrent: Unable to set priority for Torrent
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

Resolving patch:
diff --git a/medusa/clients/torrent/qbittorrent.py b/medusa/clients/torrent/qbittorrent.py
--- a/medusa/clients/torrent/qbittorrent.py
+++ b/medusa/clients/torrent/qbittorrent.py
@@ -198,7 +198,7 @@ def _set_torrent_priority(self, result):
         }
         ok = self._request(method='post', data=data, cookies=self.session.cookies)
 
-        if self.response.status_code == 403:
+        if self.response.status_code == (409 if self.api >= (2, 0, 0) else 403):
             log.info('{name}: Unable to set torrent priority because torrent queueing'
                      ' is disabled in {name} settings.', {'name': self.name})
             ok = True


Test patch:
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: TypeError: backlogShow() got an unexpected keyword argument 'showslug'

### INFO
**Python Version**: `3.6.8 (default, Feb 13 2019, 20:48:47) [GCC 4.7.3 20130102 (prerelease)]`
**Operating System**: `Linux-3.10.35-x86_64-with-glibc2.2.5`
**Locale**: `UTF-8`
**Branch**: [master](../tree/master)
**Database**: `44.17`
**Commit**: pymedusa/Medusa@b21beeb3be5c7e1dec8cbe4bfc13b565b1e1a0b9
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-02-12 06:53:49 ERROR    Thread_13 :: [b21beeb] Exception generated: backlogShow() got an unexpected keyword argument 'showslug'
Traceback (most recent call last):
  File "/volume1/@appstore/medusa/var/Medusa/<a href="../blob/b21beeb3be5c7e1dec8cbe4bfc13b565b1e1a0b9/medusa/server/web/core/base.py#L252">medusa/server/web/core/base.py</a>", line 252, in async_call
    result = function(**kwargs)
TypeError: backlogShow() got an unexpected keyword argument 'showslug'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
I can also generate this after going to the 'Backlog Overview' page. and clicking 'Force Backlog' on any show.
Tnx I'll fix it

### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-7-6.1.7601-SP1`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.17`
**Commit**: pymedusa/Medusa@b21beeb3be5c7e1dec8cbe4bfc13b565b1e1a0b9
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-02-12 18:20:03 ERROR    Thread_7 :: [b21beeb] Exception generated: backlogShow() got an unexpected keyword argument 'showslug'
Traceback (most recent call last):
  File "C:\Medusa\Medusa\<a href="../blob/b21beeb3be5c7e1dec8cbe4bfc13b565b1e1a0b9/medusa/server/web/core/base.py#L252">medusa\server\web\core\base.py</a>", line 252, in async_call
    result = function(**kwargs)
TypeError: backlogShow() got an unexpected keyword argument 'showslug'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


Resolving patch:
diff --git a/medusa/server/web/manage/handler.py b/medusa/server/web/manage/handler.py
--- a/medusa/server/web/manage/handler.py
+++ b/medusa/server/web/manage/handler.py
@@ -369,9 +369,9 @@ def subtitleMissedPP(self):
         return t.render(releases_in_pp=app.RELEASES_IN_PP,
                         controller='manage', action='subtitleMissedPP')
 
-    def backlogShow(self, indexername, seriesid):
-        indexer_id = indexer_name_to_id(indexername)
-        series_obj = Show.find_by_id(app.showList, indexer_id, seriesid)
+    def backlogShow(self, showslug):
+        identifier = SeriesIdentifier.from_slug(showslug)
+        series_obj = Series.find_by_identifier(identifier)
 
         if series_obj:
             app.backlog_search_scheduler.action.search_backlog([series_obj])


Test patch:
Repository: pymedusa/Medusa

Issue:
Nebulance - Cached results for manual search get duplicated
**Describe the bug**
As described in #8787 
Provider Nebulance duplicates cache results.
![image](https://user-images.githubusercontent.com/4103090/110449268-53085d80-80c2-11eb-9345-5589220a2e42.png)

If you need access to the Provider reach out to me in DM on Discord.
I can also provide the cache.db if needed.

PS: Should rarbg already be deduplicated?
![image](https://user-images.githubusercontent.com/4103090/110449560-9793f900-80c2-11eb-980f-cfd0b0a12252.png)



Discussion:
Rarbg is fixed. You need to delete your old cache.

Resolving patch:
diff --git a/medusa/providers/torrent/html/nebulance.py b/medusa/providers/torrent/html/nebulance.py
--- a/medusa/providers/torrent/html/nebulance.py
+++ b/medusa/providers/torrent/html/nebulance.py
@@ -27,6 +27,8 @@
 class NebulanceProvider(TorrentProvider):
     """Nebulance Torrent provider."""
 
+    IDENTIFIER_REGEX = re.compile(r'.+id=([0-9]+)&')
+
     def __init__(self):
         """Initialize the class."""
         super(NebulanceProvider, self).__init__('Nebulance')
@@ -208,5 +210,18 @@ def _check_auth(self):
 
         return True
 
+    @staticmethod
+    def _get_identifier(item):
+        """
+        Return the identifier for the item.
+
+        Cut the apikey from it, as this might change over time.
+            So we'd like to prevent adding duplicates to cache.
+        """
+        url = NebulanceProvider.IDENTIFIER_REGEX.match(item.url)
+        if url:
+            return url.group(1)
+        return item.url
+
 
 provider = NebulanceProvider()


Test patch:
Repository: pymedusa/Medusa

Issue:
Error message "Failed parsing provider" & "list index out of range"
**Describe the bug**
Error message:

`2020-12-05 07:52:25 ERROR    SEARCHQUEUE-BACKLOG-260586 :: [Beyond-HD] :: [ce68da5] Failed parsing provider.
Traceback (most recent call last):
  File "/Applications/Medusa/medusa/providers/torrent/html/beyondhd.py", line 128, in parse
    download_url = urljoin(self.url, cells[2].find('a')['href'])
IndexError: list index out of range`

**Medusa (please complete the following information):**
 - OS: macOS Catalina 10.15,.7
 - Branch: master
 - Commit: ce68da57b3878591f77c21bb2acf28e6a58269fa
 - Python version: 3.8.5
 - Database version: 44.17





Discussion:
Duplicate of https://github.com/pymedusa/Medusa/issues/8786 
We can't fix it until we have access to the provider.

Resolving patch:
diff --git a/medusa/providers/torrent/html/beyondhd.py b/medusa/providers/torrent/html/beyondhd.py
--- a/medusa/providers/torrent/html/beyondhd.py
+++ b/medusa/providers/torrent/html/beyondhd.py
@@ -121,7 +121,7 @@ def parse(self, data, mode):
                 cells = result('td')
 
                 try:
-                    if len(cells) < 2:
+                    if len(cells) < 3:
                         continue
 
                     link = cells[1].find('a')


Test patch:
Repository: pymedusa/Medusa

Issue:
Show appears on schedule page to air "today" even though it airs on different day
**Describe the bug**
The TV Show "Last Week Tonight with John Oliver" appears on schedule page to air "today" even though it airs on different day.

**To Reproduce**
http://x.x.x.x:8081/schedule/

**Expected behavior**
The TV Show "Last Week Tonight with John Oliver" airs on Sunday nights, as shown on the individual show page, and should appear on the schedule page as such instead of always appearing under "Today".

**Screenshots**

![image](https://user-images.githubusercontent.com/2957454/129420471-1da271c3-0a4e-48b4-92f7-c01f35a115a4.png)


**Medusa (please complete the following information):**
Branch: master
Commit: 9b23c72f7e24bf638819e32d72f33e433f9649c4
Version: 0.5.15
Database: 44.18

Python Version: | 3.8.9 (default, Jul 15 2021, 01:46:40) [GCC 10.2.0]
SSL Version: | OpenSSL 1.1.1k 25 Mar 2021
OS: | Linux-5.10.47-x86_64-with-glibc2.2.5
Locale: | en_US.UTF-8
Timezone: | EDT

**Debug logs (at least 50 lines):**
General > Advanced Settings > Enable debug

[https://paste.kodi.tv/rucoceqelu.kodi](url)

**Additional context**
Tried choosing different index, and restarted services,  but issue remains with just the TV Show "Last Week Tonight with John Oliver".



Discussion:

Resolving patch:
diff --git a/medusa/show/coming_episodes.py b/medusa/show/coming_episodes.py
--- a/medusa/show/coming_episodes.py
+++ b/medusa/show/coming_episodes.py
@@ -168,7 +168,8 @@ def get_coming_episodes(categories, sort, group, paused=app.COMING_EPS_DISPLAY_P
             result['qualityValue'] = result['quality']
             result['quality'] = get_quality_string(result['quality'])
             result['airs'] = sbdatetime.sbftime(result['localtime'], t_preset=timeFormat).lstrip('0').replace(' 0', ' ')
-            result['weekday'] = 1 + date.fromordinal(result['airdate']).weekday()
+            # Monday - Sunday (0 - 6)
+            result['weekday'] = date.fromordinal(result['airdate']).weekday()
             result['tvdbid'] = result['indexer_id']
             result['airdate'] = sbdatetime.sbfdate(result['localtime'], d_preset=dateFormat)
             result['localtime'] = result['localtime'].toordinal()


Test patch:
Repository: pymedusa/Medusa

Issue:
Dockerbased Medusa Shows dB-Backup question when checking for update
**Describe the bug**
As the docker image cannot update inside the container there should be no action other than possibly indicating whether a newer version/image is available. If I remember correct this used to be the way,
The latest version of the docker image however shows the question about a dB backup like the normal Medusa installation.
This looks like a regression in detecting whether the app is run in a container. 

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'tools-> check for update‘


**Expected behavior**
Info about possible update, no actions however. 

**Screenshots**
![2F5C6AE7-C723-4310-BF63-DFF7A94A34B3](https://user-images.githubusercontent.com/869637/136696979-dd34ac0d-dcf5-407b-8b4b-b23f38d14d95.jpeg)


**Medusa (please complete the following information):**
- Version: latest medusa:master docker

**Debug logs (at least 50 lines):**
N/A

**Additional context**
N/A



Discussion:
Which docker image are you using? 
pymedusa/medusa:master in the latest version. 

Resolving patch:
diff --git a/medusa/server/api/v2/config.py b/medusa/server/api/v2/config.py
--- a/medusa/server/api/v2/config.py
+++ b/medusa/server/api/v2/config.py
@@ -1142,6 +1142,7 @@ def data_system():
         section_data['runsInDocker'] = bool(app.RUNS_IN_DOCKER)
         section_data['gitRemoteBranches'] = app.GIT_REMOTE_BRANCHES
         section_data['cpuPresets'] = cpu_presets
+        section_data['newestVersionMessage'] = app.NEWEST_VERSION_STRING
 
         section_data['news'] = {}
         section_data['news']['lastRead'] = app.NEWS_LAST_READ


Test patch:
diff --git a/tests/apiv2/test_config.py b/tests/apiv2/test_config.py
--- a/tests/apiv2/test_config.py
+++ b/tests/apiv2/test_config.py
@@ -371,6 +371,7 @@ def memory_usage_mock(*args, **kwargs):
     section_data['appArgs'] = app.MY_ARGS
     section_data['webRoot'] = app.WEB_ROOT
     section_data['runsInDocker'] = bool(app.RUNS_IN_DOCKER)
+    section_data['newestVersionMessage'] = app.NEWEST_VERSION_STRING
     section_data['gitRemoteBranches'] = app.GIT_REMOTE_BRANCHES
     section_data['cpuPresets'] = cpu_presets
Repository: pymedusa/Medusa

Issue:
Same query to same tracker twice
It seems this whould not be happening as per conversation in discord with @p0psicles 

![image](https://user-images.githubusercontent.com/3207791/137594661-ac246f81-d01d-40fb-8e7e-41f63098c97d.png)
![image](https://user-images.githubusercontent.com/3207791/137594675-97de1cfb-70ae-4c5a-9200-f4369b2ed62c.png)



Discussion:

Resolving patch:
diff --git a/medusa/providers/torrent/torznab/torznab.py b/medusa/providers/torrent/torznab/torznab.py
--- a/medusa/providers/torrent/torznab/torznab.py
+++ b/medusa/providers/torrent/torznab/torznab.py
@@ -155,8 +155,8 @@ def search(self, search_strings, age=0, ep_obj=None, force_query=False, manual_s
                 if any(param in search_params for param in itervalues(INDEXERS_PARAM)):
                     break
 
-        # Reprocess but now use force_query = True if there are no results
-        if not results and not force_query:
+        # Reprocess but now use force_query = True if there are no results and we already tried a `tvsearch`
+        if not results and search_params['t'] == 'tvsearch' and not force_query:
             return self.search(search_strings, ep_obj=ep_obj, force_query=True)
 
         return results


Test patch:
Repository: pymedusa/Medusa

Issue:
Update PMS library not working
Hi,

All boxes from Notifications -> Plex Media server are completed with the correct information (token, user, password, server ip:port) and I`m receiving the blue box with (error trying to update plex).
What is surprisingly, when using the Test Plex Media Server, the test is ok even if the Token field is empty.

Error received:
Thread_2 :: [] PLEX: Unauthorized. Please set TOKEN or USERNAME and PASSWORD in Plex settings


Discussion:
I too am receiving the same blue box error. I have redone the set up multiple times and verified and the error remains the same. Test Plex connection works fine. If I have my VPN on, same issue but I have routed past it and even turned it off to no avail. Just noticed it happening the other week (if doing manually, everything still updates automatically when manually post processing or letting the system auto handle). Not sure what the deal is but I haven't seen anything in error logs, debug logs, etc.
Can you in detail describe the steps for me to reproduce this error?
Also you shouldn't need to fill in the `Plex Media Server Auth Token`. Username and password is enough.

Resolving patch:
diff --git a/medusa/server/api/v2/notifications.py b/medusa/server/api/v2/notifications.py
--- a/medusa/server/api/v2/notifications.py
+++ b/medusa/server/api/v2/notifications.py
@@ -38,7 +38,7 @@ def post(self, resource, path_param=None):
             return self._bad_request('You must provide a notifications resource name')
 
         available_resources = (
-            'kodi', 'plexserver', 'plexhome', 'emby', 'nmj', 'nmjv2', 'trakt'
+            'kodi', 'plexserver', 'plexhome', 'emby', 'nmj', 'nmjv2', 'trakt', 'plex'
         )
 
         if resource not in available_resources:
@@ -92,10 +92,10 @@ def emby_update(self):
 
     def plex_update(self):
         """Update plex's show library."""
-        if None is notifiers.plex_notifier.update_library():
+        if not notifiers.plex_notifier.update_library():
             ui.notifications.message(
-                'Library update command sent to Plex Media Server host: {host}'.format(host=', '.join(app.PLEX_SERVER_HOST)))
+                f"Library update command sent to Plex Media Server host: {', '.join(app.PLEX_SERVER_HOST)}")
         else:
-            ui.notifications.error('Unable to contact Plex Media Server host: {host}'.format(host=', '.join(app.PLEX_SERVER_HOST)))
+            ui.notifications.error(f"Unable to contact Plex Media Server host: {', '.join(app.PLEX_SERVER_HOST)}")
 
         return self._created()


Test patch:
Repository: pymedusa/Medusa

Issue:
uTServer handler - Incorrect labeling with special characters
**Describe the bug**
I am using uTorrent Server (uTServer) Labels for file destinations as it's intended but when the show is named with special characters such as question mark or a colon these characters are forwarded to Labels and then uTServer is unable to create these folders instead it creates names like "CCUEZH~B".

**To Reproduce**
Steps to reproduce the behavior:
1. Setup uTServer to use "Append the torrent's label"
2. Setup uTServer as a handler for torrents in Medusa
3. Use "Add label to torrent" with %N in Medusa
4. Add show with special characters in name such as "Case File Nº221: Kabukicho" or "So I'm a Spider, So What?"
5. Let it add to uTServer with labels
6. Wait for creation of folder for these downloads

**Expected behavior**
Creation of proper folder name.

**Intended Behavior**
Instead of labeling the show name (%N), could we append shows name from "Location" resp. path already trimmed of these characters (not a whole path but last leaf) because medusa is expecting it in this folder? I presume this is only reason to label torrents this way.

**Screenshots**
![image](https://user-images.githubusercontent.com/34989648/115951825-2332df00-a4e3-11eb-9c46-3d3e558081d2.png)

![image](https://user-images.githubusercontent.com/34989648/115952234-19aa7680-a4e5-11eb-9704-1fa0b268f5b9.png)

![image](https://user-images.githubusercontent.com/34989648/115951916-963c5580-a4e3-11eb-9c01-7aa5fa2b1150.png)


**Medusa:**
- OS: Synology / Docker Container
- Branch: master
- Commit: fcb5a1969dcd4ea0b6fb4a9debbf60179b0bbf4b
- Version: 0.5.11
- Database: 44.18

**Debug logs:**
Not needed - its not error generated in medusa.

Thanks for all your do regardless!


Discussion:
So I added line into file 
https://github.com/pymedusa/Medusa/blob/3e258d2932fcc90437751efc3c5c4b82d447f3c5/medusa/clients/torrent/utorrent.py#L136-L143

``` 
re.sub("[:'!~?°;$&*#@%]", '', torrent_new_label)
```

It's not a fix and I don't think its for PR but for anyone facing the same, this could help. 
As mentioned I am running it in docker so after this I just mapped new file to 
```
-v ./utorrent.py:/app/medusa/medusa/clients/torrent/utorrent.py
```
Yeah I think a simple sanitation of the label name should be sufficient. I'll create a similar PR.

Resolving patch:
diff --git a/medusa/clients/torrent/utorrent.py b/medusa/clients/torrent/utorrent.py
--- a/medusa/clients/torrent/utorrent.py
+++ b/medusa/clients/torrent/utorrent.py
@@ -133,7 +133,8 @@ def _add_torrent_file(self, result):
 
     def _set_torrent_label(self, result):
         """Send a 'setprop' request to uTorrent to set a label for the torrent, optionally - the show name."""
-        torrent_new_label = result.series.name
+        # Sanitize the name so that utorrent can create the folder.
+        torrent_new_label = re.sub("[:'!~?°;$&*#@%]", '', result.series.name)
 
         if result.series.is_anime and app.TORRENT_LABEL_ANIME:
             label = app.TORRENT_LABEL_ANIME


Test patch:
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: AttributeError: 'NoneType' object has no attribute 'read_from_db'

### INFO
**Python Version**: `3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]`
**Operating System**: `Linux-4.19.0-17-amd64-x86_64-with-debian-10.11`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.19`
**Commit**: pymedusa/Medusa@3b6bbbee3a45f2271b9656f1168f3e3ae2135951
**Link to Log**: **No Log available**
### ERROR
<pre>
2022-01-27 21:39:38 ERROR    TORNADO :: [3b6bbbe] Uncaught exception in APIv2: AttributeError("'NoneType' object has no attribute 'read_from_db'")
Request: GET /api/v2/series/tvmaze1371?detailed=true (83.222.189.195)
Traceback (most recent call last):
  File "/**********/Medusa/ext/tornado/web.py", line 1704, in _execute
    result = await result
  File "/**********/Medusa/ext/tornado/gen.py", line 769, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "/**********/Medusa/medusa/server/api/v2/base.py", line 64, in async_call
    content = yield IOLoop.current().run_in_executor(executor, prepared)
  File "/**********/Medusa/ext/tornado/gen.py", line 762, in run
    value = future.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/**********/Medusa/medusa/server/api/v2/series.py", line 71, in get
    data = series.to_json(detailed=detailed, episodes=episodes)
  File "/**********/Medusa/medusa/tv/series.py", line 2406, in to_json
    data['config']['searchTemplates'] = self.search_templates.to_json()
  File "/**********/Medusa/medusa/tv/series.py", line 2552, in search_templates
    self._search_templates.read_from_db()
AttributeError: 'NoneType' object has no attribute 'read_from_db'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

Resolving patch:
diff --git a/medusa/tv/series.py b/medusa/tv/series.py
--- a/medusa/tv/series.py
+++ b/medusa/tv/series.py
@@ -1635,6 +1635,9 @@ def load_from_indexer(self, tvapi=None):
 
         self._save_externals_to_db()
 
+        # Load search templates
+        self.init_search_templates()
+
     def load_imdb_info(self):
         """Load all required show information from IMDb with ImdbPie."""
         imdb_api = Imdb()


Test patch: