Unsinn wieder ausbauen, jetzt wo das Routing wieder geht
This commit is contained in:
parent
a03a8c8cbe
commit
f6be7dc724
1 changed files with 26 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/local/bin/python
|
||||
|
||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.44 2011/09/15 11:08:11 stb Exp $
|
||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.45 2011/10/12 16:31:01 stb Exp $
|
||||
#
|
||||
# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4
|
||||
# zu transkodieren.
|
||||
|
@ -45,6 +45,7 @@ includes['The Big Bang Theory'] = 1
|
|||
includes['The Colbert Report'] = 1
|
||||
includes['The Daily Show With Jon Stewart'] = 1
|
||||
includes['The Late Late Show With Craig Ferguson'] = 1
|
||||
includes['IGenius: How Steve Jobs Changed the World'] = 1
|
||||
|
||||
|
||||
class flushfile(object):
|
||||
|
@ -77,8 +78,9 @@ class TivoItem:
|
|||
def __init__(self, i):
|
||||
self.title = getTagText(i, "Title")
|
||||
self.episode = getTagText(i, "EpisodeTitle")
|
||||
self.date = getTagText(i, "CaptureDate")
|
||||
self.date = datetime.datetime.utcfromtimestamp(int(self.date, 16))
|
||||
d = getTagText(i, "CaptureDate")
|
||||
self.date = datetime.datetime.utcfromtimestamp(int(d, 16))
|
||||
self.time = int(d, base=0)
|
||||
self.datestr = self.date.strftime("%Y%m%d-%H%M")
|
||||
self.url = getTagText(i, "Url")
|
||||
self.inprogress = getTagText(i, "InProgress")
|
||||
|
@ -132,8 +134,16 @@ def quit_process(pid):
|
|||
|
||||
def waitForProcs(pids):
|
||||
success = True
|
||||
starttime = time.time()
|
||||
while len(pids) > 0:
|
||||
(spid, sse) = os.wait()
|
||||
(spid, sse) = os.waitpid(0, os.WNOHANG)
|
||||
if spid == 0:
|
||||
if 0 && time.time() - starttime > 6 * 60 * 60:
|
||||
for pid in pids:
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
raise TivoException("waiting for download to complete exceeded timeout")
|
||||
time.sleep(2)
|
||||
continue
|
||||
pids.remove(spid)
|
||||
if os.WIFSIGNALED(sse) \
|
||||
or (os.WIFEXITED(sse) and os.WEXITSTATUS(sse) != 0):
|
||||
|
@ -148,9 +158,12 @@ def waitForProcs(pids):
|
|||
quit_process(pid)
|
||||
if not success:
|
||||
raise TivoException("error executing processes")
|
||||
pass
|
||||
|
||||
|
||||
def download(file, url, mak, target):
|
||||
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
||||
#url = re.sub("tivo.lassitu.de:80", "krokodil-vpn.zs64.net:8888", url)
|
||||
print "--- downloading \"%s\"" % (url)
|
||||
start = time.time()
|
||||
p_curl = subprocess.Popen(["curl", "--anyauth", "--fail", \
|
||||
|
@ -186,20 +199,23 @@ def download_decode(item, mak):
|
|||
os.makedirs(item.dir)
|
||||
except OSError:
|
||||
pass
|
||||
if os.path.exists(target):
|
||||
if 0 & os.path.exists(target):
|
||||
print " reusing existing download file"
|
||||
else:
|
||||
try:
|
||||
download(item.file, item.url, mak, target)
|
||||
except Exception, e:
|
||||
try:
|
||||
os.remove(target)
|
||||
raise
|
||||
except Exception, e2:
|
||||
pass
|
||||
raise e
|
||||
#tivomp4.transcode(target, mp4, item.ar)
|
||||
try:
|
||||
os.utime(target, (item.date, item.date))
|
||||
os.utime(target, (item.time, item.time))
|
||||
#os.utime(mp4, [item.date, item.date])
|
||||
except Exception, e:
|
||||
print "Urgh:", e
|
||||
print "Problem setting timestamp: ", e
|
||||
|
||||
|
||||
def savetoc(toc):
|
||||
|
@ -265,7 +281,7 @@ def main():
|
|||
except TivoException, e:
|
||||
print "Error processing \"%s\": %s" % (item.name, e)
|
||||
|
||||
print "*** Completed"
|
||||
print "*** Completed %s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
downloaddb.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue