@@ -52,7 +52,7 @@ class PYVRShow(VideoItem):
url = urlparse.urljoin(baseurl, url)
url = urlparse.urljoin(baseurl, url)
self.res = Resource(url,
self.res = Resource(url,
'http-get:*:%s:*' % self.info['mimetype'])
'http-get:*:%s:*' % self.info['mimetype'])
#self.res.size = self.chapter.size
self.res.duration = self.info['duration']
def doUpdate(self):
def doUpdate(self):
pass
pass
@@ -62,6 +62,9 @@ import xml.sax.handler
from xml.sax.saxutils import unescape
from xml.sax.saxutils import unescape
class RecordingXML(xml.sax.handler.ContentHandler):
class RecordingXML(xml.sax.handler.ContentHandler):
dataels = ('title', 'subtitle', 'duration', 'mimetype', 'link',
'delete', )
def __init__(self):
def __init__(self):
self.shows = {}
self.shows = {}
self.data = None
self.data = None
@@ -71,14 +74,14 @@ class RecordingXML(xml.sax.handler.ContentHandler):
self.data.append(chars)
self.data.append(chars)
def startElement(self, name, attrs):
def startElement(self, name, attrs):
if name in ('title', 'subtitle', 'mimetype', 'link', 'delete') :
if name in self.dataels :
self.data = []
self.data = []
self.curel = name
self.curel = name
elif name == 'record':
elif name == 'record':
self.currec = {}
self.currec = {}
def endElement(self, name):
def endElement(self, name):
if name in ('title', 'subtitle', 'mimetype', 'link', 'delete') :
if name in dataels :
data = unescape(''.join(self.data))
data = unescape(''.join(self.data))
self.currec[self.curel] = data
self.currec[self.curel] = data
elif name == 'record':
elif name == 'record':
@@ -175,33 +178,46 @@ class PYVR(Container):
Container.__init__(self, *args, **kwargs)
Container.__init__(self, *args, **kwargs)
self.pathObjmap = {}
self.pathObjmap = {}
self.isPend = Fals e
self.pend = Non e
self.lastmodified = None
self.lastmodified = None
self.newobjs = None
self.newobjs = None
self.objs = {}
self.objs = {}
self.lastcheck = 0
self.lastcheck = 0
def checkUpdate(self):
def checkUpdate(self):
if self.isPend :
if self.pend is not None :
raise self.pend
raise self.pend
if time.time() - self.lastcheck < 5:
if time.time() - self.lastcheck < 5:
print '<5'
return
return
# Check to see if any changes have been made
# Check to see if any changes have been made
self.isPend = True
self.lastcheck = time.time()
self.runCheck()
raise self.pend
def runCheck(self):
print 'runCheck'
self.page = getPage(self.url, method='HEAD')
self.page = getPage(self.url, method='HEAD')
self.page.deferred.addCallback(self.doCheck)
self.page.deferred.addErrback(self.errCheck).addCallback(
self.doCheck)
self.pend = self.page.deferred
self.pend = self.page.deferred
raise self.pend
def errCheck(self, x):
print 'errCheck:', `x`
self.runCheck()
def doCheck(self, x):
def doCheck(self, x):
print 'doCheck:', self.page.status
if self.page.status != '200':
return reactor.callLater(.01, self.runCheck)
self.lastcheck = time.time()
slm = self.page.response_headers['last-modified']
slm = self.page.response_headers['last-modified']
if slm == self.lastmodified:
if slm == self.lastmodified:
# Page the same, don't do anything
# Page the same, don't do anything
self.isPend = False
self.pend = Non e
return
return
self.page = getPage(self.url)
self.page = getPage(self.url)
@@ -213,9 +229,8 @@ class PYVR(Container):
def parsePage(self, page):
def parsePage(self, page):
slm = self.page.response_headers['last-modified']
slm = self.page.response_headers['last-modified']
self.lastmodified = slm
self.lastmodified = slm
self.isPend = False
del self.page
del self.page
del self.pend
self.pend = None
self.newobjs = recxmltoobj(page)
self.newobjs = recxmltoobj(page)
self.doUpdate()
self.doUpdate()