Der Roamio gibt max. 50 Items per Aufruf aus, iterativ alle Seiten der TOC laden, vgl. http://www.tivocommunity.com/tivo-vb/showthread.php?t=515766
This commit is contained in:
parent
f8715d1ea8
commit
a78cb432f2
1 changed files with 39 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/python
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
# $Schlepperbande: src/tivomirror/tivomirror,v 1.53 2014/05/30 20:53:01 stb Exp $
|
# $Schlepperbande: src/tivomirror/tivomirror,v 1.54 2014/05/31 11:42:06 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.
|
||||||
|
@ -45,7 +45,7 @@ includes['Castle'] = 1
|
||||||
includes['Cosmos: A Spacetime Odyssey'] = 1
|
includes['Cosmos: A Spacetime Odyssey'] = 1
|
||||||
includes['Family Guy'] = 1
|
includes['Family Guy'] = 1
|
||||||
includes['Hot in Cleveland'] = 1
|
includes['Hot in Cleveland'] = 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['Modern Family'] = 1
|
includes['Modern Family'] = 1
|
||||||
|
@ -55,10 +55,10 @@ includes['NFL Football'] = 1
|
||||||
includes['Person of Interest'] = 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['The Tonight Show Starring Jimmy Fallon'] = 1
|
||||||
|
|
||||||
|
|
||||||
class flushfile(object):
|
class flushfile(object):
|
||||||
|
@ -187,22 +187,43 @@ def get_cookie_by_name(cj, name):
|
||||||
return [cookie for cookie in cj if cookie.name == name][0]
|
return [cookie for cookie in cj if cookie.name == name][0]
|
||||||
|
|
||||||
|
|
||||||
def gettoc():
|
def loadtoc(offset):
|
||||||
global session
|
global session
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'Command': 'QueryContainer',
|
'Command': 'QueryContainer',
|
||||||
'Container': '/NowPlaying',
|
'Container': '/NowPlaying',
|
||||||
'Recurse': 'Yes',
|
'Recurse': 'Yes',
|
||||||
'ItemCount': '50'
|
'ItemCount': '50',
|
||||||
|
'AnchorOffset': offset
|
||||||
}
|
}
|
||||||
url = "https://{}/TiVoConnect".format(host)
|
url = "https://{}/TiVoConnect".format(host)
|
||||||
|
print " offset %d" % (offset)
|
||||||
r = session.get(url, params=params)
|
r = session.get(url, params=params)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.text
|
return r.text
|
||||||
|
|
||||||
|
|
||||||
|
def gettoc():
|
||||||
|
offset = 0
|
||||||
|
itemCount = 1
|
||||||
|
dom = None
|
||||||
|
root = None
|
||||||
|
while itemCount > 0:
|
||||||
|
dom1 = xml.dom.minidom.parseString(loadtoc(offset))
|
||||||
|
if dom == None:
|
||||||
|
dom = dom1
|
||||||
|
root = dom.childNodes.item(0)
|
||||||
|
else:
|
||||||
|
for child in dom1.childNodes.item(0).childNodes:
|
||||||
|
if child.nodeName == "Item":
|
||||||
|
root.appendChild(child.cloneNode(True))
|
||||||
|
itemCount = int(getElementText(dom1.documentElement.childNodes, "ItemCount"))
|
||||||
|
offset += itemCount
|
||||||
|
return dom
|
||||||
|
|
||||||
|
|
||||||
def getText(nodelist):
|
def getText(nodelist):
|
||||||
rc = ""
|
rc = ""
|
||||||
for node in nodelist:
|
for node in nodelist:
|
||||||
|
@ -216,6 +237,12 @@ def getTagText(element, tagname):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def getElementText(nodes, name):
|
||||||
|
for node in nodes:
|
||||||
|
if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.nodeName == name:
|
||||||
|
return getText(node.childNodes)
|
||||||
|
return None
|
||||||
|
|
||||||
def getAvail(dir):
|
def getAvail(dir):
|
||||||
s = os.statvfs(dir)
|
s = os.statvfs(dir)
|
||||||
return s.f_bsize * s.f_bavail
|
return s.f_bsize * s.f_bavail
|
||||||
|
@ -299,9 +326,9 @@ def download_decode(item, mak):
|
||||||
print "Problem setting timestamp: ", e
|
print "Problem setting timestamp: ", e
|
||||||
|
|
||||||
|
|
||||||
def savetoc(toc):
|
def savetoc(dom):
|
||||||
fd=open("toc.xml", "w")
|
fd=open("toc.xml", "w")
|
||||||
fd.write(toc)
|
fd.write(dom.toprettyxml())
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,9 +406,8 @@ def main():
|
||||||
ignoreepisodetitle = True
|
ignoreepisodetitle = True
|
||||||
downloaddb = anydbm.open(os.path.expanduser("~") + "/.tivo-downloads", "c")
|
downloaddb = anydbm.open(os.path.expanduser("~") + "/.tivo-downloads", "c")
|
||||||
print "*** Getting listing"
|
print "*** Getting listing"
|
||||||
toc = gettoc()
|
dom = gettoc()
|
||||||
savetoc(toc)
|
savetoc(dom)
|
||||||
dom = xml.dom.minidom.parseString(toc)
|
|
||||||
|
|
||||||
if len(remainder) == 1:
|
if len(remainder) == 1:
|
||||||
if remainder[0] == "list":
|
if remainder[0] == "list":
|
||||||
|
|
Loading…
Reference in a new issue