|
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. |
|
Thread Tools | Search this Thread | Display Modes |
#1361
|
|||
|
|||
Quote:
http://docs.oracle.com/javase/6/docs...Modified(long) So in Groovy, something like: Code:
def src = new File('src.ts') def target = new File('target.ts') target.setLastModified(src.lastModified())
__________________
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... |
#1362
|
|||
|
|||
Thanks Slugger, that works perfectly.
__________________
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 |
#1363
|
|||
|
|||
I am trying to run this script and I keep getting a read error.
2013-01-10 06:38:14,551 INFO [Exe]: Received task 166 of type 'MOVEREC' from 192.168.0.10:23347... 2013-01-10 06:38:14,551 INFO [192_168_0_10-23347-166]: Starting process runner for: Task[id=MOVEREC, reqRes=100, maxInst=1, sched=ON, maxTime=86400, maxTimeRatio=1.0, rc=0-0, exe=script:c:\sjqnew\mv_media_file.groovy d:\\hold, exeArgs=, test=, testArgs=] 2013-01-10 06:38:14,554 INFO[ListenerClient]: Disconnected from 192.168.0.10:23347 2013-01-10 06:38:14,555 ERROR [192_168_0_10-23347-166]: Unable to read script 'c:\sjqnew\mv_media_file.groovy d:\hold'; marking task as FAILED! 2013-01-10 06:38:14,568 INFO[ListenerClient]: Disconnected from 192.168.0.10:23347 2013-01-10 06:38:14,568 WARN [ProcessRunner]: Removing task from active list: SJQ4Task-192.168.0.10-23347-166 Code:
/****************************************************************************** Move a SageTV Media File Last Modified: 16 Feb 2011 Author: Derek Battams <derek AT battams DOT ca> Use this groovy script to move a SageTV media file object from one location to another. The media file to be moved is defined by the SJQ4_ID environment variable; the SJQ4_TYPE variable must also be "MediaFile". The destination is given as the first command line argument to this script. The destination is a directory. This script will trigger a rescan of your media after a successful move; the rescan is necessary in order for SageTV to recognize the media file in its new location. ******************************************************************************/ boolean testMode = false; // Don't actually move any files, just print out what would be done // Uncomment and fill in these vars to run this script outside of SJQ //def SJQ4_METADATA = ["SJQ4_TYPE":"MediaFile", "SJQ4_ID":"74420011"]; //def SJQ4_ARGS = ["\\\\nas\\tv"]; /******************* DO NOT EDIT BELOW THIS LINE ************************/ // But if you do then send me your bug fix patches! ;) import org.apache.commons.io.FileUtils; import static groovy.io.FileType.*; import com.google.code.sagetvaddons.sjq.network.ServerClient; String type = SJQ4_METADATA.get("SJQ4_TYPE"); String id = SJQ4_METADATA.get("SJQ4_ID"); File dest = new File(SJQ4_ARGS[0]); if(!dest.isDirectory() && !dest.mkdirs()) { println("Destination directory is invalid! [" + dest.getAbsolutePath() + "]"); return 1; } if(!"MediaFile".equals(type) || id == null || !id.matches("\\d+")) { println("No media file attributes provided!"); return 1; } Object mediaFile = MediaFileAPI.GetMediaFileForID(id.toInteger()); if(mediaFile == null) { println("No media file for id " + id); return 1; } MediaFileAPI.SetMediaFileMetadata(mediaFile, "SJQ4_ARCHIVED", null); if(MediaFileAPI.GetNumberOfSegments(mediaFile) == 0) { println("Zero file segments for media file; nothing to move!"); return 1; } println("Moving " + Arrays.toString(MediaFileAPI.GetSegmentFiles(mediaFile)) + " to destination: " + dest.getAbsolutePath()); // Copy all segments then delete the originals if more than one segment otherwise just do a filesystem move op if(MediaFileAPI.GetNumberOfSegments(mediaFile) == 1) { try { if(!testMode) FileUtils.moveFileToDirectory(MediaFileAPI.GetFileForSegment(mediaFile, 0), dest, false); else println("Would move: " + MediaFileAPI.GetFileForSegment(mediaFile, 0)); } catch(IOException e) { println("Failed to move file to destination!"); e.printStackTrace(); return 1; } } else { def copied = []; // Copy the files to their new home for(File segment : MediaFileAPI.GetSegmentFiles(MediaFileAPI.GetMediaFileForID(id.toInteger()))) { try { if(!testMode) { FileUtils.copyFileToDirectory(segment, dest, true); copied.add(new File(dest, segment.getName())); println("\tCopy of '" + segment.getAbsolutePath() + "' completed..."); } else { println("\tWould move: " + segment.getAbsolutePath()); } } catch(IOException e) { println("Error copying segment '" + segment.getAbsolutePath() + "' to destination!"); e.printStackTrace(); copied.each { if(!it.delete()) println("Failed to delete '" + it.getAbsolutePath() + "'"); } return 1; } } } println("Moving artifacts..."); mvArtifacts(id.toInteger(), dest, testMode); if(!testMode) { MediaFileAPI.DeleteFile(MediaFileAPI.GetMediaFileForID(id.toInteger())); ServerClient sc = new ServerClient(); sc.scheduleMediaScan(); sc.close(); println("Core media scan triggered..."); } return 0; def mvArtifacts(int mfId, File dest, boolean testMode) { for(File segment : MediaFileAPI.GetSegmentFiles(MediaFileAPI.GetMediaFileForID(mfId))) { String prefix = segment.getName().substring(0, segment.getName().lastIndexOf('.')); File baseDir = new File(segment.getParent()); baseDir.eachFileMatch FILES, {!new File(baseDir, it.toString()).equals(segment) && it.toString().startsWith(prefix)}, { File artifact = new File(baseDir, it.getName()); if(!testMode) { FileUtils.moveFileToDirectory artifact, dest, false; } else println("Would move artifact: " + artifact.getAbsolutePath()); } } }
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct. |
#1364
|
|||
|
|||
It looks like you've added your command line args for the script to the actual script name:
2013-01-10 06:38:14,551 INFO [192_168_0_10-23347-166]: Starting process runner for: Task[id=MOVEREC, reqRes=100, maxInst=1, sched=ON, maxTime=86400, maxTimeRatio=1.0, rc=0-0, exe=script:c:\sjqnew\mv_media_file.groovy d:\\hold, exeArgs=, test=, testArgs=] Check the task definition. If you want to pass d:\hold as an agument to the script then you need to set that in the task's exeArgs value, you can't include it as part of the task's exe value.
__________________
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... |
#1365
|
|||
|
|||
Quote:
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct. |
#1366
|
|||
|
|||
Is there a simple script test that checks for the existence or not existence of a file ...based on an argument.
Example I would like to check for existence of filename.rename.... and others.
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct. |
#1367
|
|||
|
|||
Quote:
Code:
def f = new File('some.file') if(f.exists()) println 'File exists' else println 'File does NOT exist'
__________________
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... |
#1368
|
|||
|
|||
Is there a way for SJQ4 to handle and reencode Items that have not been watched say in 40 days or so? I am coming for SJQ3 and that was quite easy it had a mediaage variable.
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct. |
#1369
|
|||
|
|||
Quote:
Lucky for you, part of my SJQ4 work included converting some (but definitely not all) of the "convenience" functions & operators from SJQ3 into something similar for use in Groovy. Just so happens this particular problem of comparing the age of media files made the list of things I wrote helpers for. Of particular interest to you: MediaFileHelpers.isOlderThan() This is a convenience method to replicate the kind of thing you would have done with MediaAge in SJQ3. Quick example: Code:
import com.google.code.sagetvaddons.groovy.api.MediaFileHelpers def mf = MediaFileAPI.GetMediaFileForID(12345678) if(MediaFileHelpers.isOlderThan(mf, '40D')) println 'This media file is more than 40 days old!' else println 'This media file is NOT older than 40 days!' Happy scripting...
__________________
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... Last edited by Slugger; 01-13-2013 at 11:40 AM. |
#1370
|
|||
|
|||
Quick little script: Give your STBs a break
Recently, my satellite STBs have been locking up or just down right dying, requiring warranty replacement. The sat company claims that their latest model STBs should absolutely be powered off when not in use. Keeping them on 24x7 will cause all sorts of problems.
Well, I'm skeptical of this for many reasons, but to appease them, I've written a script that runs periodically (via SJQv4 crontab) and on certain Sage events (via SageAlert) that will identify "safe" times to power off my STBs and then will power them back on prior to scheduled recordings, as needed. Mind you, this isn't full proof for many reasons, but it's no less reliable than doing nothing. Sage assumes your STBs are always on 24x7 anyway and when they're not, you miss recordings. Assuming my logic is sound, this script should always ensure my STBs are on when they need to be and if the "state" flag is wrong then it also means that my STBs would be off otherwise (i.e. if the state flag I rely on in this script is wrong then it's most likely because I lost power and my UPS's battery was exhausted and my STBs lost power). So as long as my logic is right, this script will allow for chunks of hours per day when my STBs are powered off. Is this going to help the expected lifetime of my STBs? I really don't think so (I just think these newer models are much poorer quality than older models), but my sat provider says it will so I'm going to give it a shot. I share this script in case others are looking for similar functionality. I run this hourly via SJQv4 crontab and then I also run it via SageAlert on the following events: ClientConnected ClientDisconnected RecordingScheduleChanged This should cover all the situations where I may need to flip the state of my STBs. To run this script via SageAlert's process executor server, you must install Groovy on your system and run the script thru the groovy executable. You will need the gtools and sagex-api jars in your groovy classpath. The script will "just run" as a script exe in SJQv4 task clients. In theory, this script should work with any device that Sage can use to do IR blasting. In practice, the raw Sage API calls only seem to work reliably with a USB-UIRT, which is what I use in my environment. YMMV. Happy scripting... Code:
import sagex.api.* import sagex.SageAPI import sagex.remote.rmi.RMISageAPI import com.google.code.sagetvaddons.groovy.api.GlobalHelpers final def RC_CMD = 'POWER' final def REMOTES = ['SCSD1', 'SCSD5'] final def SAGE_PROP = 'slugger/stbState' def lockCreated = false def lck = new File(new File(System.getProperty('java.io.tmpdir')), '.stb.lck') try { lockCreated = lck.createNewFile() if(!lockCreated) { println 'Unable to create lock; exiting!' throw new IOException("Failed to create lock! [$lck]") } SageAPI.setProvider(new RMISageAPI('192.168.1.10')) def state = Configuration.GetServerProperty(SAGE_PROP, 'true').toBoolean() println "STBs are currently ${state ? 'ON' : 'OFF'}" if(flipState(state)) { REMOTES.each { def rcName = it println "Flipping state for $it" // Find the remote/plugin combo to issue the IR commands to based on the given remote name def found = false for(def plugin : Configuration.GetInfraredTuningPlugins()) { for(def remote : Configuration.GetRemotesForInfraredTuningPlugin(plugin, 0)) { if(remote.equals(rcName)) { found = true issueIrCommand(plugin, remote, RC_CMD) break } } if(found) break } if(!found) { println "Remote '$rcName' is not defined in the system!" } else println "Power toggled to '$rcName' successfully!" } Configuration.SetServerProperty('slugger/stbState', Boolean.toString(!state)) } else println 'Not time to flip the state of the STBs!' return 0 } finally { if(lockCreated) { if(lck.delete()) print 'Lock deleted successfully!' else print 'FAILED to remove lock!' } else print 'Lock was NOT created!' println " [$lck]" } // Given a remote plugin name, the remote ID and the command, issue that command via IR def issueIrCommand(plugin, remote, cmd) { if(cmd ==~ /\d+/) // Assuming each number is an individual command; anything else is a single command name to be issued cmd = cmd.getChars() else cmd = [cmd] for(def c : cmd) { Global.TransmitCommandUsingInfraredTuningPlugin(plugin, 0, remote, String.valueOf(c), 2) sleep Configuration.GetButtonDelayForInfraredTuningPlugin(plugin, 0, remote) } } def flipState(def curState) { if(GlobalHelpers.isAnythingConnected()) { if(!curState) { println 'STBs are off, but someone is connected... turning them back on.' return true } else { println 'Someone is connected; never turn off STBs while someone is connected!' return false } } if(GlobalHelpers.isSomethingRecording()) { if(!curState) { println 'STBs are off, but a recording running!! Turning them back on!!' return true } else { println 'Something is recording; never turn off STBs while recording!' return false } } // Otherwise, turn 'em on within 2 hrs of next recording or turn 'em off if more than 2 hours before next recording def eta = GlobalHelpers.getSecondsUntilNextRecording() println "Time until next recording: ${Utility.PrintDurationWithSeconds(eta * 1000L)}" if(curState) { // They're on, check to see if we should turn them off return eta > 7200 // 2 hours } else { // They're off, check to see if we should turn them on return eta < 7200 } }
__________________
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... Last edited by Slugger; 01-23-2013 at 06:30 PM. Reason: Fix race condition in script |
#1371
|
|||
|
|||
I have created a script that has some similarities. I occasionally miss recordings from my SD cable box because it gets shut down for some reason, either a power cyclie or something that happens at the head-end from Rogers cable.
So I have created an SJQ routine that looks for recordings from that tuner and runs them through Comskip to get an average volume and an average brightness. Very low numbers mean that the show was really just a recording of a silent black screen. When that is the case I send a power toggle to my box via the USB-UIRT. This means that subsequent recordings should be ok, but at least one recording was missed. All of this is required since this box, an SA3200, does not turn on when it receives channel change commands, and it does not have a discrete power on command, just a power toggle. In an ideal world I would create a short recording each day, say at 6am, and then use this recording as my test. But I never felt creative enough to do that last step. Part of the reason is that this cable box/tuner combo is just used to record kids shows since pretty much everything else is in HD these days.
__________________
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 |
#1372
|
|||
|
|||
Can't run tasks
I'm unable to run any SJQ jobs. This problem occurred before, last time I needed to update the Sage API Services plugin. This time everything's up to date. I tried rebooting server, restarting Sage service, no luck. BTW, this occurred after I update the JSON plugin, could this be related? I've attached a screen shot of the log. Thanks.
|
#1373
|
|||
|
|||
Quote:
__________________
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... |
#1374
|
|||
|
|||
Resetting the sagex plugin configuration and a reboot of the server pc did the trick.
|
#1375
|
|||
|
|||
Important licensing info
Please read the following. By updating the license server plugin, you can now unlock all features of this plugin. Enjoy!
__________________
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... |
#1376
|
|||
|
|||
Problem with Full Backup Script
I re-installed Sage on my server which I upgraded to Windows 7 Professional 32 bit. I had been using the full backup groovy script on a SJQ client independent of Sage. I am now having difficulty running the script which I have in "test" mode. I've attached a copy of the error log. BTW, I'm running the SJQ client as a windows service logged on as a local account. The Sage service is logged on as my user name as I'm using UNC paths.
|
#1377
|
|||
|
|||
Quote:
__________________
Home Network: https://karylstein.com/technology.html |
#1378
|
|||
|
|||
That did it. Thanks.
|
#1379
|
|||
|
|||
just rebuilt my sagetv server (win2012). instead of re-installing showanalyzer 1.0 which has its own directory monitor (no need for dirmon) thought i'd take a quick look at the alternatives.
it looks like sjq4 could be a good alternative in combination with showanalyzer/comskip. a couple quick questions: 1. is sjq4 compatible with Java 7 (all updates)? 2. any known gotchas or issues I should be aware of when configuring for commercial skipping? 3. is there a sample for using Comskip.exe (and the correct commandline args)? Thanks in advance. |
#1380
|
|||
|
|||
Quote:
Questions: 1. When using Phoenix or SageMC (which have the ability to read the .edl file and skip commercials) do you still need to install the Commercial Detector on SageTV clients? 2. Same as #1 but extenders: Installing Commercial Detector handles my extenders automatically via the Commercial Detector server plug-in? (also what if extender is running Phoenix). 3. SAV1 has not been updated in years (and the website does not even seem to be up any more). It used to be better than Comskip... is it still better or is Comskip (donator version) now better/faster/more reliable? 4. Is Commercial Detector a standalone plug-in or does it leverage the SJQ/SJQ UI? (curious what will be installed) |
Currently Active Users Viewing This Thread: 4 (0 members and 4 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Plugin: MizookLCD (Alternate SageTV LCDSmartie Plugin) | cslatt | SageTV Customizations | 48 | 06-11-2012 10:44 AM |
SJQv4: Technology Preview | Slugger | SageTV v7 Customizations | 39 | 12-17-2010 01:17 PM |
SageTV Plugin Developers: Any way to see stats for your plugin? | mkanet | SageTV Software | 4 | 12-12-2010 10:33 PM |
MediaPlayer Plugin/STV Import: Winamp Media Player Plugin | deria | SageTV Customizations | 447 | 12-11-2010 07:38 PM |
SJQv4: Design Discussion | Slugger | SageTV v7 Customizations | 26 | 10-18-2010 08:22 AM |