clinton-hall / nzbToMedia

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

Moving then symlink torrents but not NZB #1375

Closed noaho closed 5 years ago

noaho commented 6 years ago

Hi,

Torrents need to seed so I like to move then symlink them,

But NZB's don't need seeding so I would like to delete them.

Originally I thought if I use sickrage's post processing (then files would be moved from my torrent/sabnzbd directory straight into my TV shows directory, saving space, and a second layer of links.

EG Torrent_NoLink = 0. If set to 1, this will bypass all linking (copying/moving) and extracting in TorrentToMedia. This allows you to specify if you want SickBeard/SickRage to do the linking and extraction. It also bypasses the process_method and uses the SickBeard defined method. This only works with a SB fork that supports extraction. i.e. This just passes the download directly to SickBeard without doing any processing.

However there seems no way to turn off this processing for Sabnzbd, so these get linked as well, instead of being moved. This leaves behind a lot of links (and sometimes sample files) cluttering downloads and never being cleaned up.

Is there any way to achieve this? Am I missing something? Is there a reason anyone would want to do anything other than move for Sabnzbd files?

I thought to use this: process_method. set this to move, copy, hardlink, symlink as appropriate if you want to over-ride SB defaults (for NZB downloads and Torrents when Torrent_NoLink = 0). Leave blank to always use SB default.

But it seems to apply for torrents even when Torrent_NoLink=1, so I can't set it to move and have only sabnzbd stuff move.

clinton-hall commented 6 years ago

Personally, I think using hard-links (if supported) is the cleanest way of doing this, and then just set SickRage to just move as default.

[Torrent]
    useLink=hard
    outputDirectory = <path to an interim directory for processing. not your download directory>

Note here that the hard-link only applies to torrents and NOT to NZBs.

Otherwise to achieve move-sym set TorrentToMedia.py to Move and Symlink

[SickBeard]
    [[tv]]
        Torrent_NoLink = 0
        process_method =
[Torrent]
    useLink=move-sym
    outputDirectory = <path to an interim directory for processing. not your download directory>

and Set SickRage to Move and Symlink as default. This will allow this script to process all torrents, moving the file and linking back.

Now in order to prevent SAB dowloads from linking back, just set SABnzbd downloads to use a different category to the torrents (e.g. tv-nzb as per following) and set this to force the prcoess_method as move.

[SickBeard]
    [[tv-nzb]]
        Torrent_NoLink = 0
        process_method = move

Note. If you can't set SABnzbd and Torrents to use a different category, you can achieve the same by creating 2 installations/Paths of nzbToMedia and having TorrentToMEdia called from 1 locations, with theta config set with process_method blank and then have SABnzb call nzbToMedia from the other location with process_method set to move.

noaho commented 6 years ago

Thanks!

Yeah, I did look at hard-links.. my rationale is I'd like to seed for as long as the file is useful to me, and then when it's deleted from my library, save my disk space. But hard link will keep it around until the file is removed from both my library and transmission.

I ended up running 2 nzbtomedia instances in sabnzbd and transmission, so I could use different settings.. and I guess that works.

(for NZB downloads and Torrents when Torrent_NoLink = 0). Leave blank to always use SB default.

This part of the doc is confusing though, because it seems to imply that if Torrent_NoLink = 1, then I can have a separate process_method just for nzbs... which doesn't seem to be the case.

clinton-hall commented 6 years ago

This part of the doc is confusing though, because it seems to imply that if Torrent_NoLink = 1, then I can have a separate process_method just for NZBs... which doesn't seem to be the case.

I can see that... Probably somewhat historic, but basically the Torrent_NoLink =1 only applies to Torrents, and tells the script if it should attempt to extract and link files at that process. So when this is enabled it leaves all processing decisions up to SickRage and essentially Torrent and NZBs are handled the same. When this option is set to 0, Torrents are handled differently to NZBs (by way of linking and extracting) within the script. This really does separate Torrent and NZB handling when you are using hard-links.

Historically, I had set up torrent handling to use hard-linking as the preferred option, and therefore the logic flowed, as both Torrents (after being hard-linked by the script) and NZBs are "moved" by SickRage... The same is also tree for Sym-link (back to the downlaoded file), copy, and move.

In the case of the "move-sym", this is where it breaks down. The script will move the file and sym-link to, but because the script doesn't know where SickRage moves the files to, the requirements is to let SickRage move and sym-link back (this script will then follow the links and clean it all up so that the original download file is a sym-link directly to the final renamed file... and thus the breakdown, if you want NZBs to move, but Torrents to move-link, we need to have a different setting.

There is more I could do here... I could have a torrent_process_method and an nzb_process_method... to be honest, I probably need to check all of the "torrent_no_link" and "extraction_by" options. All of these were introduced to address a specific combination requested by users and I don't know how many are actually likely to still be used...

Anyways. Just a little explanation of how the naming of options and descriptions came about (before I introduced "move-sym" option. In an ideal world, one day I will try and tidy this all up... and I am open to suggestions as to how this should be named and how it should behave.

noaho commented 6 years ago

My thoughts would be (though they could probably be improved)

Separate handling of options (but consistent). eg:

[Torrent] Link = 0 or 1 process_method (applies to either the linker in nzbtomedia (1) or gets passed to sickrage/cp) (0)

[NZB] Link = 0 or 1 process_method (applies to either the linker in nzbtomedia (1) or gets passed to sickrage/cp) (0)

I'm not sure how you could do that without breaking backward compatibility... maybe if Link= is defined, Torrent_Nolink and other options are ignored, and a message is printed to the log saying that?

Really appreciate your help btw, and awesome project 😀

clinton-hall commented 6 years ago

ok... did a simple fix here, in latest nightly branch. Only applies to using "move-sym" to SickRage.

Now if you have:

[SickBeard]
    [[tv]]
        Torrent_NoLink = 0
        process_method = <can leave blank to use SickRage default, or set as move, or as desired for NZBs>
[Torrent]
    useLink=move-sym
    outputDirectory = <path to an interim directory for processing. not your download directory>

And set SickRage to use "move" for standard processing, then all NZBs will be moved (or as otherwise set), but all Torrent downloads will force process method = symbolic link reversed

This will not apply to a "manual" run of TorrentToMedia. If running manual, first set SickRage to default to symbolic link reversed.

noaho commented 5 years ago

@clinton-hall Sorry I missed this before. Thanks for addressing my use case!

Seems like a good fix - however I think it's broken, It's telling sickrage to do "Symbolic Link Reversed" when actually it should say "symlink_reversed"

Hence I get this error in sickrage: Unknown process method: Symbolic Link Reversed

noaho commented 5 years ago

Sorry, "move-sym" should equal "symlink" on sickrage/chill. symlink_reversed symlinks from the download folder without moving, and symlink moves then symlinks back to the download folder.

noaho commented 5 years ago

Thanks! Awesome 👍