SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2016, 04:53 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
How to set Watched time for DVD's

I am trying to add support in my IOS client to optionally set the Watched time on SageTV for where someone just watched a movie to on IOS. I can do this for a tv show but not for a dvd. SageTV obviously can do it but I haven't found out how. I asked this on 4/30/2015 here:
http://forums.sagetv.com/forums/show...837#post571837
This link has sample code for what I have tried.

But now that the code is open source has someone seen how this is done and how I could do it?


Thanks
David
Reply With Quote
  #2  
Old 04-14-2016, 06:17 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by davidb View Post
I am trying to add support in my IOS client to optionally set the Watched time on SageTV for where someone just watched a movie to on IOS. I can do this for a tv show but not for a dvd. SageTV obviously can do it but I haven't found out how. I asked this on 4/30/2015 here:
http://forums.sagetv.com/forums/show...837#post571837
This link has sample code for what I have tried.

But now that the code is open source has someone seen how this is done and how I could do it?


Thanks
David
My MultiUserSupport plugin does this. I am away from home at the moment and do not have access to the source. When I get home I'll post it.

If I recall it was not obvious.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #3  
Old 04-15-2016, 05:22 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I took a look at the code. I never actually set the watched duration of a DVD. What I do is save the current playback position and then when the user resumes playback perform a seek to the saved location.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #4  
Old 04-15-2016, 05:35 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
Thanks for checking!

David

Quote:
Originally Posted by tmiranda View Post
I took a look at the code. I never actually set the watched duration of a DVD. What I do is save the current playback position and then when the user resumes playback perform a seek to the saved location.
Reply With Quote
  #5  
Old 08-06-2018, 01:43 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
I still would like to add this to my IOS client. When I watch using the hd300 I can stop watching a show or dvd and when I watch it again it prompts me to resume at the same spot? Does anyone who is knowledgeable with the source code know what api I can use to do this?

I would like to be able to start watching something on the hd300 then stop and later watch some or finish on IOS and if not finished report the position back to sage and resume on the hd300 at the spot I left off on IOS.

David

Quote:
Originally Posted by davidb View Post
I am trying to add support in my IOS client to optionally set the Watched time on SageTV for where someone just watched a movie to on IOS. I can do this for a tv show but not for a dvd. SageTV obviously can do it but I haven't found out how. I asked this on 4/30/2015 here:
http://forums.sagetv.com/forums/show...837#post571837
This link has sample code for what I have tried.

But now that the code is open source has someone seen how this is done and how I could do it?


Thanks
David
Reply With Quote
  #6  
Old 08-06-2018, 02:25 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
Quote:
Originally Posted by davidb View Post
I still would like to add this to my IOS client. When I watch using the hd300 I can stop watching a show or dvd and when I watch it again it prompts me to resume at the same spot? Does anyone who is knowledgeable with the source code know what api I can use to do this?

I would like to be able to start watching something on the hd300 then stop and later watch some or finish on IOS and if not finished report the position back to sage and resume on the hd300 at the spot I left off on IOS.

David
Videoframe.java uses this to determine/seek DVD's to the previous spot:

Code:
dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
.
.
.
dvdResumeTarget.getWatchEnd()
It looks like there's an Airing API "GetWatchedEndTime" that returns the last time watched:
http://download.sage.tv/api/sage/api...e(sage.Airing)

or maybe this one:
http://download.sage.tv/api/sage/api...e(sage.Airing)

Will one of those work?

I also found this one for setting the watched times:

http://download.sage.tv/api/sage/api...0long,%20long)

Last edited by wnjj; 08-06-2018 at 02:34 PM.
Reply With Quote
  #7  
Old 08-06-2018, 02:31 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
I am able to resume an airing and can set the watched time for a show but not for a dvd. This post shows what I have tried:
https://forums.sagetv.com/forums/sho...837#post571837


If there is not an api to do it then how is the GUI saving the position of a DVD?


David
Quote:
Originally Posted by wnjj View Post
Videoframe.java uses this to determine/seek DVD's to the previous spot:

Code:
dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
.
.
.
dvdResumeTarget.getWatchEnd()
It looks like there's an Airing API "GetWatchedEndTime" that returns the last time watched:
http://download.sage.tv/api/sage/api...e(sage.Airing)

Will that one work?

EDIT: I couldn't find one to SET the watched time from an API so while you can continue on IOS, I don't think it will update the DB to refresh that on the HD300.

Last edited by davidb; 08-06-2018 at 02:33 PM.
Reply With Quote
  #8  
Old 08-06-2018, 02:38 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
Quote:
Originally Posted by davidb View Post
I am able to resume an airing and can set the watched time for a show but not for a dvd. This post shows what I have tried:
https://forums.sagetv.com/forums/sho...837#post571837


If there is not an api to do it then how is the GUI saving the position of a DVD?


David
I'll have to read your other post yet but the code I found was for DVD's:

Code:
if (watchMe.isDVD() || watchMe.isBluRay())
          {
            dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
I'm not sure why it won't work for DVD's.
Reply With Quote
  #9  
Old 08-06-2018, 02:52 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
The "SetWatchedTimes" call simply updates the watched time data in wiz.bin for the specific airing. Try getting those times using an API after partially watching a DVD in the HD300. Then see if simply setting them back to where they were causes the HD300 to still "restart" from there. If that doesn't even work there must be some kind of time bounds checking that's forcing it to the end.

Looking in the STV, it appears that "Start from the Beginning" just calls "ClearWatched(Airing)" before playing and nothing else special for the "Resume Playback" option.

Last edited by wnjj; 08-06-2018 at 02:55 PM.
Reply With Quote
  #10  
Old 08-09-2018, 09:28 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I looked into this a long time ago for my "Multi User" plugin. I'm traveling now and don't have access to the code but will look at it when I get home. It was not obvious, if I remember I had to mess with something to set the right "track".
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #11  
Old 08-23-2018, 06:53 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
I spent some more time on this and still can't set the watched time for a dvd. I am testing this on Sage 9 on windows. I am watching on the stv but using a hd-300 gives the same result. The code below is trying to set the watched time to 5 minutes for both a show and a dvd rip. In both cases the stv reports the media has been partially watched and prompts me to resume playback which I am doing. The tv airing starts at 5 minutes as expected but the dvd starts at the beginning. This test code is using sagex and running on the same machine as sage is on. I am calling the test function from main like this:
Code:
public static void main(String args[]) throws Exception 
{
    int  mediaID = 7130249; // I feel pretty


    testSetAiringTime(mediaID, 300);
    mediaID = 7354220; // Chesapeake Shores
    testSetAiringTime(mediaID, 300);
}
And this is the function.
Code:
    public static void testSetAiringTime(int mediaID, int secondsWatched)
    {
        Object mediafile = MediaFileAPI.GetMediaFileForID(mediaID);
        Object airing = MediaFileAPI.GetMediaFileAiring(mediafile);
        AiringAPI.ClearWatched(airing);

        AiringAPI.SetWatchedTimes(airing, AiringAPI.GetAiringStartTime(airing) + secondsWatched *  1000,  1534948850L * 1000L);

        System.out.println("media Title = "+ MediaFileAPI.GetMediaTitle(airing) + " IsDVD: " +
                MediaFileAPI.IsDVD(airing));

        long watchedDuration = AiringAPI.GetWatchedDuration(airing);
        long watchedEndTime = AiringAPI.GetWatchedEndTime(airing);
        long realWatchedStartTime = AiringAPI.GetRealWatchedStartTime(airing);
        long startTime = AiringAPI.GetAiringStartTime(airing);

        long sageSecondsWatched = watchedDuration / 1000L;
        
        System.out.println("watchedDuration: " + watchedDuration);
        System.out.println("watchedEndTime: " + watchedEndTime);
        System.out.println("realWatchedStartTime: " + realWatchedStartTime);
        System.out.println("startTime: " + startTime);
        System.out.println("sageSecondsWatched: " + sageSecondsWatched);
        
        if (Math.abs(sageSecondsWatched - secondsWatched) <= 3)
        {
            System.out.println("Sage shows watched time set to the desired time.");
        }
        else
        {
            System.out.println("Sage does not show watched time was set to the desired time!");
        }
    }
On the SetWatchedTimesCall for the third argument RealStartTime I have tried using 0 or the current unix time in seconds as well as the current unix time in milliseconds but it doesn't seem to matter and the api description says it will use the "current time".
Reply With Quote
  #12  
Old 08-25-2018, 07:18 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I looked into my MultiUserSupport plugin and the trick seems to be that you need to set the title number as well as the watched duration. The code below is what does it in my plugin.


Code:
                if (sagex.api.MediaFileAPI.IsDVD(MediaFile)) {
                    for (String UserID : UserIDs) {
                        MultiMediaFile MMF = new MultiMediaFile(UserID, MediaFile);
                        Long seekDuration = MMF.getDVDWatchedDuration();
                        if (seekDuration != 0) {
                            Long watchedTitleNum = (long)(MMF.getTitleNum());
                            int Code = 202;
                            Log.getInstance().write(Log.LOGLEVEL_TRACE, "watch: DVD Setting Title to " + watchedTitleNum);
                            sagex.api.MediaPlayerAPI.DirectPlaybackControl(new UIContext(UIContext), Code, watchedTitleNum, watchedTitleNum);
                            Log.getInstance().write(Log.LOGLEVEL_TRACE, "watch: DVD Seeking to " + seekDuration);
                            sagex.api.MediaPlayerAPI.Seek(new UIContext(UIContext), seekDuration);
                        } 
                    }
                }
If I recall jpaddock3000 helped me with it.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #13  
Old 08-25-2018, 08:32 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
What tmiranda is doing is keeping track of the watched position for multiple users then when playback starts restoring the watched position. He doesn't appear to be using the Sage api call that I am having a problem with(SetWatchedTimes). I can't do what he is doing because my playback is not done on sage itself but from IOS. I think the relativity recent(version not time) addition of the api function SetWatchedTimes has a problem. I don't have a build environment to be able to put in log messages in the function to see what is going on though. Can someone look at this?


Quote:
Originally Posted by tmiranda View Post
I looked into my MultiUserSupport plugin and the trick seems to be that you need to set the title number as well as the watched duration. The code below is what does it in my plugin.


Code:
                if (sagex.api.MediaFileAPI.IsDVD(MediaFile)) {
                    for (String UserID : UserIDs) {
                        MultiMediaFile MMF = new MultiMediaFile(UserID, MediaFile);
                        Long seekDuration = MMF.getDVDWatchedDuration();
                        if (seekDuration != 0) {
                            Long watchedTitleNum = (long)(MMF.getTitleNum());
                            int Code = 202;
                            Log.getInstance().write(Log.LOGLEVEL_TRACE, "watch: DVD Setting Title to " + watchedTitleNum);
                            sagex.api.MediaPlayerAPI.DirectPlaybackControl(new UIContext(UIContext), Code, watchedTitleNum, watchedTitleNum);
                            Log.getInstance().write(Log.LOGLEVEL_TRACE, "watch: DVD Seeking to " + seekDuration);
                            sagex.api.MediaPlayerAPI.Seek(new UIContext(UIContext), seekDuration);
                        } 
                    }
                }
If I recall jpaddock3000 helped me with it.
Reply With Quote
  #14  
Old 08-25-2018, 09:46 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
It sounds like you need an API that SETS the titlenum. Then the airing DB is updated properly for whatever system plays it back next time. Since you’re not actually playing the file on Sage but want it to act like it had, I suspect this is the missing piece. Unfortunately I don’t see an API for for that or an optional argument for the existing ones.

Last edited by wnjj; 08-25-2018 at 09:49 AM.
Reply With Quote
  #15  
Old 08-25-2018, 09:53 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
It’s looks like BigBrother.java has 2 setWatched() types and the second one includes titlenum. That looks like it needs an API equivalent.

Code:
public static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
      long realWatchStart, long realWatchEnd, boolean checkOnly)
  {
    return setWatched(a, airWatchStart, airWatchEnd, realWatchStart, realWatchEnd, 0, checkOnly);
  }
  static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
      long realWatchStart, long realWatchEnd, int titleNum, boolean checkOnly)
  {
The SetWatchedTimes API calls the first one. It would be easy to add a SetWatchedTimesEx or something to add titlenum as a parameter, provided you know what it is on your IOS player.

Last edited by wnjj; 08-25-2018 at 09:57 AM.
Reply With Quote
  #16  
Old 08-27-2018, 05:23 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
The SetWatchedTimes is supposed to provide this functionality. A SetWatchedTimesEx is not needed. I have entered an issue (#384)on the sagetv github. I looked at the source code but can't do much as I can't build it on my system.

David

Quote:
Originally Posted by wnjj View Post
Itís looks like BigBrother.java has 2 setWatched() types and the second one includes titlenum. That looks like it needs an API equivalent.

Code:
public static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
      long realWatchStart, long realWatchEnd, boolean checkOnly)
  {
    return setWatched(a, airWatchStart, airWatchEnd, realWatchStart, realWatchEnd, 0, checkOnly);
  }
  static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
      long realWatchStart, long realWatchEnd, int titleNum, boolean checkOnly)
  {
The SetWatchedTimes API calls the first one. It would be easy to add a SetWatchedTimesEx or something to add titlenum as a parameter, provided you know what it is on your IOS player.
Reply With Quote
  #17  
Old 08-27-2018, 09:43 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
Quote:
Originally Posted by davidb View Post
The SetWatchedTimes is supposed to provide this functionality. A SetWatchedTimesEx is not needed. I have entered an issue (#384)on the sagetv github. I looked at the source code but can't do much as I can't build it on my system.

David
I donít see how you can add the titlenum without breaking existing users of the API. A new API is the easiest solution.
Reply With Quote
  #18  
Old 08-27-2018, 10:00 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
in the source code AiringAPI.java SetWatchedTimes calls
BigBrother.setWatched function with 6 parms. Then that func calls the BigBrother.setwatched func with 7 parms passing in a titleNum of 0.

It appears the BigBrother.setwatched should handle it and new a new api function is not needed.

the BigBrother.setWatched
Quote:
Originally Posted by wnjj View Post
I don’t see how you can add the titlenum without breaking existing users of the API. A new API is the easiest solution.
Reply With Quote
  #19  
Old 08-27-2018, 01:47 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,435
Quote:
Originally Posted by davidb View Post
in the source code AiringAPI.java SetWatchedTimes calls
BigBrother.setWatched function with 6 parms. Then that func calls the BigBrother.setwatched func with 7 parms passing in a titleNum of 0.

It appears the BigBrother.setwatched should handle it and new a new api function is not needed.

the BigBrother.setWatched
I understand the internal function passes the 6 parameter call on to the 7 parameter one but the externally exposed API function only defines and accepts 6 parameters so adding one to that would break backward compatibility, unless you can have it optionally at the end. I'm not sure how flexible the API is with adding new optional arguments.
Reply With Quote
  #20  
Old 08-28-2018, 05:37 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
The api doesn't need to be extended for this to work. The titlenum is only for when you are watching on Sage.

The SetWatchedTimes was added in SageTV V7.0.13 Beta 8/4/2010 with the comment:
"Added Airing API call SetWatchedTimes(Airing, WatchedEndTime, RealStartTime) which can be used to set explicitly what the last watched time is for an Airing. Useful if viewing is done outside of the regular SageTV media players (i.e. web clients)."

If anyone is lurking and didn't read the whole thread. I have added issue: 384 on github.

David


Quote:
Originally Posted by wnjj View Post
I understand the internal function passes the 6 parameter call on to the 7 parameter one but the externally exposed API function only defines and accepts 6 parameters so adding one to that would break backward compatibility, unless you can have it optionally at the end. I'm not sure how flexible the API is with adding new optional arguments.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Marking one episode Watched marks all future as Watched svemuri SageTV Beta Test Software 3 03-16-2011 01:24 PM
Last time you watched Live TV? IVB General Discussion 34 01-01-2010 03:28 AM
Daylight Savings Time and NTFS time stamps - 1 hour off? Opus4 The SageTV Community 2 11-01-2006 11:34 PM
Reset watched shows after a certain time? Speedy64i SageTV Software 3 04-20-2006 02:08 PM
Feature Request: Time limited "watched" list Deadbolt SageTV Beta Test Software 2 02-10-2004 05:34 PM


All times are GMT -6. The time now is 06:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.