Repository: pymedusa/Medusa

Issue:
"&" In Episode name gets named "&amp;" when processing or renaming.
Medusa Info: | Branch: master
                       Commit: b96b3ee10760ffa03a15a207841a1a2bc65798dd
                       Version: v0.1.19
                       Database: 44.8
Python Version: | 2.7.13 (default, Dec 18 2016, 23:11:11)  [GCC 4.6.4]
SSL Version: | OpenSSL 1.0.2j  26 Sep 2016
OS: | Linux-3.2.40-armv7l-with-glibc2.4
Locale: | en_US.UTF-8

So I have moved from SickRage to Medusa and have a new problem that if a new episode has "&" in the title it gets named "&amp;" when processed.

so for example when...
Modern Family - S09E04 - Sex, Lies & Kickball - 1080p WEB-DL.mkv was processed it was renamed in my windows share as...

Modern Family - S09E04 - Sex, Lies &amp; Kickball - 1080p WEB-DL.mkv

If I show file names in Medusa is still shows as being named "Modern Family - S09E04 - Sex, Lies & Kickball - 1080p WEB-DL.mkv" but still exists as "Modern Family - S09E04 - Sex, Lies &amp; Kickball - 1080p WEB-DL.mkv" in the windows directory.

Preview Rename also wants to change any existing file that contains "&" from my existing collection.

If it makes any difference Medusa is running on my Synology.


Discussion:

Resolving patch:
diff --git a/medusa/indexers/indexer_base.py b/medusa/indexers/indexer_base.py
--- a/medusa/indexers/indexer_base.py
+++ b/medusa/indexers/indexer_base.py
@@ -2,11 +2,9 @@
 
 """Base class for indexer api's."""
 
-import cgi
 import getpass
 import logging
 import os
-import re
 import tempfile
 import time
 import warnings
@@ -181,25 +179,6 @@ def __repr__(self):
         """Indexer representation, returning representation of all shows indexed."""
         return str(self.shows)
 
-    def _clean_data(self, data):  # pylint: disable=no-self-use
-        """Clean up strings.
-
-        Issues corrected:
-        - Replaces &amp; with &
-        - Trailing whitespace
-        """
-        if isinstance(data, basestring):
-            data = data.replace('&amp;', '&')
-            data = data.strip()
-
-            tag_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
-            # Remove well-formed tags
-            no_tags = tag_re.sub('', data)
-            # Clean up anything else by escaping
-            data = cgi.escape(no_tags)
-
-        return data
-
     def _set_item(self, sid, seas, ep, attrib, value):  # pylint: disable=too-many-arguments
         """Create a new episode, creating Show(), Season() and Episode()s as required.
 
diff --git a/medusa/indexers/tvdbv2/tvdbv2_api.py b/medusa/indexers/tvdbv2/tvdbv2_api.py
--- a/medusa/indexers/tvdbv2/tvdbv2_api.py
+++ b/medusa/indexers/tvdbv2/tvdbv2_api.py
@@ -354,11 +354,8 @@ def _parse_episodes(self, tvdb_id, episode_data):
             for k, v in cur_ep.items():
                 k = k.lower()
 
-                if v is not None:
-                    if v and k == 'filename':
-                        v = urljoin(self.config['artwork_prefix'], v)
-                    else:
-                        v = self._clean_data(v)
+                if v and k == 'filename':
+                    v = urljoin(self.config['artwork_prefix'], v)
 
                 self._set_item(tvdb_id, seas_no, ep_no, k, v)
 


Test patch: