Schoenheit

This commit is contained in:
Stefan Bethke 2010-12-18 22:53:24 +00:00
parent 045d6f88b0
commit 9fe8a84533

View file

@ -1,6 +1,6 @@
#!/usr/local/bin/python #!/usr/local/bin/python
# $Schlepperbande: src/tivomirror/tivomirror,v 1.37 2010/12/18 09:12:01 stb Exp $ # $Schlepperbande: src/tivomirror/tivomirror,v 1.38 2010/12/18 10:03:31 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.
@ -16,6 +16,7 @@ import signal
import shutil import shutil
import subprocess import subprocess
import sys import sys
import time
import urllib2 import urllib2
import xml.dom.minidom import xml.dom.minidom
@ -175,6 +176,7 @@ def transcode(file, src, passno, ar):
def download(file, url, mak, target): def download(file, url, mak, target):
print "--- dowloading \"%s\"" % (url) print "--- dowloading \"%s\"" % (url)
start = time.clock()
p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \ p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \
"--insecure", "--cookie", "tivo/.cookies.txt", \ "--insecure", "--cookie", "tivo/.cookies.txt", \
"--silent", "--show-error", \ "--silent", "--show-error", \
@ -190,10 +192,14 @@ def download(file, url, mak, target):
except OSError: except OSError:
pass pass
raise e raise e
if os.path.getsize(target) < 1024: size = os.path.getsize(target)
if size < 1024:
print "error transcoding file: too small" print "error transcoding file: too small"
os.remove(target) os.remove(target)
raise TivoException("downloaded file is too small") raise TivoException("downloaded file is too small")
elapsed = time.clock() - start
throughput = size / elapsed
print "%d bytes transferred in %d seconds, %4.1fk/s" % (size, elapsed, throughput / 1000.0)
def download_decode(file, url, mak, ar): def download_decode(file, url, mak, ar):
@ -248,6 +254,7 @@ for i in items:
url = getTagText(i, "Url") url = getTagText(i, "Url")
inprogress = getTagText(i, "InProgress") inprogress = getTagText(i, "InProgress")
available = getTagText(i, "Available") available = getTagText(i, "Available")
sourcesize = int(getTagText(i, "SourceSize"))
if episode == "": if episode == "":
episode = date episode = date
name = "%s - %s" % (title, episode) name = "%s - %s" % (title, episode)
@ -269,12 +276,12 @@ for i in items:
print "*** skipping \"%s\": is not available" % name print "*** skipping \"%s\": is not available" % name
continue continue
if downloaddb.has_key(name): if downloaddb.has_key(name):
print "*** skipping \"%s\": already downloaded" % name #print "*** skipping \"%s\": already downloaded" % name
continue continue
if excludes.has_key(title) or excludes.has_key(episode) or excludes.has_key(name): if excludes.has_key(title) or excludes.has_key(episode) or excludes.has_key(name):
print "*** skipping \"%s\": excluded" % name print "*** skipping \"%s\": excluded" % name
continue continue
print "*** downloading \"%s\"" % name print "*** downloading \"%s\": %.3fGB" % (name, sourcesize / 1e9)
try: try:
download_decode(file, url, mak, ar) download_decode(file, url, mak, ar)
downloaddb[name] = date downloaddb[name] = date