Simple photo channel (webcam)

Hi there

 

As a start: I'm not a developer and have no programming skills - so please excuse :blink:

 

I'm trying to build a (very) simple photo channel, fetching a few images, that are available through a direct link (to a *,jpg) coming from webcams...

 

I analyzed the source of the existing photo channels, did some research in the forum and finally managed to have my photo channel displayed under my plex channels, displaying the photos as wished - so far so good.

 

The problem I'm encountering is that the photos are not refreshed at all - they are somewhere cached, I tried:

	HTTP.CacheTime = CACHE_1MINUTE
	HTTP.ClearCache()
	HTTP.PreCache('...url...')

... but nothing...

 

I'm adding each photo to the MediaContainer like so:

dir = MediaContainer(noCache=True)

title = ‘Gandegg1’
thumb = Resource.ContentsOfURLWithFallback(url=‘http://www.loetschental.ch/webcams/3/2.jpg’, fallback=‘icon-default.png’)
photo = Resource.ContentsOfURLWithFallback(url=‘http://www.loetschental.ch/webcams/3/2.jpg’)
dir.Append(PhotoItem(photo, title=title, thumb=thumb))

As the photos are of small size, i use the same source as thumb and as photo itself - I'm certain, that this is a bad hack and not elegant at all  -_-

 

So... how to have all photos / links refreshed when the channel is loaded??

 

Thanks and cheers!

 

 

 

First things first. You're using the soon-to-be-deprecated framework api. You should really use the latest framework code as described in the development docs. I realize that there are not a lot of photo channels available to use as a starting point, but I suggest looking at the code for the CatsPawImages channel. Specifically, here.

You're right to try to prevent the caching of the Container but using the newer framework, you'll need to use "no_cache=True" rather than "noCache=True". Also I would suggest setting the default HTTP cache time for your channel to a low number. Declaring your default cache time in the plugin's Start() function is the proper way to do it. Like so,

def Start()
  HTTP.CacheTime = 60 #measured in seconds

It's also important to note that even with no_cache=True and a short (or zero) CacheTime, you must reload the ObjectContainer (ie. exit & re-enter) to force it to reload the content. There is no Framework support for a timed-reload of containers.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.