Alle neuen Shows am Stueck downloaden, dafuer aber mit Timeout von drei Stunden pro Show.
This commit is contained in:
parent
f829eafc5e
commit
832574e06b
1 changed files with 36 additions and 7 deletions
|
@ -1,16 +1,22 @@
|
||||||
#!/usr/local/bin/python
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.50 2013/03/16 09:54:12 stb Exp $
|
# $Schlepperbande: src/tivomirror/tivomirror,v 1.51 2013/08/06 22:17:16 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.
|
||||||
# Wird auf disklesslibber per Crontab-Eintrag stuendlich gestartet:
|
# Wird auf disklesslibber per Crontab-Eintrag stuendlich gestartet:
|
||||||
# flock -n /tmp/tivomirror.log -c 'tivomirror >.tivomirror.log 2>&1 </dev/null'
|
# flock -n /tmp/tivomirror.log -c 'tivomirror >.tivomirror.log 2>&1 </dev/null'
|
||||||
|
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf-8')
|
||||||
|
|
||||||
import anydbm
|
import anydbm
|
||||||
import cookielib
|
import cookielib
|
||||||
import datetime
|
import datetime
|
||||||
import getopt
|
import getopt
|
||||||
|
import errno
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
@ -34,25 +40,25 @@ arset = dict()
|
||||||
arset["Futurama"] = 169
|
arset["Futurama"] = 169
|
||||||
|
|
||||||
includes = dict()
|
includes = dict()
|
||||||
includes['Breaking Bad'] = 1
|
includes['Almost Human'] = 1
|
||||||
|
includes['Brooklyn Nine-Nine'] = 1
|
||||||
includes['Castle'] = 1
|
includes['Castle'] = 1
|
||||||
includes['Dirty Jobs'] = 1
|
|
||||||
includes['Family Guy'] = 1
|
includes['Family Guy'] = 1
|
||||||
includes['Futurama'] = 1
|
|
||||||
includes["John Oliver's New York Stand-Up Show"] = 1
|
includes["John Oliver's New York Stand-Up Show"] = 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
|
||||||
includes['Mockingbird Lane'] = 1
|
|
||||||
includes['Modern Family'] = 1
|
includes['Modern Family'] = 1
|
||||||
includes['MythBusters'] = 1
|
includes['MythBusters'] = 1
|
||||||
includes['NCIS'] = 1
|
includes['NCIS'] = 1
|
||||||
includes['NFL Football'] = 1
|
includes['NFL Football'] = 1
|
||||||
|
includes['Person of Interest'] = 1
|
||||||
includes['Sesame Street'] = 1
|
includes['Sesame Street'] = 1
|
||||||
includes['The Big Bang Theory'] = 1
|
includes['The Big Bang Theory'] = 1
|
||||||
includes['The Colbert Report'] = 1
|
includes['The Colbert Report'] = 1
|
||||||
includes['The Daily Show With Jon Stewart'] = 1
|
includes['The Daily Show With Jon Stewart'] = 1
|
||||||
includes['The Late Late Show With Craig Ferguson'] = 1
|
includes['The Late Late Show With Craig Ferguson'] = 1
|
||||||
|
includes['The Tonight Show Starring Jimmy Fallon'] = 1
|
||||||
|
|
||||||
includes['CONSTITUTION USA With Peter Sagal'] = 1;
|
includes['CONSTITUTION USA With Peter Sagal'] = 1;
|
||||||
|
|
||||||
|
@ -77,6 +83,28 @@ session.verify = False
|
||||||
session.auth = requests.auth.HTTPDigestAuth("tivo", mak)
|
session.auth = requests.auth.HTTPDigestAuth("tivo", mak)
|
||||||
|
|
||||||
|
|
||||||
|
class TimeoutError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def timeout(seconds=10, error_message=os.strerror(errno.ETIMEDOUT)):
|
||||||
|
def decorator(func):
|
||||||
|
def _handle_timeout(signum, frame):
|
||||||
|
raise TimeoutError(error_message)
|
||||||
|
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
signal.signal(signal.SIGALRM, _handle_timeout)
|
||||||
|
signal.alarm(seconds)
|
||||||
|
try:
|
||||||
|
result = func(*args, **kwargs)
|
||||||
|
finally:
|
||||||
|
signal.alarm(0)
|
||||||
|
return result
|
||||||
|
|
||||||
|
return functools.wraps(func)(wrapper)
|
||||||
|
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def trimDescription(desc):
|
def trimDescription(desc):
|
||||||
desc = desc.strip()
|
desc = desc.strip()
|
||||||
i = desc.rfind(". Copyright Tribune Media Services, Inc.");
|
i = desc.rfind(". Copyright Tribune Media Services, Inc.");
|
||||||
|
@ -202,6 +230,7 @@ def quit_process(pid):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@timeout(7200)
|
||||||
def download(file, url, mak, target):
|
def download(file, url, mak, target):
|
||||||
global browser, sidcookie
|
global browser, sidcookie
|
||||||
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
||||||
|
@ -308,8 +337,8 @@ def mirror(dom, downloaddb):
|
||||||
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 first successful download since the tivo hangs easily
|
# stop after the first successful download since the tivo hangs easily
|
||||||
print "Stopping after one successful transfer"
|
#print "Stopping after one successful transfer"
|
||||||
break
|
#break
|
||||||
except TivoException, e:
|
except TivoException, e:
|
||||||
print "Error processing \"%s\": %s" % (item.name, e)
|
print "Error processing \"%s\": %s" % (item.name, e)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue