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 time
import twisted.web
from twisted.internet import reactor
from twisted.python import log
import twisted.web
import urlparse

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

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

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

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

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

# 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:
Container.doUpdate(self)

self.lastmodified = self.pyvr.lastmodified

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

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

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

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

print 'doing raise'
raise self.pend

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

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



Loading…
Cancel
Save