SageTV Community  

Go Back   SageTV Community > General Discussion > General Discussion

Notices

General Discussion General discussion about SageTV and related companies, products, and technologies.

View Poll Results: How do you archive?
I delete stuff to make space, or buy more hard disks. 33 80.49%
I use mediashrink. 3 7.32%
I use handbrake. 5 12.20%
I use videoredo. 3 7.32%
Other -- please elaborate. 3 7.32%
Multiple Choice Poll. Voters: 41. You may not vote on this poll

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old 05-25-2012, 08:15 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,373
I can tell that most of you folks don't have kids as they don't care as much about the quality nor logos. But archiving kids' shows is one of the best functions of SageTV as well as the ability to move to different devices like laptops, iPad, etc.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #22  
Old 05-25-2012, 09:14 AM
david1234 david1234 is offline
Sage Aficionado
 
Join Date: Nov 2007
Location: Beaverton, OR
Posts: 312
Quote:
Originally Posted by wayner View Post
I can tell that most of you folks don't have kids as they don't care as much about the quality nor logos. But archiving kids' shows is one of the best functions of SageTV as well as the ability to move to different devices like laptops, iPad, etc.
For kids stuff, I just don't care about quality... my daughter is 6 and she can tell the difference if I ask her, but it's not important. And, most of the stuff we record for her comes off of the OTA sub-channels that are only broadcasting at 480P anyway.
Reply With Quote
  #23  
Old 05-25-2012, 09:17 AM
david1234 david1234 is offline
Sage Aficionado
 
Join Date: Nov 2007
Location: Beaverton, OR
Posts: 312
Quote:
Originally Posted by wayner View Post
I comskip them and then run them through handbrake to convert to mp4 and finally copy them to a folder structure based on the show name. This also makes it easy to use the files on iDevices. I have written an SJQ process to handle all of this.
Is this script something that you can share? I've been thinking about installing sqj to do exactly this.
Reply With Quote
  #24  
Old 05-25-2012, 11:02 AM
MattHelm MattHelm is offline
Sage Icon
 
Join Date: Jun 2005
Location: Chicago, IL
Posts: 1,207
Quote:
Originally Posted by david1234 View Post
Is this script something that you can share? I've been thinking about installing sqj to do exactly this.
I really wish someone would create a area just for SJQ code. Easy to find that way. I've looked at the code a few have shared, and it looks Greek to me! (Greek, not geek!)
__________________
Server #1= AMD A10-5800, 8G RAM, F2A85-M PRO, 12TB, HDHomerun Prime, HDHR, Colossus (Playback - HD-200)
Server #2= AMD X2 3800+, 2G RAM, M2NPV-VM, 2TB, 3x HDHR OTA (Playback - HD-200)
Reply With Quote
  #25  
Old 05-25-2012, 11:36 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,373
Quote:
Originally Posted by david1234 View Post
Is this script something that you can share? I've been thinking about installing sqj to do exactly this.
Yes - I will post it over the next day or two. I may have already posted it in the SJQ thread but I will repost it here.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #26  
Old 05-25-2012, 11:39 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,373
Quote:
Originally Posted by MattHelm View Post
I really wish someone would create a area just for SJQ code. Easy to find that way. I've looked at the code a few have shared, and it looks Greek to me! (Greek, not geek!)
I agree, there should be a separate sub-form under plugins for SJQ.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #27  
Old 05-25-2012, 12:00 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,373
Quote:
Originally Posted by david1234 View Post
Is this script something that you can share? I've been thinking about installing sqj to do exactly this.
Here you go.

This groovy code does a few things. First it checks to see if it is a multi-segment file. If it is then it gives up since that causes too many programming issues and I am not a strong programmer. Then it renames to include the Series and Episode info (in case it doesn't have it) and moves it to a folder based on the filename - so the destination file after everything is done will look like this "\\carnoustie\Videos\Isabella's Shows\Dora the Explorer\Dora the Explorer-S05E01-Dora's Jack-in-the-Box-9350217-0.mp4". It then runs comskip and finally handrake. Note that it may take a while for your new files to show up in Sage since I don't trigger a media scan. If you want to you can do that manually.

To change the Handbrake parameters change the line HBParams=...
Also make sure that your paths to Handbrake and Comskip are specified correctly, especially is you are using the 64 bit version of windows. Also make sure that you have valid paths for your destination folder and your log file folder and that you but rename1.groovy in the correct folder and/or change the code that calls this script.

This code is a little more complex since it handles the verbose output of comskip and Handbrake. If you don't do that the routine craps out as there is too much textual output from groovy to handle.

The log file will show you how long it took to run all of these routines such as Comskip and Handbrake. Note that I have this process run automatically whenever a Kids' show has been recorded as a Favorite.

Thanks to Slugger since a lot of this code was stolen form him or he wrote it for me after I begged him for help.

Code:
import org.apache.commons.io.FileUtils
import static groovy.io.FileType.*
ComskipPath="C:\\comskip\\comskip.exe"  //Put your comskip path here
CSParams=" --verbose=0 "  //Change to 1 or higher if you want output from comskip
HBCLIPath='"C:\\Program Files\\Handbrake\\HandBrakeCLI.exe"'
HBParams=" -f mp4 -4  --deinterlace=fast -w 720 --loose-anamorphic  -e x264 -q 20 -r 29.97 --pfr  -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0 --gain=0 --audio-copy-mask none --audio-fallback ffac3 "  
def LogFile= new File("c:\\temp\\ProcKidsShows.log")
LogFile.append("===========================================================\r\n")
LogFile.append("${new Date()}\r\n")

NumSegs=MediaFileAPI.GetNumberOfSegments(mf)
RetName ="New file name to be returned"
DestFolder="\\\\carnoustie\\videos\\Kids' Shows\\"
ShowName= ShowAPI.GetShowTitle(mf)
run (new File("c:\\GroovyFiles\\Temp\\rename1.groovy")) //this routine finds the new filename

SourceFile= MediaFileAPI.GetFileForSegment(mf, 0)
SourceFileName=SourceFile.toString()
LogFile.append("Log File for MediaFile $SourceFileName\r\n")
if (NumSegs > 1) {
    LogFile.append("File has more than one segment so I am aborting the process!!!\r\n")
    return 2
    }
DestFileName=DestFolder+ShowName+"\\"+RetName
DestFile = new File(DestFileName)
LogFile.append("Moving $SourceFileName to $DestFileName\r\n")
FileUtils.moveFile( SourceFile, DestFile)

    //  This next section calls Comskip
InputCSFile=DestFileName 
CSProc=ComskipPath+CSParams+'"'+InputCSFile+'"'
println (CSProc)
def initialSize = 8192
def outStream = new ByteArrayOutputStream(initialSize)
def errStream = new ByteArrayOutputStream(initialSize)
def command=CSProc
LogFile.append("${new Date()} Running Comskip with command $CSProc\r\n")
def proc=command.execute()
proc.consumeProcessOutput(outStream, errStream)
proc.waitFor()
LogFile.append("${new Date()} Comskip is done\r\n")
    
    //This next section calls Handbrake
FilePrefix = DestFileName.substring(0, DestFileName.lastIndexOf('.'))
FileType= DestFileName.substring(DestFileName.lastIndexOf('.')+1, DestFileName.size())
InputVidFile=DestFileName
OutputVidFile=FilePrefix+".mp4"
HBProc=HBCLIPath+" -i "+'"'+InputVidFile+'"'+" -o "+'"'+OutputVidFile+'"'+HBParams

outStream = new ByteArrayOutputStream(initialSize)
errStream = new ByteArrayOutputStream(initialSize)
LogFile.append("${new Date()} Running Handbrake with command $HBProc\r\n")
def HBcommand=HBProc
def HBproc=HBcommand.execute()
HBproc.consumeProcessOutput(outStream, errStream)
HBproc.waitFor()
LogFile.append("${new Date()} Handbrake is finished\r\n")
DestDeleted=DestFile.delete()
LogFile.append("${new Date()} File $DestFileName is deleted? $DestDeleted\r\n")
LogFile.append("${new Date()} Process is now complete\r\n")
And here is file rename1.groovy
Code:
import org.apache.commons.io.FilenameUtils
//This is originally from this post http://forums.sagetv.com/forums/showthread.php?p=523594&postcount=1072
//Object mf = MediaFileAPI.GetMediaFileForID(Integer.parseInt(SJQ4_METADATA.get("SJQ4_ID")))
//Object mf = MediaFileAPI.GetMediaFileForID(6037703) //\\carnoustie\media2\tv\FiremanSam-CatMagic-6987515-0.mpg
//Object mf = MediaFileAPI.GetMediaFileForID(FileID) //\\carnoustie\media2\tv\FiremanSam-CatMagic-6987515-0.mpg

static class Data {
    static final List ILLEGAL_CHARS = [34, 60, 62, 124, 47, 58, 42, 63, 92]
}

def sanitize(def input) {
    def output = input
    for(def i = 0; i < input.length(); ++i) {
        def val = (input[i] as char) as int
        if(val < 32 || val > 126 || Data.ILLEGAL_CHARS.contains(val))
            output = output.replace(input[i], '_')
    }
    return output
}

def output = new StringBuilder()

    def MFType=MediaFileAPI.GetMediaFileMetadata(mf,"MediaType")
    def season = ShowAPI.GetShowSeasonNumber(mf)
    def episode = ShowAPI.GetShowEpisodeNumber(mf)
    def details
    if(season > 0 && episode > 0)
        details = String.format('%s-S%02dE%02d%s', ShowAPI.GetShowTitle(mf), season, episode, ShowAPI.GetShowEpisode(mf) ? "-${ShowAPI.GetShowEpisode(mf)}" : '')
    else if(ShowAPI.GetOriginalAiringDate(mf) > 0)
        details = String.format('%s %s %s', ShowAPI.GetShowTitle(mf), "- "+new Date(ShowAPI.GetOriginalAiringDate(mf)).format('yyyy-MM-dd'), ShowAPI.GetShowEpisode(mf) ? "- ${ShowAPI.GetShowEpisode(mf)}" : '')
    else if(ShowAPI.GetShowCategory(mf) == 'Movie')
        details = String.format('%s (%s)', ShowAPI.GetShowTitle(mf), ShowAPI.GetShowYear(mf))
    else if(ShowAPI.GetShowCategory(mf) == 'Sports event' && ShowAPI.IsShowFirstRun(mf))
        details = String.format('%s-%s-%s', ShowAPI.GetShowTitle(mf), ShowAPI.GetShowEpisode(mf), new Date(AiringAPI.GetAiringStartTime(mf)).format('yyyy.MM.dd'))
    else
        details = null
    if(details) {
        (0 .. MediaFileAPI.GetNumberOfSegments(mf) - 1).each { i ->
            def segFile = MediaFileAPI.GetFileForSegment(mf, i)
            def newName = sanitize(String.format('%s-%d-%d.%s', details, AiringAPI.GetAiringID(mf), i, FilenameUtils.getExtension(segFile.getName())))
            output << "$segFile >> $newName\r\n"
            RetName=newName
             }
    } else
        output << "Skipped '${ShowAPI.GetShowTitle(mf)}'; not enough metadata to build new file name!\r\n"

println output
return 0
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #28  
Old 05-25-2012, 02:12 PM
graywolf's Avatar
graywolf graywolf is offline
Sage Icon
 
Join Date: Oct 2009
Location: NC
Posts: 1,366
You could put a Media Scan command in your SJQ script.

To trigger a Media Scan (and continue processing without waiting). If one is already scheduled, it will not stack up.

Code:
    ServerClient sc = new ServerClient();
    sc.scheduleMediaScan();
    sc.close();
To trigger a Media Scan and wait until it completes before proceeding
Code:
    println("Core media scan triggered...");
    Global.RunLibraryImportScan(true)
    println("Core media scan finished...");
Reply With Quote
  #29  
Old 05-25-2012, 03:15 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,373
OK thanks, I was worried about stacking up multiple scans as I sometimes manually run this process after converting several files. Sage scans every few hours anyway so I wasn't too concerned about running a scan.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #30  
Old 05-25-2012, 05:38 PM
graywolf's Avatar
graywolf graywolf is offline
Sage Icon
 
Join Date: Oct 2009
Location: NC
Posts: 1,366
I use the Media Scan wait until finish in my move script. Before moving I check the various flags (watched, archived, etc) and save the values, then after the move, I get the new AiringID for the file then set the flags as they were.
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
Auto Archive Wakecrash SageTV Beta Test Software 0 07-17-2010 01:58 PM
Moving from Archive, but still in archive HeyGuy101 SageTV Software 2 09-09-2007 11:30 AM
How to archive files on DVD? KarylFStein General Discussion 5 07-21-2006 07:41 AM
What are ppl using to archive shows!? jimbobuk SageTV Software 0 05-17-2003 12:37 PM


All times are GMT -6. The time now is 11:30 PM.


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