Repository: pymedusa/Medusa

Issue:
Medusa deleted episode after 9 for "Dragon Ball Super"
Hello,

**Describe the bug**
Medusa deleted episode after 9 for "Dragon Ball Super" when i use scrapper tvdb (only for this serie)

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'Add shows'
2. Click on 'Add existing show', "Dragon Ball Super" for me
3. choose TVBD2'
4. Scan Files
5. For the season 1, all 14 episodes are found and rename and after episodes 10, 11, 12, 13 and 14 are deleted of my Synology Nas. Same issue for alle 5 seasons and reproduce two times

**Medusa 
 - OS: Synology
 - Medusa Info:	Branch: master
 - Commit: d9c31da063e6c4b4383749e19b27b13693a1b71e
 - Version: 0.3.16
 - Database: 44.15
 - Python Version:	3.5.6 (default, Nov 25 2018, 14:24:15) [GCC 4.7.3 20130102 (prerelease)]
 - SSL Version:	OpenSSL 1.0.2n 7 Dec 2017
 - OS:	Linux-3.10.77-x86_64-with-glibc2.2.5
 - Locale:	en_US.UTF-8

**Debug logs (at least 50 lines):**
https://pastebin.com/1NE7eLVL

**Additional context**
Left : original files
Right : files after rename
https://zupimages.net/up/20/19/7sy5.png


Discussion:
Who could help me ?
What's this folder Path? Renaming file from '/volume1/Videos/TV Series Animes/Dragon Ball Super/Saison 01/@eaDir/Dragon Ball Super_01x1.mkv@SynoResource' to '/volume1/Videos/TV Series Animes/Dragon Ball Super/Saison 01/@eaDir/Dragon Ball Super_01x01_Une récompense pour la paix. À qui reviennent les 100 millions de Zénis.mkv@SynoResource

Why is '@ eaDir' in there? 
Please make sure your folder Structure is clean. `Show/Season 01/show.name.s01e01...mkv`

Then if still na issue. Enabled debug logs and send full logs. 
These folders are created by Synology himself (MediaServer or PhotoStation) It's the Media indexing, thumbnails, ..., like .DS_Store under Mac

```
:/volume1/Videos/TV Series Animes/Dragon Ball Super$ cd \@eaDir/
:/volume1/Videos/TV Series Animes/Dragon Ball Super/@eaDir$ ls -al
total 32
drwxrwxrwx+ 2 root   root  4096 May 24 21:42 .
drwxrwxrwx+ 8 akhlan users 4096 May 24 21:31 ..
-rwxrwxrwx  1 root   root    82 May 23 18:25 Saison 01@SynoResource
-rwxrwxrwx  1 root   root    82 May 24 21:21 Saison 02@SynoResource
-rwxrwxrwx  1 root   root    82 May 24 21:25 Saison 03@SynoResource
-rwxrwxrwx  1 root   root    82 May 24 21:31 Saison 04@SynoResource
-rwxrwxrwx  1 root   root    82 May 24 21:42 Saison 05@SynoResource

:/volume1/Videos/TV Series Animes/Dragon Ball Super/@eaDir$ vi Saison\ 01\@SynoResource 

^@^E^V^G^@^B^@^@Mac OS X        ^@^B^@^@^@  ^@^@^@2^@^@^@ ^@^@^@^B^@^@^@R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
```

I don't think the problem lies with these files.




so...

I have remake the error step by step and i put the debug log here
https://pastebin.com/GNtr5ZgL

Step by step in images

1 - https://zupimages.net/up/20/22/6sga.png
2 - https://zupimages.net/up/20/22/y39z.png
3 - https://zupimages.net/up/20/22/v1x3.png
4 - https://zupimages.net/up/20/22/br36.png
5 - https://zupimages.net/up/20/22/drj3.png
6 - https://zupimages.net/up/20/22/6f94.png

Who have an idea ?
That's not a debug log. That's info
I don't see other log...

```
:/volume1/@appstore/medusa/var/Logs$ ls -al
total 504
drwxrwxrwx 2 sc-medusa medusa   4096 May 24 19:02 .
drwxr-xr-x 5 sc-medusa medusa   4096 May 28 10:07 ..
-rw-rw-rw- 1 sc-medusa medusa 501623 May 28 10:07 application.log
```



Youll have to enable debugging in config - general. And then restart
I had see "Enable Debug" in General but I don't know we had need restart (should be write near Debug switch)

I can't put log in Pastebin, i haven't pro version to put more than 512Ko
https://www.transfernow.net/KirULi052020

Medusa deleted épisodes after 9 when i rename them

There is a bug with the associated files match logic. It will be fixed in the next release.
It's not a simple "bug", i have lost all tv shown in all season after number 9...
Please contact @p0psicles for a full refund.

Resolving patch:
diff --git a/medusa/post_processor.py b/medusa/post_processor.py
--- a/medusa/post_processor.py
+++ b/medusa/post_processor.py
@@ -209,7 +209,7 @@ def list_associated_files(self, file_path, subfolders=False, subtitles_only=Fals
         files = self._search_files(file_path, subfolders=subfolders)
 
         # file path to the video file that is being processed (without extension)
-        processed_file_name = os.path.splitext(os.path.basename(file_path))[0].lower()
+        processed_file_name = os.path.splitext(os.path.basename(file_path))[0].lower() + '.'
 
         processed_names = (processed_file_name,)
         processed_names += tuple((_f for _f in (self._rar_basename(file_path, files),) if _f))
@@ -332,7 +332,7 @@ def _rar_basename(file_path, files):
                            u'Error: {message}'.format(name=rar, message=error), logger.WARNING)
                 continue
             if videofile in content:
-                return os.path.splitext(os.path.basename(rar))[0].lower()
+                return os.path.splitext(os.path.basename(rar))[0].lower() + '.'
 
     def _delete(self, files, associated_files=False):
         """


Test patch: