diff --git a/src/tivomirror/tivomirror b/src/tivomirror/tivomirror new file mode 100755 index 0000000..4bbdc20 --- /dev/null +++ b/src/tivomirror/tivomirror @@ -0,0 +1,168 @@ +#!/usr/bin/python + +# $Schlepperbande$ +# +# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4 +# zu transkodieren. +# Wird auf disklesslibber per Crontab-Eintrag stuendlich gestartet: +# flock -n /tmp/tivomirror.log -c 'tivomirror >.tivomirror.log 2>&1 > 8 != 0: + print "error downloading file: %d" % (status.get(p_curl.pid) >> 8) + exit(1) + if status.get(p_decode.pid) >> 8 != 0: + print "error decoding file: %d" % (status.get(p_decode.pid) >> 8) + exit(1) + transcode(file, 1) + transcode(file, 2) + print "--- copying to \"%s\"" % file + shutil.copy(tmpmp4, "%s.mp4" % file) + os.remove(tmpmp2) + os.remove(tmpmp4) + +def savetoc(): + fd=open("foo.xml", "w") + fd.write(gettoc()) + fd.close() + exit(0) + + +downloaddb = anydbm.open("tivo/.downloads", "c") +print "*** Getting listing" +dom = xml.dom.minidom.parseString(gettoc()) +cookiejar.save() + +items = dom.getElementsByTagName("Item") +print "*** %d shows listed" % (items.length) +for i in items: + title = getTagText(i, "Title") + episode = getTagText(i, "EpisodeTitle") + date = getTagText(i, "CaptureDate") + date = datetime.datetime.utcfromtimestamp(int(date, 16)) + date = date.strftime("%Y%m%d-%H%M") + url = getTagText(i, "Url") + inprogress = getTagText(i, "InProgress") + if episode == "": + episode = date + name = "%s - %s" % (title, episode) + dir = "tivo/%s" % (title) + file = "%s/%s" % (dir, name) + name = name.encode("utf-8"); + dir = dir.encode("utf-8"); + file = file.encode("utf-8"); + + if inprogress == "Yes": + print "*** skipping \"%s\": is currently being recorded" % name + continue + if downloaddb.has_key(name): + print "*** skipping \"%s\": already downloaded" % name + continue + print "*** downloading \"%s\"" % name + download_decode(file, url, mak) + downloaddb[name] = date + if getattr(downloaddb, "sync", None) and callable(downloaddb.sync): + downloaddb.sync() +print "*** Completed" + +downloaddb.close()