KBlixt / subcleaner

removes ads from subtitle files cleanly.
284 stars 12 forks source link

support a --backup option #28

Closed winbatch closed 1 year ago

winbatch commented 1 year ago

Would be good if it supported an option to make a backup copy of the file that it processed. I'm running the script against thousands of files, and so if/when I find something that it removed that it shouldn't have, it'd be nice to have a backup copy to restore.

KBlixt commented 1 year ago

I have a --dry-run argument for this reason. I'm currently developing a method to more easily restore false positives, but it might be a while more before that comes, and the scope of this script is to remove ads from downloaded subtitles in which case you already have a backup stored from wherever you downloaded from.

I'll keep this in mind but it's not something I'll commit to. But if it's easy to implement I might do it while I'm at it anyway.

winbatch commented 1 year ago

Got it. Consider this use case though - I'm running this in a loop against 3000 subtitles. I don't want to dry run each one, and then run it a second time to do it. I just want to be able to restore a backup if I find it did something wrong on 1 of the 3000. So in the interim I've made the copy myself as part of the loop.

Btw, don't assume that you can redownload it from where you got it. Consider the case where someone has had a Plex server for 10 years, only came up on your script now and is attempting to clean their entire library years later.

KBlixt commented 1 year ago

You raise a valid point. Really I hear you. And like I said, I'll take a look at it but if you want to backup the files you could just put a simple cp command in the post process script. Something like this:

cp "{subtitle}" "{directory}/subtitle_backup" && (subcleaner script run)

You'd also have to make sure the subtitle_backup directory exists but that would be a similar command.

winbatch commented 1 year ago

Yup, that's what I've done. (though I didn't create a directory, I just simply did {subtitle} to {subtitle}.backup

KBlixt commented 1 year ago

Yepp, that's also a way to do it. But id recommend using putting the paths between quotes in case you have spaces in your file names.