- Zielverzeichnis in Variable packen
- Bei Fehler curl und tivodecode Prozesse abschiessen - Bei zu wenig Platz im Zielverzeichnis gleich abbrechen
This commit is contained in:
parent
f303f1ca16
commit
28f217b9e1
1 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.29 2010/07/26 20:48:02 stb Exp $
|
||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.30 2010/08/05 20:05:18 stb Exp $
|
||||
#
|
||||
# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4
|
||||
# zu transkodieren.
|
||||
|
@ -20,7 +20,7 @@ import re
|
|||
|
||||
host = "tivo.lassitu.de"
|
||||
mak = "7194378159"
|
||||
|
||||
targetdir = "/mnt/safe/tivo"
|
||||
|
||||
arset = dict()
|
||||
arset["Family Guy"] = 43
|
||||
|
@ -86,6 +86,9 @@ def getTagText(element, tagname):
|
|||
except IndexError:
|
||||
return ""
|
||||
|
||||
def getAvail(dir):
|
||||
s = os.statvfs(dir)
|
||||
return s.f_bsize * s.f_bavail
|
||||
|
||||
def transcode(file, src, passno, ar):
|
||||
print "--- transcoding pass %d" % passno
|
||||
|
@ -155,6 +158,8 @@ def download(file, url, mak, target):
|
|||
"--out", target, "-"], stdin=p_curl.stdout)
|
||||
if checkProcessError(p_curl, p_decode) or checkProcessError(p_curl, p_decode):
|
||||
os.remove(target)
|
||||
os.kill(p_curl.pid, signal.SIGQUIT)
|
||||
os.kill(p_decode.pid, signal.SIGQUIT)
|
||||
raise Exception
|
||||
if os.path.getsize(target) < 1024:
|
||||
print "error transcoding file: too small"
|
||||
|
@ -187,6 +192,11 @@ def savetoc(toc):
|
|||
|
||||
curdir = os.getcwd()
|
||||
os.chdir(tmp)
|
||||
avail = getAvail(targetdir)
|
||||
if avail < 1024*1024*1024:
|
||||
print "%s: %.1fM available, at least 1024M needed, stopping" % \
|
||||
(targetdir, avail / 1024.0 / 1024.0)
|
||||
sys.exit(1)
|
||||
downloaddb = anydbm.open(curdir + "/tivo/.downloads", "c")
|
||||
print "*** Getting listing"
|
||||
toc = gettoc()
|
||||
|
@ -208,8 +218,8 @@ for i in items:
|
|||
if episode == "":
|
||||
episode = date
|
||||
name = "%s - %s" % (title, episode)
|
||||
dir = "%s/tivo/%s" % (curdir, re.sub("[:/]", "-", title))
|
||||
dir = "/mnt/safe/tivo/%s" % (re.sub("[:/]", "-", title))
|
||||
#dir = "%s/tivo/%s" % (curdir, re.sub("[:/]", "-", title))
|
||||
dir = "%s/%s" % (targetdir, re.sub("[:/]", "-", title))
|
||||
file = "%s/%s" % (dir, re.sub("[:/]", "-", name))
|
||||
name = name.encode("utf-8");
|
||||
dir = dir.encode("utf-8");
|
||||
|
|
Loading…
Reference in a new issue