Excludes angepasst, Download von Transcoding trennen, nach einem erfolgreichen Download stoppen, damit der Tivo Luft holen kann.
This commit is contained in:
parent
46245a8c99
commit
c290f91548
1 changed files with 36 additions and 31 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.26 2010/06/27 11:36:21 stb Exp $
|
# $Schlepperbande: src/tivomirror/tivomirror,v 1.27 2010/07/04 10:06:46 stb Exp $
|
||||||
#
|
#
|
||||||
# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4
|
# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4
|
||||||
# zu transkodieren.
|
# zu transkodieren.
|
||||||
|
@ -35,9 +35,10 @@ arset["House"] = 43
|
||||||
excludes = dict()
|
excludes = dict()
|
||||||
excludes['Cops'] = 1
|
excludes['Cops'] = 1
|
||||||
excludes['Hot Pursuit'] = 1
|
excludes['Hot Pursuit'] = 1
|
||||||
|
excludes['Most Shocking'] = 1
|
||||||
excludes["World's Wildest Police Videos"] = 1
|
excludes["World's Wildest Police Videos"] = 1
|
||||||
excludes["World Cup Soccer"] = 1
|
#excludes["World Cup Soccer"] = 1
|
||||||
excludes["World Cup Live"] = 1
|
#excludes["World Cup Live"] = 1
|
||||||
|
|
||||||
class flushfile(object):
|
class flushfile(object):
|
||||||
def __init__(self, f):
|
def __init__(self, f):
|
||||||
|
@ -130,6 +131,32 @@ def transcode(file, src, passno, ar):
|
||||||
print " %s" % " ".join(transcode_opts)
|
print " %s" % " ".join(transcode_opts)
|
||||||
subprocess.check_call(transcode_opts)
|
subprocess.check_call(transcode_opts)
|
||||||
|
|
||||||
|
def download(file, url, mak, target):
|
||||||
|
print "--- dowloading \"%s\"" % (url)
|
||||||
|
p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \
|
||||||
|
"--insecure", "--cookie", "tivo/.cookies.txt", \
|
||||||
|
"--silent", "--show-error", \
|
||||||
|
"--user", "tivo:%s" % mak, "--url", url], \
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
p_decode = subprocess.Popen(["tivodecode", "--mak", mak, \
|
||||||
|
"--out", target, "-"], stdin=p_curl.stdout)
|
||||||
|
status = {}
|
||||||
|
(spid, sse) = os.wait()
|
||||||
|
status.update({spid: sse})
|
||||||
|
(spid, sse) = os.wait()
|
||||||
|
status.update({spid: sse})
|
||||||
|
if status.get(p_curl.pid) >> 8 != 0:
|
||||||
|
print "error downloading file: %d" % (status.get(p_curl.pid) >> 8)
|
||||||
|
os.remove(target)
|
||||||
|
raise OSError
|
||||||
|
if status.get(p_decode.pid) >> 8 != 0:
|
||||||
|
print "error decoding file: %d" % (status.get(p_decode.pid) >> 8)
|
||||||
|
os.remove(target)
|
||||||
|
raise OSError
|
||||||
|
if os.path.getsize(target) < 1024:
|
||||||
|
print "error transcoding file: too small"
|
||||||
|
os.remove(target)
|
||||||
|
raise OSError
|
||||||
|
|
||||||
def download_decode(file, url, mak, ar):
|
def download_decode(file, url, mak, ar):
|
||||||
#target = tmpmp2
|
#target = tmpmp2
|
||||||
|
@ -138,34 +165,10 @@ def download_decode(file, url, mak, ar):
|
||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
if os.path.exists(target):
|
#if os.path.exists(target):
|
||||||
print " reusing existing download file"
|
# print " reusing existing download file"
|
||||||
else:
|
#else:
|
||||||
print "--- dowloading \"%s\" (ar %s)" % (url, ar)
|
download(file, url, mak, target)
|
||||||
p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \
|
|
||||||
"--insecure", "--cookie", "tivo/.cookies.txt", \
|
|
||||||
"--silent", "--show-error", \
|
|
||||||
"--user", "tivo:%s" % mak, "--url", url], \
|
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
p_decode = subprocess.Popen(["tivodecode", "--mak", mak, \
|
|
||||||
"--out", target, "-"], stdin=p_curl.stdout)
|
|
||||||
status = {}
|
|
||||||
(spid, sse) = os.wait()
|
|
||||||
status.update({spid: sse})
|
|
||||||
(spid, sse) = os.wait()
|
|
||||||
status.update({spid: sse})
|
|
||||||
if status.get(p_curl.pid) >> 8 != 0:
|
|
||||||
print "error downloading file: %d" % (status.get(p_curl.pid) >> 8)
|
|
||||||
os.remove(target)
|
|
||||||
raise OSError
|
|
||||||
if status.get(p_decode.pid) >> 8 != 0:
|
|
||||||
print "error decoding file: %d" % (status.get(p_decode.pid) >> 8)
|
|
||||||
os.remove(target)
|
|
||||||
raise OSError
|
|
||||||
if os.path.getsize(target) < 1024:
|
|
||||||
print "error transcoding file: too small"
|
|
||||||
os.remove(target)
|
|
||||||
raise OSError
|
|
||||||
return
|
return
|
||||||
transcode(file, target, 1, ar)
|
transcode(file, target, 1, ar)
|
||||||
transcode(file, target, 2, ar)
|
transcode(file, target, 2, ar)
|
||||||
|
@ -230,6 +233,8 @@ for i in items:
|
||||||
downloaddb[name] = date
|
downloaddb[name] = date
|
||||||
if getattr(downloaddb, "sync", None) and callable(downloaddb.sync):
|
if getattr(downloaddb, "sync", None) and callable(downloaddb.sync):
|
||||||
downloaddb.sync()
|
downloaddb.sync()
|
||||||
|
# stop after the fist successful download since the tivo hangs easily
|
||||||
|
break
|
||||||
except:
|
except:
|
||||||
print "Error processing \"%s\"" % name
|
print "Error processing \"%s\"" % name
|
||||||
print "*** Completed"
|
print "*** Completed"
|
||||||
|
|
Loading…
Reference in a new issue