Ways to deal with timeouts

I've been trying to develop a plugin for mylifetime.com. One of the annyoing traits of mylifetime.com is very slow loading times of web pages.

 

Currently I have a directory structure like this:

 

Show --> Season --> (Full Episodes | Clips) --> Video

 

After I select "Full Episodes" on a TV Show that has say 14 videos, I currently am downloading and parsing two different web pages (the first has the first 12 episodes and the second has the last 2) and then MediaObjectsForURL is being called for all 14 videos. The MediaObjectsForURL has to do an HTML.ElementFromURL call and an XML.ElementFromURL call. So I am estimating that I am performing 2 + (2 * 14) = 30 page retrievals for this one button click.

 

So when I click the "Full Episodes" button, Plex brings up the "Plex Media Server - Waiting for response..." dialog box. If this is the first time I've pressed this button, then Plex will silently fail as if I hadn't pressed the button. If I press the "Full Episodes" button again, or maybe even a third time, the button will succeed and I'll see the list of episodes.

 

My guess of what is going on is that Plex timeouts any selection after a certain specified amount of time. However, during that time, it is caching many of the web lookups. So the next time it does the same lookup, it can do new portions of it. Eventually, Plex will fill in all of the entries and show all the episodes.

 

So my question is, is there anyway to increase the Plex default timeout time?

 

Or is there a more intelligent way to organize this so that delays are minimized? I was thinking of doing something like:

 

Show --> Season --> Full Episodes --> (Episode 1 | Episode 2 | ... | Episode N) --> Video

 

where the (Episode 1 | Episode 2 | ... | Episode N) is just a DirectoryObject that points to the real episodes individually. That way each menu button click only has to deal with a maximum of one video at a time, rather than 14.

 

Any other suggestions?

 

 

Hi!

You can use a Callback and postpone the HTTP requests until they are really needed (= when a user clicks the item to watch the video):

####################################################################################################
def MediaObjectsForURL(url):

    return [
        MediaObject(
            parts = [
                PartObject(key=Callback(PlayVideo, url=url))
            ],
            video_codec = VideoCodec.H264,
            audio_codec = AudioCodec.AAC,
            container = Container.MP4,
            optimized_for_streaming = True
        )
    ]

####################################################################################################
def PlayVideo(url):

    # Do the HTTP request(s) here
    page = HTML.ElementFromURL(url)

    # … do some more stuff if needed …

    video_url = ‘http://www…’

    return Redirect(video_url)
 

Yep you want to minimize the amount of HTTP calls for sure, that's probably what is slowing you down.  Ideally for the main show listings you would want to try and pull enough metadata from a single page (like a page that lists all the video details) and populate that way.]

It would be helpful if we could see your plugin code, then we may be able to tell you where it's bottlenecking.

Hi!

You can use a Callback and postpone the HTTP requests until they are really needed (= when a user clicks the item to watch the video):

Thanks, this helped me a lot. I'm not sure why I couldn't figure this out after looking at the Daily Show plugin for so long. Still learning.

Right now I am using RTMP videos so I had to return an IndirectResponse from PlayVideo to make it work (as described in this thread: http://forums.plexapp.com/index.php/topic/48486-rtmpvideourl-using-real-rtmp-wont-play-on-ios/).

Yep you want to minimize the amount of HTTP calls for sure, that's probably what is slowing you down.  Ideally for the main show listings you would want to try and pull enough metadata from a single page (like a page that lists all the video details) and populate that way.]

It would be helpful if we could see your plugin code, then we may be able to tell you where it's bottlenecking.

Thanks for the offer to look at my code. I tried to avoid doing this because it's pretty rough/ugly at this point.

No worries on the rough/ugly code.  If you run into more issues post away, I can look through the rough bits to try and help you find the bottleneck.

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