API calls after video finishes playing?

The API that my plugin's content provider uses offers various functions to set things like video progress or watched status. The "official" apps the provider releases send out API calls when users stop watching a video or a video ends to update the user's profile with this information. This way the user can track what they've watched via the provider's website. Is there a way to issue API calls AFTER a video is stopped or ends? For example, i'd like to be able to issue a call when a video ends to the API to set the watched status to watched. If i don't do this the video provider's website still shows the video as unwatched. 

 

I'm guessing the answer is no, but with so much of Plex's API being undocumented i didn't know if there was some kind of hidden feature out there i could use. As far as i can tell, all the plugin can do is tell the client what video to play and that's it. There's no sort or return path. 

 

Thanks!

You are correct. That is not possible with the way Plex channels work. There's no communication back from the player to say that the video is over/exited. Other people have talked about sending the "Mark watched" API request as playback starts. Not an ideal solution but one that is at least doable.

If you're using a URL service I guess you could do a hack like this to make it work(example):

############################################################################################
def MediaObjectsForURL(url):
    return [
        MediaObject(
            container               = Container.MP4,
            video_codec             = VideoCodec.H264,
            audio_codec             = AudioCodec.AAC,
            video_resolution        = 720,
            audio_channels          = 2,
            optimized_for_streaming = True,
            parts                   = [
                PartObject(
                    key = Callback(PlayVideo, url = url, partNo = partNo)
                ) for partNo in range(2)
            ]
        )
    ]

############################################################################################
def PlayVideo(url, partNo):
if partNo == 0:
// Play as usual
else:
// Update website with info

with prerequisite that videos normally have 1 part.

If you're using a URL service I guess you could do a hack like this to make it work(example):

############################################################################################
def MediaObjectsForURL(url):
    return [
        MediaObject(
            container               = Container.MP4,
            video_codec             = VideoCodec.H264,
            audio_codec             = AudioCodec.AAC,
            video_resolution        = 720,
            audio_channels          = 2,
            optimized_for_streaming = True,
            parts                   = [
                PartObject(
                    key = Callback(PlayVideo, url = url, partNo = partNo)
                ) for partNo in range(2)
            ]
        )
    ]

############################################################################################
def PlayVideo(url, partNo):
if partNo == 0:
// Play as usual
else:
// Update website with info

with prerequisite that videos normally have 1 part.

That's a pretty decent work-around although some clients throw an error if they don't receive a video for one of the part objects. To work around that, you would just need to return a little filler video (only a second or two) after updating the website via the API call.  Several of the URL Services for Viacom properties have to do that because the number of parts per episode is not static between episodes. Here's an example in the SouthPark URL Service.

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