From 48c8b44bd3350287846dc0490ec090a0dc661d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Mon, 25 Feb 2013 11:02:51 +0100 Subject: [PATCH] hardlink solution for uTorrent --- TorrentToMedia.py | 27 +++++++- autoProcessMedia.cfg.sample | 4 ++ utorrent/__init__.py | 0 utorrent/__init__.pyc | Bin 0 -> 133 bytes utorrent/client.py | 124 ++++++++++++++++++++++++++++++++++++ utorrent/client.pyc | Bin 0 -> 5325 bytes utorrent/upload.py | 71 +++++++++++++++++++++ utorrent/upload.pyc | Bin 0 -> 2798 bytes 8 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 utorrent/__init__.py create mode 100644 utorrent/__init__.pyc create mode 100644 utorrent/client.py create mode 100644 utorrent/client.pyc create mode 100644 utorrent/upload.py create mode 100644 utorrent/upload.pyc diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 3e990b56..6c759cfa 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -7,14 +7,18 @@ import os import shutil import logging import datetime +import time +import urllib2 from subprocess import call + # Custom imports import linktastic.linktastic as linktastic import autoProcessMovie import autoProcessTV from nzbToMediaEnv import * from nzbToMediaUtil import * +from utorrent.client import UTorrentClient nzbtomedia_configure_logging(os.path.dirname(sys.argv[0])) Logger = logging.getLogger(__name__) @@ -272,7 +276,7 @@ if len(sys.argv) == 2: #for other clients we assume we must at least get the dir inputName = '' # We dont have a name yet inputCategory = '' # We dont have a category yet -elif len(sys.argv) > 3 and sys.argv[1] == 'utorrent': #distinguish utorrent from others like deluge. +elif len(sys.argv) > 4 and sys.argv[1] == 'utorrent': #distinguish utorrent from others like deluge. # We will pass in 'utorrent' '%D', '%N', and '%L' (if it exists), from uTorrent # In short pass "/path/to/downloaded/torrent/ name" to TorrentToMedia.py, eg >>>> TorrentToMedia.py /Downloaded/MovieName.2013.BluRay.1080p.x264-10bit.DTS MovieName.2013.BluRay.1080p.x264-10bit.DTS <<<< inputDirectory = os.path.normpath(sys.argv[2]) @@ -281,6 +285,7 @@ elif len(sys.argv) > 3 and sys.argv[1] == 'utorrent': #distinguish utorrent from inputCategory = sys.argv[4] # We dont have a category yet except: inputCategory = '' # We dont have a category yet + inputHash = sys.argv[5] elif len(sys.argv) == 4: # We will assume this to be the passin from deluge. torrent id, torrent name, torrent save path. @@ -312,6 +317,9 @@ movieDestination = os.path.normpath(config.get("CouchPotato", "outputDirectory") # Torrent specific useLink = int(config.get("Torrent", "useLink")) extractionTool = os.path.normpath(config.get("Torrent", "extractionTool")) +uTorrentWEBui = config.get("Torrent", "uTorrentWEBui") +uTorrentUSR = config.get("Torrent", "uTorrentUSR") +uTorrentPWD = config.get("Torrent", "uTorrentPWD") compressedContainer = (config.get("Torrent", "compressedExtentions")).split(',') mediaContainer = (config.get("Torrent", "mediaExtentions")).split(',') metaContainer = (config.get("Torrent", "metaExtentions")).split(',') @@ -429,11 +437,26 @@ old_stdout = sys.stdout # Still crude, but we wat to capture this for now logFile = os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log") log_file = open(logFile,"a+") sys.stdout = log_file -if inputCategory == movieCategory: + +# Hardlink solution with uTorrent +if inputHash and useLink: + Logger.debug("MAIN: We are using hardlinks with uTorrent, calling uTorrent to pause download") + utorrentClass = UTorrentClient(uTorrentWEBui, uTorrentUSR, uTorrentPWD) + utorrentClass.stop(inputHash) + time.sleep(10) + +if inputCategory == movieCategory: Logger.info("MAIN: Calling postprocessing script for CouchPotatoServer") autoProcessMovie.process(outputDestination, inputName, status) elif inputCategory == tvCategory: Logger.info("MAIN: Calling postprocessing script for Sick-Beard") autoProcessTV.processEpisode(outputDestination, inputName, status) + +# Hardlink solution with uTorrent +if inputHash and useLink: + Logger.debug("MAIN: We are using hardlinks with uTorrent, calling uTorrent to resume download") + utorrentClass.start(inputHash) + time.sleep(10) + sys.stdout = old_stdout log_file.close() diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index f20ff807..af847ca3 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -31,6 +31,10 @@ failed_fork=0 useLink = 0 extractionTool = C:\Program Files\7-Zip\7z.exe categories = music,music_videos,pictures,software +###### uTorrent Hardlink solution (You must edit this if your using TorrentToMedia.py with uTorrent) +uTorrentWEBui = http://localhost:8090/gui/ +uTorrentUSR = your username +uTorrentPWD = your password ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ###### compressedExtentions = .zip,.rar,.7z,.gz,.bz,.tar,.arj mediaExtentions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso diff --git a/utorrent/__init__.py b/utorrent/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/utorrent/__init__.pyc b/utorrent/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4de8d258fa8be36a8f3a88f5e62faa47807b69c GIT binary patch literal 133 zcmZSn%*(Y;Ry#160SXv_v;zul`Q>>z`H3m1 zMa40BRY@WFzNsmhi7}-m`9(#kc_lIN@tJvotPj9Ci~2>vk1&5tk+E5GJ|=uKW~DhZqfyFh>aWOu`!Q~`ThPPMceIA z-t0g4+wKG?x+P>Ek8+po#FhJ?tOo89T7I`zR#jTK%{)VXrfeNu?<3j2B1@sBRKpI` zE8tdCs-^-os;e+Fkpi+NGisSNNmGS6lgz5nGRd3@^CoGjuwasT6(IMLz6<6t0K7D< zE~>h0!rcxf?lzDyQNc|lyM^pDFsH^uDAZIywXTAyeF%#dd{M2NM-6o;@6Ql5&V|$l zxYe-QwwpsfnqbqJMMW(Ku}z~B4q5a;@R=Y^kr2XOE-cI}d*k;}Kdn4Ct$3@camgRAl zw(V#*EGySOEUUJVZGVW%6VrXGAP5D%p}lTAlX#?S zrVkFm)uCM^?8CRS3QwvZyL zNm^ts9a!NP#a)+`MTc8^97v?&lejvvlk-@`g9|Zp4GaDR$#P}7ycMr4Wn=mklD&xx zuFPxu;3~DfbN@04N1h1@aPF`s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