FAQ  •  Register  •  Login

stream url expires quickly

<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Tue Mar 13, 2012 12:14 pm

stream url expires quickly

Hi everyone,
I have a nice website which offers hundreds of tv shows http://serialepenet.ro It is paied and pretty good.
I have managed to make a plugin for it and it works, problem is that the URLs to the streams are available only for about 2 hours, and as I have loads of movies with loads of episodes, library refresh and cache take more than half an hour for only about 5 movies. And i would need to refresh it every 2 hours...

What I'm thinking is whether it is possible to not cache it at all, except for the thumbnail and somehow tell Serviio that the stream is always live and make the web requests to retrieve the actual stream url only when I press play on the TV?

Is it possible to specify something like that in the WebResourceItem class ?
Does the extractUrl method of the WebResourceUrlExtractor class gets executed when I press play on the TV ?

I would appreciate any ideas
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Tue Mar 13, 2012 12:19 pm

Re: stream url expires quickly

use "expires immediately" as documented in the guide.

can you tell me how you handled the logon/password for the paid site in your plugin?
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Tue Mar 13, 2012 12:25 pm

Re: stream url expires quickly

I set this to the org.serviio.library.online.ContentURLContainer object in the extractUrl method?

and how does it work, when I press play on tv it calls the "extractUrl" method (again)?
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Tue Mar 13, 2012 12:28 pm

Re: stream url expires quickly

regarding login, i was very fortunate as the site works just by specifying a static cookie, it doesn't actually require credentials post.
And the cookie I specified to the openURL() method

If it didn't work with the static cookie I would have tried to login with creds in the querystring, so do a GET instead of POST,
or use a different java HTTP request package
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Mar 13, 2012 12:49 pm

Re: stream url expires quickly

scrissti wrote:I set this to the org.serviio.library.online.ContentURLContainer object in the extractUrl method?

and how does it work, when I press play on tv it calls the "extractUrl" method (again)?

yes and yes
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Tue Mar 13, 2012 8:28 pm

Re: stream url expires quickly

  Code:
   
ContentURLContainer extractUrl(WebResourceItem item, PreferredQuality requestedQuality) {
   return new ContentURLContainer(fileType: MediaFileType.VIDEO, contentUrl: item.getAdditionalInfo()['WebResourceItemUrl_LOW'], thumbnailUrl: item.getAdditionalInfo()['WebResourceItemThumbnailUrl'], expiresImmediately: true)
   }

If i have this in the log file I get :
2012-03-13 22:25:02,824 WARN [WebResourceParser] Plugin sri returned no value for resource item 'power_of_art/sezon_1/episod_2'
2012-03-13 22:25:02,825 DEBUG [WebResourceParser] Skipping web resource item 'power_of_art/sezon_1/episod_2' because it's not of type VIDEO
2012-03-13 22:25:02,825 DEBUG [FeedItemUrlExtractor] sri: Starting extraction of url for item: power_of_art/sezon_1/episod_1
2012-03-13 22:25:02,825 WARN [FeedItemUrlExtractor] Online item expires but no cache key has been set
2012-03-13 22:25:02,825 DEBUG [FeedItemUrlExtractor] sri: Finished extraction of url: no result


and of course i don't see anything on the tv...

any ideas?
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Wed Mar 14, 2012 8:32 am

Re: stream url expires quickly

  Code:
    WebResourceContainer extractItems(URL resourceUrl, int maxItems) {
...
       ep_videourl=getMovieRealURL(new URL(videourl))
       WebResourceItem item = new WebResourceItem(title: ep_title,
                                                   additionalInfo: ['WebResourceItemThumbnailUrl': ep_thumb,
                                                                    'WebResourceItemUrl_LOW'     : ep_videourl,
                                                                    'WebResourceItemUrl_MEDIUM'  : ep_videourl,
                                                                    'WebResourceItemUrl_HIGH'    : ep_videourl,
                                                                    'WebResourceItemInfoUrl'     : ep_videourl,
                                                                    'bula'                       : ep_web_url])
...
   ContentURLContainer extractUrl(WebResourceItem item, PreferredQuality requestedQuality) {
        def videourl=item.getAdditionalInfo()['bula']
        videourl=getMovieRealURL(new URL(videourl))
        return new ContentURLContainer(fileType: MediaFileType.VIDEO, contentUrl: videourl, thumbnailUrl: item.getAdditionalInfo()['WebResourceItemThumbnailUrl'])
   }


Have tried also this but not working after a few hours
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Wed Mar 14, 2012 11:26 am

Re: stream url expires quickly

When you use expiresOn or expiresImmediately, you probably need "cachekey":

String cacheKey – a unique identifier of the content (i.e. this item with this quality) used
as a key to technical metadata cache; optional if expiresOn nor expiresImmediately is
provided


On TrailerAddictRss.groovy plugin, I use the currentTime for unique identifier like this :
  Code:
def cacheKey = getClass().getName() + "_${VideoId}_${requestedQuality}_"+(System.currentTimeMillis()/1000).toInteger()
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Mar 14, 2012 12:34 pm

Re: stream url expires quickly

you should not use time as a key, it negates the effect of the key, ie it'll run ffmpeg -i every time the method returns a new (nonexisting) cache key.

Cache key should be unique to the file itself, so I normally use something like (video_id + quality). If you're 100% sure all the files have the same technical metadata (codec, resolution, bitrate, etc), you can even use a constant cacheKey so that ffmpeg -i is only run 1x for the whole feed.
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Wed Mar 14, 2012 2:01 pm

Re: stream url expires quickly

Thank you very much,
I'll test it tonight
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Wed Mar 14, 2012 2:30 pm

Re: stream url expires quickly

zip wrote:you should not use time as a key.

Thanks,
Good to know, I will check that for my groovy plugins.
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Thu Mar 15, 2012 3:37 pm

Re: stream url expires quickly

unfortunately still not working, please take a look and let me know where i'm wrong. I think it's a principle issue.
My code is like this
  Code:
   WebResourceContainer extractItems(URL resourceUrl, int maxItems) {
 ...
       def ep_WebUrl=ep_href.toString()
        def ep_streamUrl=getMovieRealURL(ep_href)
        println ep_href       
        WebResourceItem item = new WebResourceItem(title: ep_title,
                                                   additionalInfo: ['WebResourceItemThumbnailUrl': ep_thumb,
                                                                    'WebResourceItemUrl_LOW'     : ep_streamUrl,
                                                                    'WebResourceItemUrl_MEDIUM'  : ep_streamUrl,
                                                                    'WebResourceItemUrl_HIGH'    : ep_WebUrl,
                                                                    'WebResourceItemInfoUrl'     : ep_streamUrl])
        Episodes <<item
...}

   ContentURLContainer extractUrl(WebResourceItem item, PreferredQuality requestedQuality) {
        def videoWeburl=item.getAdditionalInfo()['WebResourceItemUrl_HIGH']
        def streamUrl=getMovieRealURL(new URL(videoWeburl))
        return new ContentURLContainer(fileType: MediaFileType.VIDEO, contentUrl: streamUrl, thumbnailUrl: item.getAdditionalInfo()['WebResourceItemThumbnailUrl'],expiresImmediately: true, cacheKey:videoWeburl)
   }


So the idea is, i have two urls to an episode.
A web url :eg http://serialepenet.ro/house_m_d/sezon_8/episod_7
and a stream url: http://s5.serialepenet.ro:81/video/7f89 ... /46140.mp4

The stream Url is valid only for an hour or two.

So the strategy i took was to put in the WebResourceItem object both urls, the stream url to be called for video metadata to be cahed and the web url to be cached and to be available in the extractUrl method to use it in order to retrieve again the stream url when i press play on the tv remote.

Please take a look at the code and let me know where i'm wrong.
Thanks
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Mar 15, 2012 5:55 pm

Re: stream url expires quickly

first, you're not dealing with different qualities, right?

It looks ok, what exactly doesn't work? post detailed log.
<<

scrissti

Serviio newbie

Posts: 18

Joined: Fri Mar 09, 2012 11:51 pm

Post Fri Mar 16, 2012 9:46 am

Re: stream url expires quickly

I got this in the logs, and at that time when there should be no activty (TV is off, cache is set to 24 hours)

  Code:
2012-03-16 11:42:43,571 WARN  [FeedUpdaterThread] An error occured while scanning for online item information, will continue
java.io.IOException: Unexpected error while invoking plugin (sri): no protocol: tml    PUBLIC
   at org.serviio.library.online.WebResourceParser.parse(WebResourceParser.java:58)
   at org.serviio.library.online.OnlineLibraryManager.findResource(OnlineLibraryManager.java:169)
   at org.serviio.library.online.OnlineLibraryManager.findResourceInCacheOrParse(OnlineLibraryManager.java:184)
   at org.serviio.library.online.metadata.FeedUpdaterThread.getOnlineItems(FeedUpdaterThread.java:158)
   at org.serviio.library.online.metadata.FeedUpdaterThread.run(FeedUpdaterThread.java:95)
Caused by: java.net.MalformedURLException: no protocol: tml    PUBLIC
   at java.net.URL.<init>(Unknown Source)
   at java.net.URL.<init>(Unknown Source)
   at java.net.URL.<init>(Unknown Source)
   at sun.reflect.GeneratedConstructorAccessor1899.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
   at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
   at Seriale.getMovieRealURL(serialepenet.groovy:115)
   at Seriale$getMovieRealURL.callCurrent(Unknown Source)
   at Seriale.extractItems(serialepenet.groovy:86)
   at org.serviio.library.online.WebResourceUrlExtractor.parseWebResource(WebResourceUrlExtractor.java:29)
   at org.serviio.library.online.WebResourceParser.parse(WebResourceParser.java:56)


From the TV it seems that some times it works some times it doesn't.
And yes I don't care about different qualities.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Fri Mar 16, 2012 12:16 pm

Re: stream url expires quickly

it tries to get the URL for the first time, but fails:

  Code:
java.io.IOException: Unexpected error while invoking plugin (sri): no protocol: tml    PUBLIC
   at org.serviio.library.online.WebResourceParser.parse(WebResourceParser.java:58)


You have o check your code (like 58) and see what kind of URL you're returning, it probably valid, ie has a wrong (tml) protocol, instead of http, rtmp, etc.

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 12 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.