clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
671 stars 176 forks source link

FR: removed files as failed when not replacing existing file in SR #1044

Closed mgaulton closed 5 months ago

mgaulton commented 8 years ago

I'd like the ability to delete the files based on the below log line automagically

[13:59:56] [POSTPROCESS]::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace

13:53:52] [DEBUG]::SICKBEARD: Opening URL: http://localhost:8182/home/postprocess/processEpisode with params: {'nzbName': 'Turn.S03E06.HDTV.x264-FLEET.nzb', 'force': 1, 'quiet': 1, 'failed': '0', 'proc_dir': '/home/@send/TV/Turn', 'delete_on': 1} [13:59:56] [POSTPROCESS]::SICKBEARD: Processing folder /home/@send/TV/Turn [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing Path: /home/@send/TV [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing Dirs: [u'Turn'] [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing Files: [] [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing VideoFiles: [] [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing RarContent: [] [13:59:56] [POSTPROCESS]::SICKBEARD: PostProcessing VideoInRar: [] [13:59:56] [POSTPROCESS]::SICKBEARD: Processing folder Turn [13:59:56] [POSTPROCESS]::SICKBEARD: Processing folder /home/@send/TV/Turn [13:59:56] [POSTPROCESS]::SICKBEARD: Found unwanted files: ['Turn - S03E06 - HDTV x264-FLEET.par2'] [13:59:56] [POSTPROCESS]::SICKBEARD: Processing /home/@send/TV/Turn/Turn.-.S03E06.-.HDTV.x264-FLEET.mkv (Turn.S03E06.HDTV.x264-FLEET.nzb) [13:59:56] [POSTPROCESS]::SICKBEARD: Retrieving episode object for 3x6 [13:59:56] [POSTPROCESS]::SICKBEARD: Snatch history had a quality in it, using that: SDTV [13:59:56] [POSTPROCESS]::SICKBEARD: Is ep a priority download: False [13:59:56] [POSTPROCESS]::SICKBEARD: File /mnt/tv/@@Sorted/TURN/TURN Washington's Spies - S03E06 -.mkv is smaller than /home/@send/TV/Turn/Turn.-.S03E06.-.HDTV.x264-FLEET.mkv [13:59:56] [POSTPROCESS]::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace [13:59:56] [POSTPROCESS]::SICKBEARD: Processing failed for /home/@send/TV/Turn/Turn.-.S03E06.-.HDTV.x264-FLEET.mkv: [13:59:56] [POSTPROCESS]::SICKBEARD: Problem(s) during processing, failed the following files/folders:
[13:59:56] [POSTPROCESS]::SICKBEARD: [/home/@send/TV/Turn/Turn.-.S03E06.-.HDTV.x264-FLEET.mkv : Processing failed: ] [13:59:56] [ERROR]::MAIN: A problem was reported in the /opt/Sick-Beard/autoProcessTV/nzbToMedia.py script. SickBeard: Failed to post-process - Returned log from SickBeard was not as expected.!

labrys commented 8 years ago

@mgaulton afaik atm SickRage does not provide that option currently. Now you can run manual PP with the delete option enabled, and that should remove it, but ofc that's not automagically :).

MrCee commented 8 years ago

I'm sure I have this working. See the last line in the log....

2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Snatch history had a quality in it, using that: SDTV
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Is ep a priority download: False
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: File /volume1/video/TV Shows/Game of Silence (2016)/Season 01/Game.of.Silence.S01E09.The.Truth.SDTV.mkv is smaller than /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Processing failed for /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv: 
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Problem(s) during processing, failed the following files/folders:  
2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: [/volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv : Processing failed: ]
2016-06-03 16:21:02 DEBUG   ::PLEX: Attempting to update Plex Library for category tv.
2016-06-03 16:21:03 DEBUG   ::PLEX: Plex Library has been refreshed.
2016-06-03 16:21:03 INFO    ::CLEANDIR: Doing Forceful Clean of /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]
2016-06-03 16:21:03 INFO    ::MAIN: Deleting /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]

Here are the settings in autoprocess.config I have which help either nzbToMedia.py & TorrentToMedia.py clean up files afterwards:

[General]
    # Enable/Disable forceful cleaning of leftover files following postprocess
    force_clean = 1
[SickBeard]
    [[tv]]
        fork = sickrage
        delete_failed = 1
        # tell SickRage to delete all source files after processing.
        delete_on = 1
[Torrent]
    ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
    deleteOriginal = 1
    chmodDirectory = 777
mgaulton commented 8 years ago

ok, i have all the same except the Torrent deleteOriginal, so I added that but I was seeing it with nzbs and torrents. I'll keep an eye on it. Thanks for checking.

On Fri, Jun 3, 2016 at 4:55 AM, MrCee notifications@github.com wrote:

I'm sure I have this working. See the last line in the log....

2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Snatch history had a quality in it, using that: SDTV 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Is ep a priority download: False 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: File /volume1/video/TV Shows/Game of Silence (2016)/Season 01/Game.of.Silence.S01E09.The.Truth.SDTV.mkv is smaller than /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Processing failed for /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv: 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: Problem(s) during processing, failed the following files/folders: 2016-06-03 16:21:02 POSTPROCESS::SICKBEARD: [/volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]/Game.of.Silence.S01E09.HDTV.x264-DEFiNE.mkv : Processing failed: ] 2016-06-03 16:21:02 DEBUG ::PLEX: Attempting to update Plex Library for category tv. 2016-06-03 16:21:03 DEBUG ::PLEX: Plex Library has been refreshed. 2016-06-03 16:21:03 INFO ::CLEANDIR: Doing Forceful Clean of /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg] 2016-06-03 16:21:03 INFO ::MAIN: Deleting /volume1/downloads/tv/Game.of.Silence.S01E09.HDTV.x264-DEFiNE[rarbg]

Here are the settings in autoprocess.config I have which help either nzbToMedia.py & TorrentToMedia.py clean up files afterwards:

[SickBeard] [[tv]] fork = sickrage delete_failed = 1

tell SickRage to delete all source files after processing.

    delete_on = 1

[Torrent]

ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING
deleteOriginal = 1
chmodDirectory = 777

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-223526599, or mute the thread https://github.com/notifications/unsubscribe/AEiY3p3hRRTATT3C-DYYxJsWNqzAdloYks5qH-v6gaJpZM4Iq0Zl .

MrCee commented 8 years ago

@mgaulton Let us know how you go. Question... Do you have SickRage >> Search Settings >> Episode Search >> Use Failed Downloads & Delete Failed switched ON?

mgaulton commented 8 years ago

Yes, those have always been on.

On Sun, Jun 5, 2016 at 7:45 AM, MrCee notifications@github.com wrote:

@mgaulton https://github.com/mgaulton Let us know how you go. Question... Do you have SickRage >> Search Settings >> Episode Search >> Use Failed Downloads & Delete Failed switched ON?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-223808633, or mute the thread https://github.com/notifications/unsubscribe/AEiY3ltAGIxKQOt1yBxNmZJOaDDwDTQuks5qIrbhgaJpZM4Iq0Zl .

mgaulton commented 8 years ago

Still appears that I'm not getting deletion.

[18:42:20] [INFO]::MAIN: nzbToMedia Version:2d770510a284fadc6b44628626f5769789086dbb Branch:master (Linux 4.1.21-14-default)

[18:42:55] [DEBUG]::SICKBEARD: Opening URL: http://localhost:8182/home/postprocess/processEpisode with params: {'nzbName': 'The.Path.S01E10.480p.x264-mSD.nzb', 'force': 1, 'quiet': 1, 'failed': '0', 'proc_dir': '/home/@send/TV/The Path', 'delete_on': 1} [18:45:02] [POSTPROCESS]::SICKBEARD: Processing folder /home/@send/TV/The Path [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing Path: /home/@send/TV [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing Dirs: [u'The Path'] [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing Files: [] [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing VideoFiles: [] [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing RarContent: [] [18:45:02] [POSTPROCESS]::SICKBEARD: PostProcessing VideoInRar: [] [18:45:02] [POSTPROCESS]::SICKBEARD: Processing folder The Path [18:45:02] [POSTPROCESS]::SICKBEARD: Processing folder /home/@send/TV/The Path [18:45:02] [POSTPROCESS]::SICKBEARD: Found unwanted files: ['The.Path.-.S01E10.-.480p.x264-mSD.nfo', 'The.Path.-.S01E10.-.480p.x264-mSD.1.nfo', 'The.Path.-.S01E10.-.480p.x264-mSD.1.2.nfo', 'The.Path.-.S01E10.-.480p.x264-mSD.en.srt', 'The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.en.srt'] [18:45:02] [POSTPROCESS]::SICKBEARD: Processing /home/@send/TV/The Path/The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.mkv (The.Path.S01E10.480p.x264-mSD.nzb) [18:45:02] [POSTPROCESS]::SICKBEARD: Retrieving episode object for 1x10 [18:45:02] [POSTPROCESS]::SICKBEARD: Snatch history had a quality in it, using that: SDTV [18:45:02] [POSTPROCESS]::SICKBEARD: Is ep a priority download: False [18:45:02] [POSTPROCESS]::SICKBEARD: File /mnt/newtv/@Sorted/The Path/The Path - S01E10 - The Miracle.avi is larger than /home/@send/TV/The Path/The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.mkv [18:45:02] [POSTPROCESS]::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace [18:45:02] [POSTPROCESS]::SICKBEARD: Processing failed for /home/@send/TV/The Path/The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.mkv: [18:45:02] [POSTPROCESS]::SICKBEARD: Processing /home/@send/TV/The Path/The.Path.-.S01E10.-.480p.x264-mSD.mkv (The.Path.S01E10.480p.x264-mSD.nzb) [18:45:02] [POSTPROCESS]::SICKBEARD: Retrieving episode object for 1x10 [18:45:02] [POSTPROCESS]::SICKBEARD: Snatch history had a quality in it, using that: SDTV [18:45:02] [POSTPROCESS]::SICKBEARD: Is ep a priority download: False [18:45:02] [POSTPROCESS]::SICKBEARD: File /mnt/newtv/@Sorted/The Path/The Path - S01E10 - The Miracle.avi is larger than /home/@send/TV/The Path/The.Path.-.S01E10.-.480p.x264-mSD.mkv [18:45:02] [POSTPROCESS]::SICKBEARD: File exists and new file quality is not in a preferred quality list, marking it unsafe to replace [18:45:02] [POSTPROCESS]::SICKBEARD: Processing failed for /home/@send/TV/The Path/The.Path.-.S01E10.-.480p.x264-mSD.mkv: [18:45:02] [POSTPROCESS]::SICKBEARD: Problem(s) during processing, failed the following files/folders: [18:45:02] [POSTPROCESS]::SICKBEARD: [/home/@send/TV/The Path/The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.mkv : Processing failed: ] [18:45:02] [POSTPROCESS]::SICKBEARD: [/home/@send/TV/The Path/The.Path.-.S01E10.-.480p.x264-mSD.mkv : Processing failed: ] [18:45:02] [ERROR]::MAIN: A problem was reported in the /opt/Sick-Beard/autoProcessTV/nzbToMedia.py script. SickBeard: Failed to post-process - Returned log from SickBeard was not as expected.! The Path S01E10 480p x264-mSDimage 4 of 4nextpreviousclose

On Sun, Jun 5, 2016 at 7:45 AM, MrCee notifications@github.com wrote:

@mgaulton https://github.com/mgaulton Let us know how you go. Question... Do you have SickRage >> Search Settings >> Episode Search >> Use Failed Downloads & Delete Failed switched ON?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-223808633, or mute the thread https://github.com/notifications/unsubscribe/AEiY3ltAGIxKQOt1yBxNmZJOaDDwDTQuks5qIrbhgaJpZM4Iq0Zl .

MrCee commented 8 years ago

Could be a permission problem... but you would have checked this I'm sure. I should have asked about your environment. I'm not mounting external, so it's difficult for me to help. I hard-link everything on the NAS, which helps with the clean-up process I use. @clinton-hall for any suggestions

clinton-hall commented 8 years ago

@mgaulton was this from a manual run? I believe, looking through the code, that the cleanup section here is skipped on manual run if the script does not succeed.

Please note. In this script "successful"/"failed" run is different to "successful"/"failed" download.

I believe we can add this, but this needs to be a new feature whereby we look for "marking unsafe to replace" or similar... I am hesitant to delete on "failed to process"...

labrys commented 8 years ago

@clinton-hall SickRage's post processing does not delete on "Failed to process" unless you use manual post processing.

clinton-hall commented 8 years ago

@labrys Yeah, so I think what is being asked here is for an option whereby IF SickRage fails to postprocess nzbToMedia would automatically delete the files (delete the torrent). The thing I would need to check however is that we identify reasons to delete, and reasons not to delete... i.e if the file already esists in a better quality, this makes sense. But if SickRage failed to process becasue of permissions issues etc, we don't want to delete...

labrys commented 8 years ago

Well the reason SickRage does not delete upon failure is to avoid removal of media that may be desired without specifically telling it that it must. It's a fail-safe ideology. Having it delete media is unlikely to reliably fail-well and could occasionally fail-badly. Running an occasional manual PP to clean up remaining files is a safe (although less convenient) alternative.

clinton-hall commented 8 years ago

Yes, I agree. Hence I hadn't added this functionality previously. The default for force_clean is disabled... I hate when people report that my script deleted their downloads!!

mgaulton commented 8 years ago

@clinton-hall no, i don't do manual runs very often. I pulled this from the history log in SAB I thought the "we already have a file and won't replace it with this one" part of the logging would be considered "marked unsafe to replace" etc.

On Tue, Jun 7, 2016 at 8:53 AM, Clinton Hall notifications@github.com wrote:

@mgaulton https://github.com/mgaulton was this from a manual run? I believe, looking through the code, that the cleanup section here is skipped on manual run if the script does not succeed.

Please note. In this script "successful"/"failed" run is different to "successful"/"failed" download.

I believe we can add this, but this needs to be a new feature whereby we look for "marking unsafe to replace" or similar... I am hesitant to delete on "failed to process"...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-224270987, or mute the thread https://github.com/notifications/unsubscribe/AEiY3viHrjDUFMXKErJnsAVGfb7-Tt3tks5qJWm0gaJpZM4Iq0Zl .

mgaulton commented 8 years ago

In this scenario, if we were to parse the message " File exists and new file quality is not in a preferred quality list, marking it unsafe to replace" and have a option to say leave or delete, that would fit what I'm thinking of but I suspect you aren't parsing that bit of logging but going based on the returned result value from SR.

On Tue, Jun 7, 2016 at 9:27 AM, Clinton Hall notifications@github.com wrote:

Yes, I agree. Hence I hadn't added this functionality previously. The default for force_clean is disabled... I hate when people report that my script deleted their downloads!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-224279532, or mute the thread https://github.com/notifications/unsubscribe/AEiY3lArtuydJ7qY4S3fYYjS8YINJnFyks5qJXGogaJpZM4Iq0Zl .

mgaulton commented 8 years ago

@MrCee I don't believe that to be the case, it works under other circumstances using all the same setup.

On Tue, Jun 7, 2016 at 6:59 AM, MrCee notifications@github.com wrote:

Could be a permission problem... but you would have checked this I'm sure. I should have asked about your environment. I'm not mounting external, so it's difficult for me to help. I hard-link everything on the same NAS, which helps with the clean-up process I use.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/clinton-hall/nzbToMedia/issues/1044#issuecomment-224247437, or mute the thread https://github.com/notifications/unsubscribe/AEiY3ipaX3lnnY__IGnLifXnLI7qv8UNks5qJU72gaJpZM4Iq0Zl .

MrCee commented 8 years ago

@mgaulton What is with the two different episodes in the last log?

[18:45:02] [POSTPROCESS]::SICKBEARD: File /mnt/newtv/@Sorted/The Path/The
Path - S01E10 - The Miracle.avi is larger than /home/@send/TV/The
Path/The.Path.-.S01E09.-.480p.x264-mSD-Obfuscated.mkv