Repository: pymedusa/Medusa

Issue:
manual PP deletes subs I just dowloaded manually
I think that happened several times

I went to "dowload subtitles in the PP folder"
I download 2 subs for the 2 shows I am proposed and then click "Manual PP"

and I just got that:
```
Postprocessing results
Processing folder /home/nicoleoca/Downloads/AutoDL
Feature 'postpone post-processing if no subtitle available' is enabled
PostProcessing Path: /home/nicoleoca/Downloads/AutoDL
PostProcessing Dirs: [u'The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]']
PostProcessing Files: []
PostProcessing VideoFiles: []
PostProcessing RarContent: 
PostProcessing VideoInRar: 
Processing folder The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]
Processing folder /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]
Found unwanted files: [u'the.wire.s03e09.1080p.bluray.x264-rovers.en.srt', u'the.wire.s03e12.1080p.bluray.x264-rovers.en.srt']
Found subtitles associated. Continuing the post-process of this file: the.wire.s03e09.1080p.bluray.x264-rovers.mkv
Found the following associated files for /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.mkv: [u'/home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.en.srt', u'/home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e12.1080p.bluray.x264-rovers.en.srt']
Processing /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.mkv (Torrent)
Retrieving episode object for The Wire S03E09
The episode file has a quality in it, using that: 1080p BluRay
This episode was snatched last and isn't processed yet, processing now
This episode is a priority download: True
There is no existing file so there's no worries about replacing it
This download is marked a priority download so I'm going to replace an existing file if I find one
Found release name the.wire.s03e09.1080p.bluray.x264-rovers
Destination folder for this episode: /media/media/TV Shows/The Wire/Season 03
Found the following associated files for /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.mkv: [u'/home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.en.srt', u'/home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e12.1080p.bluray.x264-rovers.en.srt']
Moving file from /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.mkv to /media/media/TV Shows/The Wire/Season 03/The.Wire.S03E09.1080p.BluRay.x264-ROVERS.mkv 
Moving file from /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.en.srt to /media/media/TV Shows/The Wire/Season 03/The.Wire.S03E09.1080p.BluRay.x264-ROVERS.en.srt 
Moving file from /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e12.1080p.bluray.x264-rovers.en.srt to /media/media/TV Shows/The Wire/Season 03/The.Wire.S03E09.1080p.BluRay.x264-ROVERS.en.srt 
Processing succeeded for /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e09.1080p.bluray.x264-rovers.mkv
No subtitles associated. Postponing the post-process of this file: the.wire.s03e12.1080p.bluray.x264-rovers.mkv
Successfully processed
```

S03E09 is OK but please see S03E12
also I don't get why they don't face the same behaviour

full debug logs:
https://gist.github.com/NicoLeOca/b5667d317957cb4278d5bdf77306ea5d

@medariox can you help please?
subtitles settings in on english subs only
and:
![image](https://cloud.githubusercontent.com/assets/9487685/20536416/42731f9e-b0e9-11e6-937c-c9b5edfad4d7.png)



Discussion:
@NicoLeOca 

Here it shows it was moved:
`Moving file from /home/nicoleoca/Downloads/AutoDL/The.Wire.S03.1080p.BluRay.x264-ROVERS[rartv]/the.wire.s03e12.1080p.bluray.x264-rovers.en.srt to /media/media/TV Shows/The Wire/Season 03/The.Wire.S03E09.1080p.BluRay.x264-ROVERS.en.srt`
@fernandog 
so somehow it gets renamed?
@nicoleoca
send a screenshot of the files inside the folder
source:
![image](https://cloud.githubusercontent.com/assets/9487685/20536912/53024ef0-b0eb-11e6-82c6-2de88c6ae7fb.png)
don't bother about the ignore file, that's couchpotato

destination:
![image](https://cloud.githubusercontent.com/assets/9487685/20536895/3d6b724c-b0eb-11e6-9fa2-953fa1158a0a.png)

@NicoLeOca that unknown.ignore i bet is the subtitle! please open the file

do you have a different folder for series and movies?
so CP only check movies folder and medusa only check series folder?
no, I got the same folder for both deluge and nzbget for finished dl

here is the content of the file:
This file is from CouchPotato
It has marked this release as "unknown"
This file hides the release from the renamer
Remove it if you want it to be renamed (again, or at least let it try again)

@NicoLeOca so how do you know medusa that deleted and not CP ?
I don't. except that there is nothing in CP logs

also you pointed out yourself that Medusa renamed subs S03E12*.srt into S03E09*.srt
that where the issue is
though there is nothing in the logs to explain it


Resolving patch:
diff --git a/medusa/post_processor.py b/medusa/post_processor.py
--- a/medusa/post_processor.py
+++ b/medusa/post_processor.py
@@ -205,14 +205,15 @@ def list_associated_files(self, file_path, base_name_only=False, subtitles_only=
 
             file_name = os.path.basename(found_file).lower()
 
-            if is_subtitle(found_file):
-                code = file_name.rsplit('.', 2)[1].replace('_', '-')
-                language = from_code(code, unknown='') or from_ietf_code(code, unknown='und')
-                if language:
-                    filelist.append(found_file)
-
-            # if there's no difference in the filename add it to the filelist
-            elif file_name.startswith(processed_file_name):
+            if file_name.startswith(processed_file_name):
+
+                # only add subtitles with valid languages to the list
+                if is_subtitle(found_file):
+                    code = file_name.rsplit('.', 2)[1].replace('_', '-')
+                    language = from_code(code, unknown='') or from_ietf_code(code, unknown='und')
+                    if not language:
+                        continue
+
                 filelist.append(found_file)
 
         file_path_list = []


Test patch: