SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v7 Customizations
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV v7 Customizations This forums is for discussing and sharing user-created modifications for the SageTV version 7 application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss plugins for SageTV version 7 and newer.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-01-2011, 05:01 PM
gabrielcab gabrielcab is offline
Sage Aficionado
 
Join Date: Jan 2006
Posts: 287
Automatically remove incomplete recordings?

Hello, Is there any way to make sagetv to look into all recordings and automatically remove any recording that has a "red bar" for beign incomplete? Maybe SJQ? or any other simpler solution?
__________________
Waiting for Sage 8.
Reply With Quote
  #2  
Old 04-02-2011, 07:54 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
To my knowledge, there is no setting in the Sage core to do this kind of thing. SJQv4 would be able to do this. But you've got to be careful when deciding which recordings are incomplete.

Basically you want to look at the length of media file and compare it to the length of the airing it was recording. If they aren't near equal then you'd consider it an incomplete recording and delete it. The tricky part is deciding what "near equal" means. For a 30 minute airing you will rarely, if ever, get a media file of length 30 minutes. Depending on your tuner type, IR blaster settings, etc. a 30 minute airing might, at best, produce a recording file of length 29m55s. So you only want to delete recordings if they are outside this "fudge factor".

Here's a Groovy script that would do exactly what you're asking for. I'd definitely run it in test mode a few times and look at what it plans to do before flipping that TEST_MODE switch. You'll want to adjust the fudge factor accordingly.

Code:
def TEST_MODE = true
def FUDGE_FACTOR = 30L // seconds; you probably want to be conservative here

MediaFileAPI.GetMediaFiles("T").each {
    def mfLength = MediaFileAPI.GetFileDuration(it)
    def airLength = AiringAPI.GetScheduleDuration(it)
    if(mfLength < airLength - (1000L * FUDGE_FACTOR)) {
        if(!TEST_MODE) {
            MediaFileAPI.DeleteFileWithoutPrejudice(it)
            print "DELETED: "
        } else
            print "SKIPPED (test mode): "
        println "${MediaFileAPI.GetMediaTitle(it)}/${MediaFileAPI.GetMediaFileID(it)} because the media file is ${(airLength - mfLength) / 1000} seconds shorter than the airing!"
    }
}
return 0
And the output on my system:

Code:
SKIPPED (test mode): Friends/1672838 because the media file is 62.664 seconds shorter than the airing!
SKIPPED (test mode): Oz/2686686 because the media file is 72.476 seconds shorter than the airing!
Not bad... almost 1700 recordings and only two look like they're missing a significant chunk. You can set this script up to run periodically in SJQv4 and it'll toast off any recordings that are missing more than the fudge factor amount of seconds.
__________________
Twitter: @ddb_db
Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive
Capture: 2 x Colossus
STB Controller: 1 x USB-UIRT
Software:Java 1.7.0_71; SageTV 7.1.9
Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter
Plugins: Too many to list now...
Reply With Quote
  #3  
Old 04-02-2011, 10:07 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Note that the above script as written won't detect recordings with gaps in the middle, since (if I'm not mistaken) GetFileDuration measures from the start of the first segment to the end of the last segment, ignoring gaps between segments.

To do it right, you'd want to add up the times of the individual segments. Or you might consider any recording with more than one segment to be incomplete, regardless of gap size.

If I were doing this, I'd want to add a test to see if there were any future airings of that show in the schedule before deleting, since presumably the point of deleting it is so that it can record again.
__________________
-- Greg
Reply With Quote
  #4  
Old 04-02-2011, 11:47 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by GKusnick View Post
Note that the above script as written won't detect recordings with gaps in the middle, since (if I'm not mistaken) GetFileDuration measures from the start of the first segment to the end of the last segment, ignoring gaps between segments.

To do it right, you'd want to add up the times of the individual segments. Or you might consider any recording with more than one segment to be incomplete, regardless of gap size.
Any gap anywhere should be detectable simply by looking at the total length of all segments, which is what GetFileDuration() returns, no? Since you're testing that the total length of the file is approximately the length of the airing it was recording (adjusting for the FUDGE_FACTOR), whether the missing part is at the beginning, middle, or end should be irrelevant (based on my understanding). If a 30 min rec was stopped after 12 mins then restarted 4 mins later you'd have 2 segments, one of length 12 mins and one of length 14 mins. The GetFileDuration() should return 26 mins and the GetScheduleDuration() should return 30 mins. The 4 min gap is then identifiable. Of course, this assumes GetFileDuration() is working like I think it is?

Quote:
If I were doing this, I'd want to add a test to see if there were any future airings of that show in the schedule before deleting, since presumably the point of deleting it is so that it can record again.
Definitely. If I were actually ever going to run this script, which I don't plan to, I'd definitely be adding a lot more tweaks to it, including:

* checking that there is at least one (maybe more) future airings that can be recorded; maybe actually scheduling a manual record and ensure no conflict arises, which guarantees the "bad" recording will be replaced with a new one (or at least guarantees an attempt will be made to replace it)

* adding a MAX fudge factor to account for transcoded recordings where only a certain segment of the recording was transcoded; these wouldn't be bad recordings per se and therefore should not be deleted

But I think it's certainly a good starting point and addresses the major concerns of the OP.
__________________
Twitter: @ddb_db
Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive
Capture: 2 x Colossus
STB Controller: 1 x USB-UIRT
Software:Java 1.7.0_71; SageTV 7.1.9
Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter
Plugins: Too many to list now...
Reply With Quote
  #5  
Old 04-02-2011, 01:57 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by Slugger View Post
Any gap anywhere should be detectable simply by looking at the total length of all segments, which is what GetFileDuration() returns, no?
You're right; I'm wrong. I thought I had seen an example last week in which GetFileDuration() == GetFileEndTime() - GetFileStartTime(), but on retesting, that appears not to be the case. GetFileDuration() is the sum of the segment durations.

Never mind.
__________________
-- Greg
Reply With Quote
Reply


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

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
Incomplete recordings flavius SageTV Software 2 05-19-2009 08:32 PM
Automatically Import Recordings deadend5001 SageTV Customizations 0 02-24-2009 08:51 PM
Incomplete recordings are unplayable White94Cobra SageTV Beta Test Software 9 11-21-2006 07:19 PM
Problem with incomplete recordings GTwannabe SageTV Software 0 04-24-2005 02:51 PM
incomplete recordings-- spastic buzzerbee SageTV Software 2 07-29-2004 06:52 AM


All times are GMT -6. The time now is 01:32 AM.


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