Browse Source

this now appears to be working...

import necessary modules... call doUpdate w/ no args...  fix spelling
of some vars...

order shows by the same order returned, not by title...

properly index urlparse so that we get the schema, not the tuple
which is always true.. this makes calculating the resource correct..

Things should now work!

[git-p4: depot-paths = "//depot/": change = 1114]
replace/b43bf02ddeddd088c0e6b94974ca1a46562eb3db
John-Mark Gurney 17 years ago
parent
commit
f23346c54a
1 changed files with 12 additions and 13 deletions
  1. +12
    -13
      pyvr.py

+ 12
- 13
pyvr.py View File

@@ -10,9 +10,10 @@ from FSStorage import registerklassfun


import os.path import os.path
import time import time
import twisted.web
from twisted.internet import reactor from twisted.internet import reactor
from twisted.python import log from twisted.python import log
import twisted.web
import urlparse


def getPage(url, contextFactory=None, *args, **kwargs): def getPage(url, contextFactory=None, *args, **kwargs):
"""Download a web page as a string. """Download a web page as a string.
@@ -45,7 +46,7 @@ class PYVRShow(VideoItem):
VideoItem.__init__(self, *args, **kwargs) VideoItem.__init__(self, *args, **kwargs)


url = self.info['link'] url = self.info['link']
sc = urlparse.urlparse(url)
sc = urlparse.urlparse(url)[0]
if not sc: if not sc:
# need to combine w/ base url # need to combine w/ base url
url = urlparse.urljoin(baseurl, url) url = urlparse.urljoin(baseurl, url)
@@ -111,25 +112,26 @@ class PYVRShows(Container):
def checkUpdate(self): def checkUpdate(self):
self.pyvr.checkUpdate() self.pyvr.checkUpdate()
if self.pyvr.lastmodified != self.lastmodified: if self.pyvr.lastmodified != self.lastmodified:
self.doUpdate(self)
self.doUpdate()


@staticmethod @staticmethod
def getunique(eps, ep): def getunique(eps, ep):
i = 1 i = 1
while True: while True:
title = '%s Copy %d' % (ep['subtitle'], i) title = '%s Copy %d' % (ep['subtitle'], i)
if not ret.has_key(title):
if not eps.has_key(title):
return title return title
i += 1 i += 1


@staticmethod @staticmethod
def eplisttodict(eps): def eplisttodict(eps):
ret = {} ret = {}
for i in eps:
for pos, i in enumerate(eps):
title = i['subtitle'] title = i['subtitle']
if ret.has_key(title): if ret.has_key(title):
print 'WARNING: dup:', `i`, `ret[title]` print 'WARNING: dup:', `i`, `ret[title]`
title = self.getunique(ret, i)
title = PYVRShows.getunique(ret, i)
i['pos'] = pos
ret[title] = i ret[title] = i


return ret return ret
@@ -158,10 +160,13 @@ class PYVRShows(Container):
self.shows = nl self.shows = nl


# sort our children # sort our children
self.sort(lambda x, y: cmp(x.title, y.title))
#self.sort(lambda x, y: cmp(x.title, y.title))
self.sort(lambda x, y: cmp(x.info['pos'], y.info['pos']))
if doupdate: if doupdate:
Container.doUpdate(self) Container.doUpdate(self)


self.lastmodified = self.pyvr.lastmodified

class PYVR(Container): class PYVR(Container):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.url = kwargs['url'] self.url = kwargs['url']
@@ -178,11 +183,9 @@ class PYVR(Container):


def checkUpdate(self): def checkUpdate(self):
if self.isPend: if self.isPend:
print 'already'
raise self.pend raise self.pend


if time.time() - self.lastcheck < 5: if time.time() - self.lastcheck < 5:
print 'escape'
return return


# Check to see if any changes have been made # Check to see if any changes have been made
@@ -192,11 +195,9 @@ class PYVR(Container):
self.page.deferred.addCallback(self.doCheck) self.page.deferred.addCallback(self.doCheck)
self.pend = self.page.deferred self.pend = self.page.deferred


print 'doing raise'
raise self.pend raise self.pend


def doCheck(self, x): def doCheck(self, x):
print 'got check'
print `self.page.response_headers` print `self.page.response_headers`
slm = self.page.response_headers['last-modified'] slm = self.page.response_headers['last-modified']
if slm == self.lastmodified: if slm == self.lastmodified:
@@ -211,7 +212,6 @@ class PYVR(Container):
return self.pend return self.pend


def parsePage(self, page): def parsePage(self, page):
print 'parsing'
slm = self.page.response_headers['last-modified'] slm = self.page.response_headers['last-modified']
self.lastmodified = slm self.lastmodified = slm
self.isPend = False self.isPend = False
@@ -261,7 +261,6 @@ class PYVR(Container):
def detectpyvrfile(path, fobj): def detectpyvrfile(path, fobj):
bn = os.path.basename(path) bn = os.path.basename(path)
if bn == 'PYVR': if bn == 'PYVR':
print 'detected'
return PYVR, { 'url': fobj.readline().strip() } return PYVR, { 'url': fobj.readline().strip() }
return None, None return None, None




Loading…
Cancel
Save