clinton-hall / nzbToMedia

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

TorrentToMedia | UserScript won't execute if download single file, not in directory #262

Closed ghost closed 10 years ago

ghost commented 10 years ago

Wondering if there is any way to fix this?

I'm using "other" and "hard".

TorrentToMedia works perfect with downloads sorted in their own directory by name. However, if the torrent just downloaded a single file (iso) as an example, and didn't download to a directory, nothing gets executed. Appears it expects a directory path to kick off the linking and script.

I can reproduce this single file behavior with this torrent: http://cdimage.debian.org/debian-cd/7.4.0/amd64/bt-cd/debian-7.4.0-amd64-netinst.iso.torrent

Everything works great with a directory torrent, such as: http://www.slackware.com/torrents/slackware-14.1-install-d1.torrent

Happens rarely that I come across an individual file.

ghost commented 10 years ago

sickbeard not linking... wiping out original files instead.. :-) (whoops!)

20:18:38|INFO    ====================
20:18:38|INFO    TorrentToMedia V9.2
20:18:38|INFO    MAIN: Loading config from ./autoProcessMedia.cfg
20:18:38|DEBUG   arg 0 is: ./TorrentToMedia.py
20:18:38|DEBUG   arg 1 is: /cache/torrent/download/sickbeard/TV.Show/
20:18:38|DEBUG   arg 2 is: TV.Show/
20:18:38|DEBUG   arg 3 is: sickbeard
20:18:38|DEBUG   arg 4 is: 
20:18:38|DEBUG   MAIN: Received Directory: /cache/torrent/download/sickbeard/TV.Show | Name: TV.Show/ | Category: sickbeard
20:18:38|INFO    SEARCH: Files appear to be in their own directory
20:18:38|DEBUG   MAIN: Determined Directory: /cache/torrent/download/sickbeard/TV.Show | Name: TV.Show/ | Category: sickbeard
20:18:38|INFO    MAIN: Calling SickBeard's TPB branch to post-process: TV.Show/
20:18:38|INFO    Loading config from ./autoProcessMedia.cfg
20:18:38|INFO    The download succeeded. Sending process request to SickBeard's TPB branch
20:18:38|INFO    Waiting for 0.0 seconds to allow SB to process newly extracted files
20:18:38|DEBUG   Opening URL: https://127.0.0.1:8081/sickbeard/home/postprocess/processEpisode?nzbName=TV.Show%2F&failed=0&quiet=1&dir=%2Fcache%2Ftorrent%2Fdownload%2Fsickbeard%2FTV.Show
20:18:41|INFO    Processing folder /cache/torrent/download/sickbeard/TV.Show
20:18:41|INFO    TV_DOWNLOAD_DIR: /cache/process/sickbeard
20:18:41|INFO    PostProcessing Path: /cache/torrent/download/sickbeard
20:18:41|INFO    PostProcessing Dirs: [u'TV.Show']
20:18:41|INFO    PostProcessing Files: []
20:18:41|INFO    PostProcessing VideoFiles: []
20:18:41|INFO    PostProcessing RarContent: []
20:18:41|INFO    PostProcessing VideoInRar: []
20:18:41|INFO    Processing folder TV.Show
20:18:41|INFO    Deleting file sample-tv.show.mkv
20:18:41|INFO    Deleting folder /cache/torrent/download/sickbeard/TV.Show/Sample
20:18:41|INFO    Packed Releases detected: ['tv.show.rar']
20:18:41|INFO    Unpacking archive: tv.show.rar
20:18:41|INFO    You're trying to post process a video that's already been processed, skipping
20:18:41|INFO    Archive file already post-processed, extraction skipped: tv.show.mkv
20:18:41|INFO    UnRar content: []
20:18:41|INFO    Deleting file tv.show.r19
20:18:41|INFO    Deleting file tv.show.r18
20:18:41|INFO    Deleting file tv.show.r13
20:18:41|INFO    Deleting file tv.show.r12
20:18:41|INFO    Deleting file tv.show.r11
20:18:41|INFO    Deleting file tv.show.r10
20:18:41|INFO    Deleting file tv.show.r17
20:18:41|INFO    Deleting file tv.show.r16
20:18:41|INFO    Deleting file tv.show.r15
20:18:41|INFO    Deleting file tv.show.r14
20:18:41|INFO    Deleting file tv.show.rar
20:18:41|INFO    Deleting file tv.show.nfo
20:18:41|INFO    Deleting file tv.show.sfv
20:18:41|INFO    Deleting file tv.show.r08
20:18:41|INFO    Deleting file tv.show.r09
20:18:41|INFO    Deleting file tv.show.r20
20:18:41|INFO    Deleting file tv.show.r21
20:18:41|INFO    Deleting file tv.show.r00
20:18:41|INFO    Deleting file tv.show.r01
20:18:41|INFO    Deleting file tv.show.r02
20:18:41|INFO    Deleting file tv.show.r03
20:18:41|INFO    Deleting file tv.show.r04
20:18:41|INFO    Deleting file tv.show.r05
20:18:41|INFO    Deleting file tv.show.r06
20:18:41|INFO    Deleting file tv.show.r07
20:18:41|INFO    Deleting folder /cache/torrent/download/sickbeard/TV.Show
20:18:41|INFO    MAIN: All done.

[SickBeard] sbCategory = sickbeard host = 127.0.0.1 port = 8081 username = password = web_root = /sickbeard ssl = 1 delay = 0 wait_for = 10 watch_dir = fork = TPB delete_failed = 1 nzbExtractionBy = Destination

[Torrent] clientAgent = rtorrent useLink = hard outputDirectory = /cache/process categories = couchpotato,sickbeard,manual,movies,music,tv noFlatten = manual,movies,music,tv uTorrentWEBui = http://localhost:8090/gui/ uTorrentUSR = your username uTorrentPWD = your password TransmissionHost = localhost TransmissionPort = 8084 TransmissionUSR = your username TransmissionPWD = your password DelugeHost = DelugePort = DelugeUSR = DelugePWD = deleteOriginal = 0

clinton-hall commented 10 years ago

Everything between

20:18:38|DEBUG Opening URL: https://127.0.0.1:8081/sickbeard/home/postprocess/processEpisode?nzbName=TV.Show%2F&failed=0&quiet=1&dir=%2Fcache%2Ftorrent%2Fdownload%2Fsickbeard%2FTV.Show

And 20:18:41|INFO MAIN: All done

Is done by SickBeard... With these settings we are passing everything to SickBeard to process... So as long as the directory we are passing is correct, I hint this is a SickBeard issue...

clinton-hall commented 10 years ago

The issue appears to be You're trying to post process a video that's already been processed, skipping 20:18:41|INFO Archive file already post-processed, extraction skipped: tv.show.mkv

ghost commented 10 years ago

Correct.

However, shouldn't the link happen before sending to sickbeard? in the event sickbeard does this? shouldn't it receive the process path, after link? instead of original?

my default config in SB is to unrar, delete, and move. it's assuming it's receiving a linked directory that it wouldn't matter if it was failed or not.. i'd prefer SB cleanup anything that's a duplicate, or delete a failed and go find it's next one, etc...

in this case it blew away a seed...

should i be using different settings?

clinton-hall commented 10 years ago

Hmmm... When the idea of passing files directly into SickBeard was first presented, I was of the impression these branches of SickBeard do their own extraction and hardlinking etc... so for fork = TPB or Pistachitos, I just pass it the directory and the name... I bypass all linking and extracting etc.

even if this wasn't bypassed, it would no link these files, it would do the unrar...

So as far as this goes, it did as expected.... but that is not to say this is how it should be.

Suggestions?

ghost commented 10 years ago

You are correct. These branches can do hard linking.. problem is.. with both SAB and Torrent in play, you only have one post-processing option...

For SAB, doing a move is a good thing, there is no need to leave it to seed and SB set to move does what you'd want it to do; it leaves you with a properly functioning automation and not a ton of leftover stuff filling your drive. This is the original SB / SAB way...

However, when SB set to move, the torrent would need to be hard linked prior; otherwise you blow away the seed.

If set SB to hard link, then you end up with a mess in SAB folders and no way to clean things up...

IMHO, for those of us who utilize both, move is the proper setting, which ideally means that we hard link before sending to SB failed branches. Much the same way CP is handled?

clinton-hall commented 10 years ago

ok... so CP is fine, but for SB I just want to confirm I understand this:

NZB -> You don't want SAB or my script to extract or link, but just pass the download dire and name straight to SB to extract/move (not link)

Torrent -> You want to link all files (media and .rar etc) but not extract, and then pass this all on to SB to extract/move (not link)

Basically, the only difference to current is to perform a recursive link of all files for SickBeard Torrents?

clinton-hall commented 10 years ago

ok, new option [SickBeard] Torrent_ForceLink =1 This will link/copy/move all files, unflattened, for TPB/Pistachitos fork of SickBeard and then pass to SickBeard.

Suggested to use with SickBeard set to Move files, and TorrentToMedia useLink = hard.

ghost commented 10 years ago

works beautifully. thank you again!

funny.. now sickbeard won't clean up the source.. i think because it's already unrar'd; vs. that other run which was still in un-clean state...

ghost commented 10 years ago
13:59:18|INFO    ====================
13:59:18|INFO    TorrentToMedia V9.2
13:59:18|INFO    MAIN: Loading config from ./autoProcessMedia.cfg
13:59:18|INFO    SEARCH: Found torrent file /cache/torrent/download/sickbeard/TV.Show.mkv in category directory /cache/torrent/download/sickbeard
13:59:18|INFO    MAIN: Download is not a directory
13:59:18|INFO    MAIN: Output directory set to: /cache/process/sickbeard/TV.Show
13:59:18|INFO    MAIN: Found file .mkv in /cache/torrent/download/sickbeard/TV.Show.mkv
13:59:18|INFO    CREATE DESTINATION: Creating destination folder: /cache/process/sickbeard/TV.Show
13:59:18|INFO    COPYLINK: Hard linking /cache/torrent/download/sickbeard/TV.Show.mkv to /cache/process/sickbeard/TV.Show/TV.Show.mkv
13:59:19|INFO    FLATTEN: Flattening directory: /cache/process/sickbeard/TV.Show
13:59:19|INFO    REMOVER: Removing empty folders in: /cache/process/sickbeard/TV.Show
13:59:19|INFO    MAIN: Calling Sick-Beard to post-process: TV.Show.mkv
13:59:19|INFO    Loading config from ./autoProcessMedia.cfg
13:59:19|INFO    The download succeeded. Sending process request to SickBeard's TPB branch
13:59:19|INFO    Waiting for 0.0 seconds to allow SB to process newly extracted files
13:59:19|INFO    Processing folder /cache/process/sickbeard/TV.Show
13:59:19|INFO    TV_DOWNLOAD_DIR: /cache/process/sickbeard
13:59:19|INFO    PostProcessing Path: /cache/process/sickbeard
13:59:19|INFO    PostProcessing Dirs: []
13:59:19|INFO    PostProcessing Files: [u'/cache/process/sickbeard/TV.Show/TV.Show.mkv']
13:59:19|INFO    PostProcessing VideoFiles: [u'/cache/process/sickbeard/TV.Show/TV.Show.mkv']
13:59:19|INFO    PostProcessing RarContent: []
13:59:19|INFO    PostProcessing VideoInRar: []
13:59:19|INFO    Processing /cache/process/sickbeard/TV.Show/TV.Show.mkv (TV.Show.mkv)
13:59:19|INFO    Parsed TV.Show.mkv into TV Show (Blah) [ABD: False]
13:59:19|INFO    Checking scene exceptions for a match on How I Met Your Mother
13:59:19|INFO    Looking up How I Met Your Mother in the DB
13:59:19|INFO    Lookup successful, using tvdb id 12345
13:59:19|INFO    Loading show object for tvdb_id 12345
13:59:19|INFO    Retrieving episode object for 9x7
13:59:19|INFO    Looking up quality for name TV.Show.mkv, got 1080p WEB-DL
13:59:19|INFO    Is ep a priority download: False
13:59:19|INFO    File /storage/TV.Show.mkv is the same size as /cache/process/sickbeard/TV.Show/TV.Show.mkv
13:59:19|INFO    File exists and we are not going to replace it because it's not smaller, quitting post-processing
13:59:19|INFO    Processing failed for /cache/process/sickbeard/TV.Show/TV.Show.mkv:
13:59:19|INFO    outputDirectory /cache/process/sickbeard/TV.Show still contains 1 media and/or meta files. This directory will not be removed.
13:59:19|INFO    MAIN: All done.
clinton-hall commented 10 years ago

Yeah, SickBeard is saying File /storage/TV.Show.mkv is the same size as /cache/process/sickbeard/TV.Show/TV.Show.mkv 13:59:19|INFO File exists and we are not going to replace it because it's not smaller, quitting post-processing

Now, becasue the same file exists, SickBeard doesn't move the file, so /cache/process/sickbeard/TV.Show/TV.Show.mkv still exists.

Then my script does a quick check for files in /cache/process/sickbeard/TV.Show and it finds the video file is still there... so to be safe, this isn't deleted (because the user may have delete_Original checked and I don't want to delete files unless i can be sure they have been correctly processed).

13:59:19|INFO outputDirectory /cache/process/sickbeard/TV.Show still contains 1 media and/or meta files. This directory will not be removed.

At the end of the day, if something goes wrong I prefer to keep the files as opposed to deleting something that wasn't processed to the end library.

ghost commented 10 years ago

Understood and agreed. Thank you for all your help. I think we've got all this working. I've tested SB, CP, torrent and SAB, and userscript. Everything looks good!

clinton-hall commented 10 years ago

I just noticed in your log that it was flattening... when using the SICKBEARD_TORRENT forks, we should copy/link and pass in the Full directory structure... this last fix should take care of that (was a trivial little change)

clinton-hall commented 10 years ago

And thanks so much for your patience and detailed testing :)

ghost commented 10 years ago

for Sickbeard.. wasn't causing any issues. original behavior was good. just for userscript that it was causing a mess... thanks again!