Fehler beim Dekodieren auch hochwerfen, schoener loggen
This commit is contained in:
parent
24be7bddfc
commit
e7b935535e
1 changed files with 35 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/python
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.62 2014/07/05 15:19:39 stb Exp $
|
# $Schlepperbande: src/tivomirror/tivomirror,v 1.63 2014/07/05 15:23:02 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.
|
||||||
|
@ -33,6 +33,7 @@ import xml.dom.minidom
|
||||||
import tivomp4
|
import tivomp4
|
||||||
|
|
||||||
host = "tivo.lassitu.de"
|
host = "tivo.lassitu.de"
|
||||||
|
#host = "wavehh.lassitu.de:30080"
|
||||||
mak = "7194378159"
|
mak = "7194378159"
|
||||||
targetdir = "/p1/media/TV"
|
targetdir = "/p1/media/TV"
|
||||||
gig = 1024.0 * 1024 * 1024
|
gig = 1024.0 * 1024 * 1024
|
||||||
|
@ -46,6 +47,7 @@ includes['Brooklyn Nine-Nine'] = 1
|
||||||
includes['Castle'] = 1
|
includes['Castle'] = 1
|
||||||
includes['Family Guy'] = 1
|
includes['Family Guy'] = 1
|
||||||
includes['Hot in Cleveland'] = 1
|
includes['Hot in Cleveland'] = 1
|
||||||
|
includes["How It's Made"] = 1
|
||||||
includes['Late Show With David Letterman'] = 1
|
includes['Late Show With David Letterman'] = 1
|
||||||
includes['Louie'] = 1
|
includes['Louie'] = 1
|
||||||
includes['Mad Men'] = 1
|
includes['Mad Men'] = 1
|
||||||
|
@ -80,6 +82,7 @@ tmp = "/tmp"
|
||||||
session = requests.session()
|
session = requests.session()
|
||||||
session.verify = False
|
session.verify = False
|
||||||
session.auth = requests.auth.HTTPDigestAuth("tivo", mak)
|
session.auth = requests.auth.HTTPDigestAuth("tivo", mak)
|
||||||
|
session.keep_alive = False
|
||||||
|
|
||||||
|
|
||||||
class TimeoutError(Exception):
|
class TimeoutError(Exception):
|
||||||
|
@ -268,17 +271,22 @@ class FdLogger(threading.Thread):
|
||||||
self.logger.exception("")
|
self.logger.exception("")
|
||||||
|
|
||||||
|
|
||||||
@timeout(7200)
|
@timeout(43200)
|
||||||
def download(url, mak, target):
|
#@timeout(7200)
|
||||||
|
def download(item, mak, target):
|
||||||
global session
|
global session
|
||||||
count = 0
|
count = 0
|
||||||
start = time.time()
|
start = time.time()
|
||||||
upd = start
|
upd = start
|
||||||
|
url = item.url
|
||||||
|
#url = re.sub("tivo.lassitu.de:80", "wavehh.lassitu.de:30080", url)
|
||||||
|
#url = re.sub("wavehh.lassitu.de:80", "wavehh.lassitu.de:30080", url)
|
||||||
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
||||||
#url = re.sub("tivo.lassitu.de:80", "krokodil-vpn.zs64.net:8888", url)
|
#url = re.sub("tivo.lassitu.de:80", "krokodil-vpn.zs64.net:8888", url)
|
||||||
logger.info("--- downloading \"%s\"" % (url))
|
logger.info("--- downloading \"%s\"" % (url))
|
||||||
start = time.time()
|
start = time.time()
|
||||||
r = session.get(url, stream=True)
|
r = session.get(url, stream=True)
|
||||||
|
#r = session.get(url, stream=True, proxies={"http":"http://wavehh:8888","https":"http://wavehh:8888"})
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -286,13 +294,18 @@ def download(url, mak, target):
|
||||||
"--no-verify", "--out", target, "-"], stdin=subprocess.PIPE,
|
"--no-verify", "--out", target, "-"], stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
FdLogger(logger, logging.INFO, p_decode.stdout)
|
FdLogger(logger, logging.INFO, p_decode.stdout)
|
||||||
FdLogger(logger, logging.ERROR, p_decode.stderr)
|
FdLogger(logger, logging.INFO, p_decode.stderr)
|
||||||
def info(signum, frame):
|
def info(signum, frame):
|
||||||
upd = time.time()
|
upd = time.time()
|
||||||
dur = now - start
|
dur = now - start
|
||||||
mb = count / 1e6
|
mb = count / 1e6
|
||||||
print "%5.3f GB downloaded in %.0f min, %.3f MB/s" % (mb / 1e3, dur / 60, mb / dur)
|
print "%5.1f%% %5.3f GB downloaded in %.0f min, %.3f MB/s" % (
|
||||||
|
100.0 * count / item.sourcesize,
|
||||||
|
mb / 1e3, dur / 60, mb / dur)
|
||||||
|
try:
|
||||||
signal.signal(signal.SIGINFO, info)
|
signal.signal(signal.SIGINFO, info)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0) # yield to logger threads
|
time.sleep(0) # yield to logger threads
|
||||||
chunk = r.raw.read(65536)
|
chunk = r.raw.read(65536)
|
||||||
|
@ -306,11 +319,17 @@ def download(url, mak, target):
|
||||||
upd = now
|
upd = now
|
||||||
dur = now - start
|
dur = now - start
|
||||||
mb = count / 1e6
|
mb = count / 1e6
|
||||||
logger.debug(" %5.3f GB downloaded in %.0f min, %.3f MB/s" % (mb / 1e3, dur / 60, mb / dur))
|
logger.debug(" %5.1f%% %5.3f GB downloaded in %.0f min, %.3f MB/s" % (
|
||||||
except Exception, e:
|
100.0 * count / item.sourcesize,
|
||||||
|
mb / 1e3, dur / 60, mb / dur))
|
||||||
|
except Exception as e:
|
||||||
logger.error("problem decoding: %s" % (e))
|
logger.error("problem decoding: %s" % (e))
|
||||||
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
try:
|
||||||
signal.signal(signal.SIGINFO, signal.SIG_IGN)
|
signal.signal(signal.SIGINFO, signal.SIG_IGN)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
throughput = count / elapsed
|
throughput = count / elapsed
|
||||||
logger.info("%5.3fGB transferred in %d:%02d, %.1f MB/s" % (
|
logger.info("%5.3fGB transferred in %d:%02d, %.1f MB/s" % (
|
||||||
|
@ -346,7 +365,7 @@ def download_decode(item, mak):
|
||||||
logger.info(" reusing existing download file")
|
logger.info(" reusing existing download file")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
download(item.url, mak, target)
|
download(item, mak, target)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
try:
|
try:
|
||||||
|
@ -392,7 +411,7 @@ def wantitem(item, downloaddb):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def mirror(toc, downloaddb):
|
def mirror(toc, downloaddb, one=False):
|
||||||
avail = getAvail(targetdir)
|
avail = getAvail(targetdir)
|
||||||
if avail < minfree:
|
if avail < minfree:
|
||||||
logger.error("%s: %.1fG available, at least %.1fG needed, stopping" % \
|
logger.error("%s: %.1fG available, at least %.1fG needed, stopping" % \
|
||||||
|
@ -403,12 +422,13 @@ def mirror(toc, downloaddb):
|
||||||
logger.info("*** %d shows listed" % (items.length))
|
logger.info("*** %d shows listed" % (items.length))
|
||||||
for node in items:
|
for node in items:
|
||||||
item = TivoItem(node)
|
item = TivoItem(node)
|
||||||
|
|
||||||
reason = wantitem(item, downloaddb)
|
reason = wantitem(item, downloaddb)
|
||||||
if reason != "":
|
if reason != "":
|
||||||
logger.debug("*** skipping \"%s\": %s" % (item.name, reason))
|
logger.debug("*** skipping \"%s\": %s" % (item.name, reason))
|
||||||
else:
|
else:
|
||||||
download_one(item, downloaddb)
|
download_one(item, downloaddb)
|
||||||
|
if one:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
def download_episode(toc, downloaddb, episode):
|
def download_episode(toc, downloaddb, episode):
|
||||||
|
@ -461,7 +481,6 @@ def main():
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
if opt in ('-u', '--update'):
|
if opt in ('-u', '--update'):
|
||||||
updateToc = True
|
updateToc = True
|
||||||
toc.download()
|
|
||||||
if opt in ('-T', '--ignoreepisodetitle'):
|
if opt in ('-T', '--ignoreepisodetitle'):
|
||||||
ignoreepisodetitle = True
|
ignoreepisodetitle = True
|
||||||
|
|
||||||
|
@ -475,6 +494,8 @@ def main():
|
||||||
|
|
||||||
if cmd == "mirror":
|
if cmd == "mirror":
|
||||||
mirror(toc, downloaddb)
|
mirror(toc, downloaddb)
|
||||||
|
elif cmd == "mirrorone":
|
||||||
|
mirror(toc, downloaddb, True)
|
||||||
elif cmd == "list":
|
elif cmd == "list":
|
||||||
printtoc(toc, downloaddb)
|
printtoc(toc, downloaddb)
|
||||||
elif cmd == "download":
|
elif cmd == "download":
|
||||||
|
|
Loading…
Reference in a new issue