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

Issue:
Manual rename error
Hi, when I want to manually rename I have this error

**Logs:**
```
2018-07-27 23:00:36 ERROR    Thread_3 :: [b733355] Exception generated: need more than 1 value to unpack
Traceback (most recent call last):
  File "/app/medusa/medusa/server/web/core/base.py", line 259, in async_call
    result = function(**kwargs)
  File "/app/medusa/medusa/server/web/home/handler.py", line 2108, in doRename
    season_no, episode_no = cur_ep.lstrip('s').split('e')
ValueError: need more than 1 value to unpack
```

 - OS: unRAID linuxserver docker
 - Branch: master

Manual rename error
Hi, when I want to manually rename I have this error

**Logs:**
```
2018-07-27 23:00:36 ERROR    Thread_3 :: [b733355] Exception generated: need more than 1 value to unpack
Traceback (most recent call last):
  File "/app/medusa/medusa/server/web/core/base.py", line 259, in async_call
    result = function(**kwargs)
  File "/app/medusa/medusa/server/web/home/handler.py", line 2108, in doRename
    season_no, episode_no = cur_ep.lstrip('s').split('e')
ValueError: need more than 1 value to unpack
```

 - OS: unRAID linuxserver docker
 - Branch: master



Discussion:

Resolving patch:
diff --git a/medusa/common.py b/medusa/common.py
--- a/medusa/common.py
+++ b/medusa/common.py
@@ -48,7 +48,7 @@
 # To enable, set SPOOF_USER_AGENT = True
 SPOOF_USER_AGENT = False
 INSTANCE_ID = str(uuid.uuid1())
-VERSION = '0.2.7'
+VERSION = '0.2.8'
 USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
     version=VERSION, system=platform.system(), release=platform.release(),
     instance=INSTANCE_ID)


Test patch:
Repository: pymedusa/Medusa

Issue:
Manual rename error
Hi, when I want to manually rename I have this error

**Logs:**
```
2018-07-27 23:00:36 ERROR    Thread_3 :: [b733355] Exception generated: need more than 1 value to unpack
Traceback (most recent call last):
  File "/app/medusa/medusa/server/web/core/base.py", line 259, in async_call
    result = function(**kwargs)
  File "/app/medusa/medusa/server/web/home/handler.py", line 2108, in doRename
    season_no, episode_no = cur_ep.lstrip('s').split('e')
ValueError: need more than 1 value to unpack
```

 - OS: unRAID linuxserver docker
 - Branch: master



Discussion:

Resolving patch:
diff --git a/medusa/common.py b/medusa/common.py
--- a/medusa/common.py
+++ b/medusa/common.py
@@ -48,7 +48,7 @@
 # To enable, set SPOOF_USER_AGENT = True
 SPOOF_USER_AGENT = False
 INSTANCE_ID = str(uuid.uuid1())
-VERSION = '0.2.7'
+VERSION = '0.2.8'
 USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
     version=VERSION, system=platform.system(), release=platform.release(),
     instance=INSTANCE_ID)


Test patch:
Repository: pymedusa/Medusa

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

### INFO
**Python Version**: `2.7.9 (default, Sep 17 2016, 20:26:04) [GCC 4.9.2]`
**Operating System**: `Linux-4.9.35-v7+-armv7l-with-debian-8.0`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@ada014890c068092fdc1580937eb38f2e1ab5514
**Link to Log**: https://gist.github.com/ddc709ec18572a98cb158cf68837b7d4
### ERROR
<pre>
2018-08-12 13:02:35 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [TvChaosUK] :: [ada0148] Failed parsing provider.
Traceback (most recent call last):
  File "/home/pi/Medusa/<a href="../blob/ada014890c068092fdc1580937eb38f2e1ab5514/medusa/providers/torrent/html/tvchaosuk.py#L150">medusa/providers/torrent/html/tvchaosuk.py</a>", line 150, in parse
    title = self.get_full_title(title)
  File "/home/pi/Medusa/<a href="../blob/ada014890c068092fdc1580937eb38f2e1ab5514/medusa/providers/torrent/html/tvchaosuk.py#L235">medusa/providers/torrent/html/tvchaosuk.py</a>", line 235, in get_full_title
    with BS4Parser(result.text, 'html5lib') as html:
AttributeError: 'NoneType' object has no attribute 'text'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
Provider is currently like this, which may be the cause of this issue.

![image](https://pls.gtfo.accountant/gYNrE.png)


Resolving patch:
diff --git a/medusa/providers/torrent/html/tvchaosuk.py b/medusa/providers/torrent/html/tvchaosuk.py
--- a/medusa/providers/torrent/html/tvchaosuk.py
+++ b/medusa/providers/torrent/html/tvchaosuk.py
@@ -231,8 +231,12 @@ def get_full_title(self, title):
         # Strip trailing 3 dots
         title = title[:-3]
         search_params = {'input': title}
-        result = self.session.get(self.urls['query'], params=search_params)
-        with BS4Parser(result.text, 'html5lib') as html:
+        response = self.session.get(self.urls['query'], params=search_params)
+        if not response or not response.text:
+            log.debug("Couldn't retrieve the full release title")
+            return title
+
+        with BS4Parser(response.text, 'html5lib') as html:
             titles = html('results')
             for item in titles:
                 title = item.text


Test patch:
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: 321285: Multiple entries found in show: Boruto - Naruto Next Generations 

### INFO
**Python Version**: `2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2]`
**Operating System**: `Linux-3.16.0-6-amd64-x86_64-with-debian-8.11`
**Locale**: `UTF-8`
**Branch**: [master](../tree/master)
**Database**: `44.11`
**Commit**: pymedusa/Medusa@f5973b28465246e67465d7d86bdc8aa74d13e659
**Link to Log**: https://gist.github.com/24caae955e057e707616546a2159e039
### ERROR
<pre>
2018-08-04 22:15:19 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [Yggtorrent] :: [f5973b2] 321285: Multiple entries found in show: Boruto - Naruto Next Generations 
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
This is probably caused by the fact that the query uses only the show ID and not the show ID + indexer ID.
https://github.com/pymedusa/Medusa/blob/b7333559c9a747cd3e8b4022c4073757a62b32ed/medusa/tv/series.py#L740-L751

Resolving patch:
diff --git a/medusa/tv/series.py b/medusa/tv/series.py
--- a/medusa/tv/series.py
+++ b/medusa/tv/series.py
@@ -738,15 +738,26 @@ def get_episode(self, season=None, episode=None, filepath=None, no_create=False,
             sql = None
             sql_args = None
             if self.is_anime and absolute_number:
-                sql = b'SELECT season, episode ' \
-                      b'FROM tv_episodes ' \
-                      b'WHERE showid = ? AND absolute_number = ? AND season != 0'
-                sql_args = [self.series_id, absolute_number]
+                sql = (
+                    b'SELECT season, episode '
+                    b'FROM tv_episodes '
+                    b'WHERE indexer = ? '
+                    b'AND showid = ? '
+                    b'AND absolute_number = ? '
+                    b'AND season != 0'
+                )
+                sql_args = [self.indexer, self.series_id, absolute_number]
                 log.debug(u'{id}: Season and episode lookup for {show} using absolute number {absolute}',
                           {'id': self.series_id, 'absolute': absolute_number, 'show': self.name})
             elif air_date:
-                sql = b'SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?'
-                sql_args = [self.series_id, air_date.toordinal()]
+                sql = (
+                    b'SELECT season, episode '
+                    b'FROM tv_episodes '
+                    b'WHERE indexer = ? '
+                    b'AND showid = ? '
+                    b'AND airdate = ?'
+                )
+                sql_args = [self.indexer, self.series_id, air_date.toordinal()]
                 log.debug(u'{id}: Season and episode lookup for {show} using air date {air_date}',
                           {'id': self.series_id, 'air_date': air_date, 'show': self.name})
 


Test patch:
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: ProtocolError: (u'api.broadcasthe.net/', 502, 'Bad Gateway', <httplib.HTTPMessage instance at 0x4f89db20>)

### INFO
**Python Version**: `2.7.9 (default, Sep 17 2016, 20:26:04) [GCC 4.9.2]`
**Operating System**: `Linux-4.9.35-v7+-armv7l-with-debian-8.0`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@3d0f169a1157f206b13c74a4ab46089f14b7c0a9
**Link to Log**: https://gist.github.com/61f8a7743f4ba1fe0809559bf8474365
### ERROR
<pre>
2018-09-23 10:42:29 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [BTN] :: [3d0f169] JSON-RPC protocol error while accessing provider. Error: (u'api.broadcasthe.net/', 502, 'Bad Gateway', <httplib.HTTPMessage instance at 0x4f89db20>)
Traceback (most recent call last):
  File "/home/pi/Medusa/<a href="../blob/3d0f169a1157f206b13c74a4ab46089f14b7c0a9/medusa/providers/torrent/json/btn.py#L274">medusa/providers/torrent/json/btn.py</a>", line 274, in _api_call
    int(offset)
  File "/home/pi/Medusa/<a href="../blob/3d0f169a1157f206b13c74a4ab46089f14b7c0a9/ext/jsonrpclib/jsonrpc.py#L650">ext/jsonrpclib/jsonrpc.py</a>", line 650, in __call__
    return self.__send(self.__name, args)
  File "/home/pi/Medusa/<a href="../blob/3d0f169a1157f206b13c74a4ab46089f14b7c0a9/ext/jsonrpclib/jsonrpc.py#L531">ext/jsonrpclib/jsonrpc.py</a>", line 531, in _request
    response = self._run_request(request)
  File "/home/pi/Medusa/<a href="../blob/3d0f169a1157f206b13c74a4ab46089f14b7c0a9/ext/jsonrpclib/jsonrpc.py#L564">ext/jsonrpclib/jsonrpc.py</a>", line 564, in _run_request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/home/pi/Medusa/<a href="../blob/3d0f169a1157f206b13c74a4ab46089f14b7c0a9/ext/jsonrpclib/jsonrpc.py#L387">ext/jsonrpclib/jsonrpc.py</a>", line 387, in single_request
    response.msg)
ProtocolError: (u'api.broadcasthe.net/', 502, 'Bad Gateway', <httplib.HTTPMessage instance at 0x4f89db20>)
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
@sharkykh 

Resolving patch:
diff --git a/medusa/providers/torrent/json/btn.py b/medusa/providers/torrent/json/btn.py
--- a/medusa/providers/torrent/json/btn.py
+++ b/medusa/providers/torrent/json/btn.py
@@ -280,7 +280,7 @@ def _api_call(self, params=None, results_per_page=300, offset=0):
                 log.warning('Incorrect authentication credentials.')
             elif (code, message) == (-32002, 'Call Limit Exceeded'):
                 log.warning('You have exceeded the limit of 150 calls per hour.')
-            elif code in (500, 524):
+            elif code in (500, 502, 524):
                 log.warning('Provider is currently unavailable. Error: {code} {text}',
                             {'code': code, 'text': message})
             else:


Test patch:
Repository: pymedusa/Medusa

Issue:
SabNZBd "Direct Unpack" feature causes post processing failures.
**Describe the bug**
SabNZBd has a (relatively) new feature that will unrar the file as it downloads if it has enough chunks and the disk speed is sufficient.

However, Medusa keeps trying to post-process this even though I have added "\_UNPACK\_" to the sync file extensions (which prepends the folder name of downloads using this feature) and "Wait to process a folder if sync files are present" is enabled.

I have recently migrated from Sickrage, and this didn't used to happen on that platform. 

**To Reproduce**
Steps to reproduce the behavior:
1. Download a file in SABnzbd with "Direct Unpacking" option enabled.
2. Wait for medusa's post-processor to fire as the download is ongoing.
3. See error

**Expected behavior**
Medusa should recognize this as an incomplete download and decline to Post-process

**Medusa (please complete the following information):**
 - OS: [Mac OS 10.13.6]
 - Branch: [master]
 - Commit: [?]

**Logs:**
<details>
```
2018-10-10 23:05:35 WARNING  POSTPROCESSOR :: [4614efc] Processing failed for /Volumes/dvorak.8tb/SABnzbd/tv/_UNPACK_Firefly.S01E12.Objects.in.Space.720p.BluRay.DD5.1.x264-CHOTAB/AmFbpPF7yUvpZsU4zn9FpnffknKitQiqs.mkv: This show isn't in your list, you need to add it before post-processing an episode
```
</details>

**Additional context**
none



Discussion:

Resolving patch:
diff --git a/medusa/process_tv.py b/medusa/process_tv.py
--- a/medusa/process_tv.py
+++ b/medusa/process_tv.py
@@ -241,7 +241,8 @@ def _is_valid_folder(self, path, failed):
             self.missedfiles.append('{0}: Failed download'.format(path))
             return False
 
-        if folder.startswith('_unpack'):
+        # SABnzbd: _UNPACK_, NZBGet: _unpack
+        if folder.startswith(('_UNPACK_', '_unpack')):
             self.log('The directory name indicates that this release is in the process of being unpacked.',
                      logger.DEBUG)
             self.missedfiles.append('{0}: Being unpacked'.format(path))


Test patch:
Repository: pymedusa/Medusa

Issue:
Torrent Client - Synology DS - Wrong file name
**DESCRIPTION**:
Attempting to configure Synology DS as torrent client.  After entering correct details and clicking "test" an error is generated:

> WARNING  Thread_0 :: [0c0a735] Error while testing downloadstation connection: No module named downloadstation_client

**RESOLUTION**:
Rename /opt/medusa/medusa/clients/torrent/download_station_client.py to downloadstation_client.py

**Medusa (please complete the following information):**
 - OS: ubuntu 18.04 server
 - Branch: master
 - Commit: 0c0a73583452f988c518adeafa75ee1f17987bdf 



Discussion:

Resolving patch:
diff --git a/medusa/clients/torrent/download_station_client.py b/medusa/clients/torrent/downloadstation_client.py
similarity index 100%
rename from medusa/clients/torrent/download_station_client.py
rename to medusa/clients/torrent/downloadstation_client.py


Test patch:
diff --git a/tests/test_clients.py b/tests/test_clients.py
--- a/tests/test_clients.py
+++ b/tests/test_clients.py
@@ -3,7 +3,7 @@
 
 import medusa.clients.torrent as sut
 from medusa.clients.torrent import (
-    deluge_client, deluged_client, download_station_client, mlnet_client,
+    deluge_client, deluged_client, downloadstation_client, mlnet_client,
     qbittorrent_client, rtorrent_client, transmission_client, utorrent_client
 )
 import pytest
@@ -19,8 +19,8 @@
         'expected': deluged_client
     },
     {  # p2
-        'client': 'download_station',
-        'expected': download_station_client
+        'client': 'downloadstation',
+        'expected': downloadstation_client
     },
     {  # p3
         'client': 'mlnet',
@@ -74,8 +74,8 @@ def test_get_client_module__non_existent():
         'expected': deluged_client.DelugeDAPI
     },
     {  # p2
-        'client': 'download_station',
-        'expected': download_station_client.DownloadStationAPI
+        'client': 'downloadstation',
+        'expected': downloadstation_client.DownloadStationAPI
     },
     {  # p3
         'client': 'mlnet',
Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: BraceException: {indexerid}: {error}

### INFO
**Python Version**: `2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]`
**Operating System**: `Linux-4.15.0-38-generic-x86_64-with-Ubuntu-16.04-xenial`
**Locale**: `UTF-8`
**Branch**: [master](../tree/master)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@0c0a73583452f988c518adeafa75ee1f17987bdf
**Link to Log**: **No Log available**
### ERROR
<pre>
2018-10-30 03:20:40 ERROR    SHOWQUEUE-REFRESH :: [0c0a735] BraceMessage string formatting failed. Using representation instead.
Traceback (most recent call last):
  File "/home/quickbox/.medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L53">medusa/logger/adapters/style.py</a>", line 53, in __str__
    return self.msg.format(*args)
KeyError: u'indexerid'
Traceback (most recent call last):
  File "/home/quickbox/.medusa/<a href="../blob/0c0a73583452f988c518adeafa75ee1f17987bdf/medusa/logger/adapters/style.py#L60">medusa/logger/adapters/style.py</a>", line 60, in __str__
    raise BraceException(self.msg)
BraceException: {indexerid}: {error}
</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
@@ -1308,7 +1308,7 @@ def make_ep_from_file(self, filepath):
             parse_result = NameParser(series=self, try_indexers=True, parse_method=(
                 'normal', 'anime')[self.is_anime]).parse(filepath)
         except (InvalidNameException, InvalidShowException) as error:
-            log.debug(u'{indexerid}: {error}',
+            log.debug(u'{indexer_id}: {error}',
                       {'indexer_id': self.series_id, 'error': error})
             return None
 


Test patch:
Repository: pymedusa/Medusa

Issue:
Growl not registering
2018-11-10 08:21:42 INFO     CHECKVERSION :: [0c0a735] Checking for updates using GIT

**What you did: Input ip:port to register gowl
**What happened: Nothing!
**What you expected: Successful registration.

**Logs:**
2018-11-10 08:22:04 WARNING Thread_1 :: [0c0a735] GROWL: Unable to send growl to 192.168.1.4:23053 - u"error b'encode() takes exactly 1 argument (2 given)'"
2018-11-10 08:22:04 WARNING Thread_1 :: [0c0a735] GROWL: Unable to send growl to 192.168.1.4:23053 - u"error b'encode() takes exactly 1 argument (2 given)'"

Same IP:port work perfectly in rage/chill.



Discussion:
Can you try develop branch? 
Thanks for the quick reply, @p0psicles .
Same result:

2018-11-10 08:33:20 INFO     CHECKVERSION :: [807c53f] Checking for updates using GIT
2018-11-10 08:33:26 WARNING  Thread_0 :: [807c53f] GROWL: Unable to send growl to 192.168.1.4:23053 - u"Error: 'encode() takes exactly 1 argument (2 given)'"



Ok ill make sure its fixed before next release 

Resolving patch:
diff --git a/medusa/notifiers/growl.py b/medusa/notifiers/growl.py
--- a/medusa/notifiers/growl.py
+++ b/medusa/notifiers/growl.py
@@ -66,7 +66,7 @@ def _send_growl(self, options, message=None):
         if message:
             notice.add_header('Notification-Text', message)
 
-        response = self._send(options['host'], options['port'], notice.encode('utf-8'), options['debug'])
+        response = self._send(options['host'], options['port'], notice.encode(), options['debug'])
         return True if isinstance(response, gntp.core.GNTPOK) else False
 
     @staticmethod
@@ -181,7 +181,7 @@ def _sendRegistration(self, host=None, password=None):
             register.set_password(opts['password'])
 
         try:
-            return self._send(opts['host'], opts['port'], register.encode('utf-8'), opts['debug'])
+            return self._send(opts['host'], opts['port'], register.encode(), opts['debug'])
         except Exception as error:
             log.warning(
                 u'GROWL: Unable to send growl to {host}:{port} - {msg!r}',


Test patch:
Repository: pymedusa/Medusa

Issue:
Guessit bug
```
➜  medusa git:(feature/vueify-home) ✗ python2 ./tests/report_guessit.py "Rugrats Season 1/Rugrats - 01x01 - Tommy's First Birthday[JM].avi"
# guessit: 3.0.3  rebulk: 1.0.0
? Rugrats Season 1/Rugrats - 01x01 - Tommy's First Birthday[JM].avi
: season: 1
  episode: 1
  title: Tommy's First Birthday
  release_group: JM
  container: avi
  mimetype: video/x-msvideo
  type: episode
  parsing_time: 0.125710010529
```
```
➜  medusa git:(feature/vueify-home) ✗ guessit "Rugrats Season 1/Rugrats - 01x01 - Tommy's First Birthday[JM].avi"
For: Rugrats Season 1/Rugrats - 01x01 - Tommy's First Birthday[JM].avi
GuessIt found: {
    "title": "Rugrats",
    "season": 1,
    "episode": 1,
    "episode_title": "Tommy's First Birthday",
    "release_group": "JM",
    "container": "avi",
    "mimetype": "video/x-msvideo",
    "type": "episode"
}
```


Discussion:

Resolving patch:
diff --git a/medusa/name_parser/rules/rules.py b/medusa/name_parser/rules/rules.py
--- a/medusa/name_parser/rules/rules.py
+++ b/medusa/name_parser/rules/rules.py
@@ -1083,13 +1083,20 @@ def when(self, matches, context):
             second_part = fileparts[parts_len - 2].value
             if self.ends_with_digit.search(second_part):
                 title = matches.named('title')
-                if not title or second_part.startswith(title[0].value):
+                if not title:
                     episode_title[0].name = 'title'
                     to_append = episode_title
-                    to_remove = title
-
+                    to_remove = None
                     return to_remove, to_append
 
+                if second_part.startswith(title[0].value):
+                    season = matches.named('season')
+                    if season and not second_part.endswith(season[-1].initiator.value):
+                        episode_title[0].name = 'title'
+                        to_append = episode_title
+                        to_remove = title
+                        return to_remove, to_append
+
 
 class FixMultipleSources(Rule):
     """Fix multiple sources.


Test patch:
diff --git a/tests/test_guessit.yml b/tests/test_guessit.yml
--- a/tests/test_guessit.yml
+++ b/tests/test_guessit.yml
@@ -4310,6 +4310,16 @@
   mimetype: video/x-matroska
   type: episode
 
+? Rugrats Season 1/Rugrats - 01x01 - Tommy's First Birthday[JM].avi
+: title: Rugrats
+  season: 1
+  episode: 1
+  episode_title: Tommy's First Birthday
+  release_group: JM
+  container: avi
+  mimetype: video/avi
+  type: episode
+
 ? shes.gotta.have.it.s01e08.720p.web.x264-strife.mkv
 : title: shes gotta have it
   season: 1