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
  #1061  
Old 12-05-2011, 09:00 PM
phareous phareous is offline
Sage Advanced User
 
Join Date: Jul 2009
Posts: 234
Quote:
Originally Posted by Slugger View Post
Going to have to increase the log level to DEBUG in the sjq.log4j.properties file and run again. You must restart SageTV after changing the log level. This will produce a tonne of output in a hurry. Run it for a few minutes so the queue is processed then drop the log level back down and restart SageTV.
Not a whole lot in the server log, even with debug:
2011-12-05 21:56:10,476 INFO [Plugin]: sagetv-addons license successfully validated!
2011-12-05 21:56:10,491 INFO [Plugin]: SJQ timer thread has been started!
2011-12-05 21:56:10,491 INFO [Plugin]: Server agent has started!
2011-12-05 21:56:10,491 INFO [Plugin]: Server crontab has started!
2011-12-05 21:56:25,480 INFO [TaskQueue]: Scheduling queue processor for ~8 seconds from now!
2011-12-05 21:56:25,522 INFO [AgentManager]: Pinging Client[host=HTPC:23344,state=ONLINE,lastUpdate=2011-12-05 21:51:12.127]
2011-12-05 21:56:25,546 INFO[ListenerClient]: Disconnected from HTPC:23344
2011-12-05 21:56:25,553 INFO [AgentManager]: Pinging Client[host=192.168.1.153:23344,state=ONLINE,lastUpdate=2011-12-05 21:51:12.751]
2011-12-05 21:56:26,155 INFO[ListenerClient]: Disconnected from 192.168.1.153:23344
2011-12-05 21:56:26,159 INFO [AgentManager]: Pinging Client[host=192.168.1.152:23344,state=ONLINE,lastUpdate=2011-12-05 21:51:23.371]
2011-12-05 21:56:26,761 INFO[ListenerClient]: Disconnected from 192.168.1.152:23344
2011-12-05 21:56:33,482 INFO [TaskQueue]: Running queue processor now!
2011-12-05 21:56:33,507 INFO [TaskQueue]: Enforcing licensing restrictions... license is valid!
2011-12-05 21:57:02,278 ERROR [AgentClient]: IOError
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.google.code.sagetvaddons.sjq.listener.ListenerClient.readObj(ListenerClient.java:60)
at com.google.code.sagetvaddons.sjq.network.AgentClient.exe(AgentClient.java:104)
at com.google.code.sagetvaddons.sjq.server.TaskQueue$QueueProcessor.run(TaskQueue.java:149)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
2011-12-05 21:57:02,280 INFO [TaskQueue]: Scheduling queue processor for ~8 seconds from now!
Reply With Quote
  #1062  
Old 12-05-2011, 10:19 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Ok, drop the log level back to INFO. All the logging I need is available at info, but here's the problem:

Code:
2011-12-05 21:57:02,278 ERROR [AgentClient]: IOError
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.google.code.sagetvaddons.sjq.listener.ListenerClient.readObj(ListenerClient.java:60)
at com.google.code.sagetvaddons.sjq.network.AgentClient.exe(AgentClient.java:104)
at com.google.code.sagetvaddons.sjq.server.TaskQueue$QueueProcessor.run(TaskQueue.java:149)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Do you get this same looking stack trace everytime the QueueProcessor attempts to run? The cause is a misbehaving task client. Unfortunately, my logging isn't quite right in that it doesn't log which client it's trying to talk to before it tries so all I know with this log is that an attempt to talk to one of your task clients is failing, I can't tell you which one. Might there be a firewall preventing the Sage server from talking to one of the configured clients at the port numbers listed in the log? Since it's taking the full 30 seconds to bail, it's either a firewall issue where a remote task client is likely blocking the SJQ server's attempt to talk to it or there's a network issue on your LAN (bad cabling, network misconfig, etc.). I'd be checking that out on any remote task clients you have installed.

If that same error (IOError - Read time out) keeps coming up then I can add some logging to help us figure out which task client isn't playing nice. May not be until the weekend before I can play with this code though. In the meantime, I'd try disabling your task clients one at a time to see if that error goes away. If you need the extra logging to track it down then let me know and I'll try to do that on the weekend.

When the queue properly processes a task there will be an INFO (or ERROR) level log message saying where the task was assigned. Because of the socket error, it's just logging the socket error and skipping the task and unfortunately, I didn't make the socket error log message verbose enough to know exactly which task client is causing the problem.
__________________
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
  #1063  
Old 12-06-2011, 10:15 PM
phareous phareous is offline
Sage Advanced User
 
Join Date: Jul 2009
Posts: 234
I removed the bad client and everything is working now. The PING succeeded for that client, but the client seems to have intermittent problems connecting to the server. Yet the client can connect to any other machine in the house, and all other machines can connect to the server OK. I have no idea why the server hates this particular client. All firewalls, etc. are off. Oh well..at least 2 of the 3 task clients are working

Quote:
Originally Posted by Slugger View Post
Ok, drop the log level back to INFO. All the logging I need is available at info, but here's the problem:

Code:
2011-12-05 21:57:02,278 ERROR [AgentClient]: IOError
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peek(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.google.code.sagetvaddons.sjq.listener.ListenerClient.readObj(ListenerClient.java:60)
at com.google.code.sagetvaddons.sjq.network.AgentClient.exe(AgentClient.java:104)
at com.google.code.sagetvaddons.sjq.server.TaskQueue$QueueProcessor.run(TaskQueue.java:149)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Do you get this same looking stack trace everytime the QueueProcessor attempts to run? The cause is a misbehaving task client. Unfortunately, my logging isn't quite right in that it doesn't log which client it's trying to talk to before it tries so all I know with this log is that an attempt to talk to one of your task clients is failing, I can't tell you which one. Might there be a firewall preventing the Sage server from talking to one of the configured clients at the port numbers listed in the log? Since it's taking the full 30 seconds to bail, it's either a firewall issue where a remote task client is likely blocking the SJQ server's attempt to talk to it or there's a network issue on your LAN (bad cabling, network misconfig, etc.). I'd be checking that out on any remote task clients you have installed.

If that same error (IOError - Read time out) keeps coming up then I can add some logging to help us figure out which task client isn't playing nice. May not be until the weekend before I can play with this code though. In the meantime, I'd try disabling your task clients one at a time to see if that error goes away. If you need the extra logging to track it down then let me know and I'll try to do that on the weekend.

When the queue properly processes a task there will be an INFO (or ERROR) level log message saying where the task was assigned. Because of the socket error, it's just logging the socket error and skipping the task and unfortunately, I didn't make the socket error log message verbose enough to know exactly which task client is causing the problem.
Reply With Quote
  #1064  
Old 12-16-2011, 12:18 PM
gdippel gdippel is offline
Sage Aficionado
 
Join Date: Oct 2003
Location: Bayside, New York
Posts: 301
Quote:
Originally Posted by Slugger View Post
Here's a script that sends an email every morning with that night's late night summaries. I tend to only record Letterman, Leno, Fallon, Kimmel, etc. if they have guests of interest. I used to have them all as favs and then would mark episodes as watched before they were recorded if the guests were of no interest. This was fine expect if I forgot to check, etc. then I'd have a bunch of recordings I'd then have to remember to delete.

Instead, now I get a daily email with the summary of guests for that evening. If any interest me, I just click the link in the email to schedule the recording. If not, delete the email and nothing is recorded.

The script could be enhanced to only alert if certain names are found as guests, etc. That's an exercise for the reader.

http://sagetv-addons.googlecode.com/..._alerts.groovy

This script assumes it is running in the SJQv4 environment and will not work without modification otherwise. I run it daily from the SJQv4 crontab.

Happy scripting!
I just got around to trying this script, works great. I did have a little trouble with my smtp server which I found odd as I used the same settings as in the premier alert script. Comparing the two scripts, I discovered that the ssl variable was "hard coded" to "true" in the body of the Late Night script, which I had to change to "false" for my server. I did have the ssl variable set to "false" in the variable definition section of the script. (Please pardon my jargon, I'm not a programmer.)

Also, I had to change the category to "Talk" from "Talk Show", that may be unique to my epg data from Zap2it.

Speaking of Zap2It, I have to prepare for the inevitable shut down of their feed, but that's another story. See you on the mc2xml plugin thread!
Reply With Quote
  #1065  
Old 12-27-2011, 08:36 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Auto plugin upgrader

Below is a new script I wrote that will automatically upgrade all plugins on the server and optionally on any connected clients. It does NOT restart server nor clients after it upgrades plugins. Why not? I am running this script just prior to my nightly Sage restart task so there's no need for me to restart in this script. Basically, I run this script prior to the restart script and it ensures I'm running the latest version of every plugin.

Happy scripting!

Code:
/*
    Auto Plugin Upgrader
    Last Modified: 27 Dec 2011
           Author: Derek Battams <derek AT battams DOT ca>
    
    This script, which must be executed on a SageTV server instance, will check all installed plugins and
    upgrade any that can be upgraded.  If enabled, it will also check and upgrade plugins on any actively
    connected SageClients.
    
    REVIEW THE SETTINGS CAREFULLY BEFORE INITIAL EXECUTION.
    
    This script WILL NOT automatically restart Sage after a plugin is upgraded.  I run this script prior
    to my nightly reboot script, so the reboot is taken care of shortly after this script runs.
    
    This script is intended for periodic execution via the SJQv4 crontab.
*/

import sagex.UIContext

private class Settings {
    static def TEST_MODE = true         // Upgrade command is not executed when true
    static def UPGRADE_CLIENTS = false  // Client plugins are only upgraded when true and the client must also be actively connected
    static def IGNORE_REGEX = / +/      // This regex can never match a valid plugin id; i.e. no plugins are ignored by default
    static def SEND_MAIL = false        // When true, use the mail settings below to email the output; output is always dumped to stdout
}

private class EmailSettings {
    static def host = 'smtp.gmail.com'
    static def user = 'your_id@gmail.com'
    static def pwd  = 'your_gmail_password'
    static def port = '465'
    static def subj = 'SageTV Plugin Auto Updater Results'
    static def from = user                       // Gmail will reject mail via SMTP if the from addr != user id so no point in changing this
    static def to   = 'your_id+alerts@gmail.com' // Sometimes Gmail won't send an email addressed to yourself, try a plus address at the end; YMMV
    static def ssl  = 'true'                     // Gmail requires SSL, other SMTP servers may or may not; this is a STRING setting!
}

def output = new StringBuilder("${new Date()}\n\nProcessing server plugins...\n\n")
for(def p : PluginAPI.GetInstalledPlugins()) {
    def latest = PluginAPI.GetAvailablePluginForID(PluginAPI.GetPluginIdentifier(p))
    if(!PluginAPI.IsPluginInstalledSameVersion(latest)) {
        output.append("Upgrading '${PluginAPI.GetPluginIdentifier(latest)}'...\n")
        output.append("\t${PluginAPI.GetPluginVersion(p)} > ${PluginAPI.GetPluginVersion(latest)}\n")
        output.append('\tResult: ')
        if(Settings.TEST_MODE)
            output.append('SKIPPED - test mode')
        else if(PluginAPI.GetPluginIdentifier(latest) ==~ Settings.IGNORE_REGEX)
            output.append('SKIPPED - matches ignore list')
        else
            output.append(PluginAPI.InstallPlugin(latest))
    }
}

if(Settings.UPGRADE_CLIENTS && Global.GetConnectedClients().size() > 0) {
    output.append('\n\nProcessing connected clients...\n\n')
    for(def c : Global.GetConnectedClients()) {
        def context = new UIContext(c)
        output.append("Processing '$context'...\n")
        for(def p : PluginAPI.GetInstalledClientPlugins(context)) {
            def latest = PluginAPI.GetAvailablePluginForID(PluginAPI.GetPluginIdentifier(p))
            if(!PluginAPI.IsClientPluginInstalledSameVersion(context, latest)) {
                output.append("Upgrading '${PluginAPI.GetPluginIdentifier(latest)}'...\n")
                output.append("\t${PluginAPI.GetPluginVersion(p)} > ${PluginAPI.GetPluginVersion(latest)}\n")
                output.append('\tResult: ')
                if(Settings.TEST_MODE)
                    output.append('SKIPPED - test mode\n')
                else if(PluginAPI.GetPluginIdentifier(latest) ==~ Settings.IGNORE_REGEX)
                    output.append('SKIPPED - matches ignore list\n')
                else
                    output.append(PluginAPI.InstallClientPlugin(context, latest))
            }
        }        
    }
} else if(!Settings.UPGRADE_CLIENTS)
    output.append('\n\nSkipping clients; client upgrades are disabled!')
else
    output.append('\n\nNo clients are connected to the server!')
if(Settings.SEND_MAIL)
    sendMail(output.toString())
print output
return 0

def sendMail(def msg) {
   def ant = new AntBuilder()
   ant.mail(mailhost: EmailSettings.host, mailport: EmailSettings.port, subject: EmailSettings.subj, user: EmailSettings.user, password: EmailSettings.pwd, ssl: EmailSettings.ssl) {
       from(address: EmailSettings.from)
       to(address: EmailSettings.to)
       message(msg)   
   }
}
__________________
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
  #1066  
Old 12-28-2011, 01:41 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
@Slugger - I tried searching this thread but I couldn't find the answer to setting the right Return codes for Comskip. If I remember correctly Comskip is kind of wonky in what it returns after successfully processing a file. I just comskipped a file and everything seemed to work but I get the red bullet icon in the Completed Tasks lists. What should I set for Max return code and min return code for Comskip? Is it 1 and 1?
__________________
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
  #1067  
Old 12-28-2011, 01:54 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by wayner View Post
@Slugger - I tried searching this thread but I couldn't find the answer to setting the right Return codes for Comskip. If I remember correctly Comskip is kind of wonky in what it returns after successfully processing a file. I just comskipped a file and everything seemed to work but I get the red bullet icon in the Completed Tasks lists. What should I set for Max return code and min return code for Comskip? Is it 1 and 1?
I think min=0 and max=1 is appropriate, but maybe someone who's using comskip will chime in (I use SA myself). Pretty sure 0/1 is correct, though. If you look through the v4 user guide (or definitely in the old v3 user guide), I believe I document the proper RCs for comskip there.
__________________
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
  #1068  
Old 12-28-2011, 02:03 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
I couldn't find any direction in the users guide. The comskip example page says:
Quote:
Max/Min Return Code: ShowAnalyzer, like most programs, returns zero on success and any other value means failure. comskip.exe returns zero OR one on success. Configure appropriately.
__________________
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
  #1069  
Old 12-28-2011, 02:07 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
With min of 0 and max of 1 I get state=completed (rather than failed) and I get a blue bullet. Should the bullet be blue or green?
__________________
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
  #1070  
Old 12-28-2011, 02:44 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
I believe blue is correct. State=Completed is definitely correct, so I'll assume the blue is as well. Tom will have to confirm that. But as long as the state gets to complete then all is well.
__________________
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
  #1071  
Old 01-02-2012, 03:42 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
Move media files to folder = Show Title

Here is a SJQ script that is a slight modification of Slugger's Move Media File script. The modification is that this will move to a directory that is based off of the show's title and a hard-coded base directory. The hard-coded base directory would likely be something like \\server1\TV Shows\. So if you want to move a Seinfeld show it would go to \\server1\TV Shows\Seinfeld\. The script does check for characters that are illegal in file/folder names and it should also move multi-segment files and related files like .edl files and .properties files (if applicable) - this is thanks to Slugger's excellent coding in the original as that is beyond my capabilities. It should create folder names if they don't already exist. Note that this will move to a literal file name that might not be what you are expecting -ie "Go, Diego, Go!" is a legal name for a directory so that is what is used not Go Diego Go.

The script does not need any parameters and I have set it up so that it only uses a Groovy script, no executable is required.

Here is what the setup in the SJQ UI looks like on my system:


To use:
Create a folder on your c drive called C:\GroovyFiles
Download the file attached below and move it to C:\GroovyFiles and rename the file to mv_Show_Folder.groovy
Change the BaseDirectory to your relevant Base Directory.
Setup the task in SJQ.

I haven't yet done this but you could likely set this up to move a file after the recording is finished.

NOTE: After moving files you should do a rescan in Sage!
Attached Files
File Type: txt mv_Show_Folder.groovy.txt (5.1 KB, 162 views)
__________________
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
  #1072  
Old 01-02-2012, 07:30 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Scrapable file names...

By request, here's a script that will calculate "scrapable" file names for all your recordings. This script doesn't actually rename any files or do anything useful. It's provided more as a starting point for others who may want to do something more useful with this type of info.

The output generates file names that match the format that BMT looks for when scraping file names (except for sports since there was nothing to go on, I just created my own). One should be able to easily adjust the output to match other scrappers as desired (Plex, XBMC, etc.).

Code:
import org.apache.commons.io.FilenameUtils

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()
MediaFileAPI.GetMediaFiles('T').each {
    def season = ShowAPI.GetShowSeasonNumber(it)
    def episode = ShowAPI.GetShowEpisodeNumber(it)
    def details
    if(season > 0 && episode > 0)
        details = String.format('%s-S%02dE%02d%s', ShowAPI.GetShowTitle(it), season, episode, ShowAPI.GetShowEpisode(it) ? "-${ShowAPI.GetShowEpisode(it)}" : '')
    else if(ShowAPI.GetOriginalAiringDate(it) > 0)
        details = String.format('%s %s %s', ShowAPI.GetShowTitle(it), new Date(ShowAPI.GetOriginalAiringDate(it)).format('yyyy-MM-dd'), ShowAPI.GetShowEpisode(it) ? "- ${ShowAPI.GetShowEpisode(it)}" : '')
    else if(ShowAPI.GetShowCategory(it) == 'Movie')
        details = String.format('%s (%s)', ShowAPI.GetShowTitle(it), ShowAPI.GetShowYear(it))
    else if(ShowAPI.GetShowCategory(it) == 'Sports event' && ShowAPI.IsShowFirstRun(it))
        details = String.format('%s-%s-%s', ShowAPI.GetShowTitle(it), ShowAPI.GetShowEpisode(it), new Date(AiringAPI.GetAiringStartTime(it)).format('yyyy.MM.dd'))
    else
        details = null
    if(details) {
        (0 .. MediaFileAPI.GetNumberOfSegments(it) - 1).each { i ->
            def segFile = MediaFileAPI.GetFileForSegment(it, i)
            def newName = sanitize(String.format('%s-%d-%d.%s', details, AiringAPI.GetAiringID(it), i, FilenameUtils.getExtension(segFile.getName())))
            output << "$segFile >> $newName\r\n"
        }
    } else
        output << "Skipped '${ShowAPI.GetShowTitle(it)}'; not enough metadata to build new file name!\r\n"
}
println output
return 0
Output snippet from my system...

Code:
\\nas\tv\BoardwalkEmpire-Anastasia-3911855-0.ts >> Boardwalk Empire-S01E04-Anastasia-3911855-0.ts
\\nas\tv\BoardwalkEmpire-BoardwalkEmpire-3716893-0.ts >> Boardwalk Empire-S01E01-Boardwalk Empire-3716893-0.ts
\\nas\tv\BoardwalkEmpire-BroadwayLimited-3845321-0.ts >> Boardwalk Empire-S01E03-Broadway Limited-3845321-0.ts
\\nas\tv\TheKingsSpeech-11420886-0.ts >> The King's Speech (2010)-11420886-0.ts
\\nas\tv\RobinHood-11465980-0.ts >> Robin Hood (2010)-11465980-0.ts
D:\tv\NHLHockey-NewYorkRangersvsPhiladelphiaFlyers-11466894-0.ts >> NHL Hockey-New York Rangers vs Philadelphia Flyers-2012.01.02-11466894-0.ts
D:\tv\MythBusters-Outtakes-10941625-0.ts >> MythBusters 2011-09-25 - Outtakes-10941625-0.ts
D:\tv\TheSimpsons-TheBlueandtheGray-5118887-0.ts >> The Simpsons-S22E13-The Blue and the Gray-5118887-0.ts
__________________
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
  #1073  
Old 01-03-2012, 08:08 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
Is it possible to run a job whenever any recording has finished?
__________________
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
  #1074  
Old 01-03-2012, 08:19 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Yes, in the SJQ menu on the STV you can attach a task to an event. Just attach a task to the RecordingCompleted event and that task will be queued at the completion of every recording.
__________________
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
  #1075  
Old 01-08-2012, 08:02 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
Adding timed recordings using SJQ

I want to create a Timed Recording in SJQ. This will be for testing if an encoder is working properly.

It appears that you can add an Airing via AiringAPI.AddAiring:
Quote:
AddAiring
public sage.Airing AddAiring(java.lang.String ShowExternalID,
int StationID,
long StartTime,
long Duration)Adds a new Airing object to the database. This call should be used with caution.

Parameters:
ShowExternalID - a GUID which uniquely identifies the Show that correlates with this Airing, this Show should already have been added
StationID - the GUID which uniquely identifies a "Station" (sort of like a Channel).
StartTime - the time at which the new Airing starts
Duration - the duration of the new Airing in milliseconds
Returns:
the newly added Airing
But it says that the Show should have already been created. Do your really need a Show for a Timed Recording?

Could you just create a show with lots of null data, for example:
ManRecID=AiringAPI.AddAiring(ShowAPI.AddShow("Test Recording"),55,date()+60000,date()+360000)
to create a 5 minute test recording on StationID 55 that starts 1 min from now and ends 6 mins from now and have it return the new Airing ID?

FYI the docs for the ShowAPI.AddShowAPI are:
Quote:
AddShow
public sage.Show AddShow(java.lang.String Title,
boolean IsFirstRun,
java.lang.String Episode,
java.lang.String Description,
long Duration,
java.lang.String[] Categories,
java.lang.String[] PeopleList,
java.lang.String[] RolesListForPeopleList,
java.lang.String Rated,
java.lang.String[] ExpandedRatingsList,
java.lang.String Year,
java.lang.String ParentalRating,
java.lang.String[] MiscList,
java.lang.String ExternalID,
java.lang.String Language,
long OriginalAirDate,
int SeasonNumber,
int EpisodeNumber)Adds a new Show to the database. Null or the empty string ("") can be passed in for any unneeded fields.

Parameters:
Title - the title of the Show (for music this should be album name)
IsFirstRun - true if this Show is a first run, false otherwise (this parameter has no effect anymore since Airings determine first/rerun status)
Episode - the episode name for this Show (for music this should be the song title)
Description - the description of the Show
Duration - the duration of the Show, not necessary and can be zero; this is only used for indicating differences between Airing duration and the actual content duration
Categories - an array of the categories of the Show (should be genre for music)
PeopleList - a list of all of the people in the Show, the roles of the people should correspond to the RolesListForPeopleList argument
RolesListForPeopleList - a list of the roles for the people in the Show, this should correspond to the PeopleList argument
Rated - the rating for the Show see GetShowRated()
ExpandedRatingsList - the expanded ratings list for the show, see GetShowExpandedRatings()
Year - the year of the Show
ParentalRating - the parental rating for the Show (this is no longer used since Airing contains the parental rating)
MiscList - miscellaneous metadata for the Show
ExternalID - the global ID which should be used to uniquely identify this Show
Language - the language for the Show
OriginalAirDate - the original airing date of the Show
SeasonNumber - the season number of the Show
EpisodeNumber - the episode number for the specific season for the Show
Returns:
the newly created Show object
Since:
7.1
__________________
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
  #1076  
Old 01-08-2012, 08:40 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
I think you want to use Global.CreateTimedRecording() Nice and easy that way!
__________________
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
  #1077  
Old 01-08-2012, 09:37 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
I didn't even think to look in the Global API - thanks Slugger.
__________________
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
  #1078  
Old 01-09-2012, 11:16 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
What's the best way to do logging for one's SJQ scripts? I have been writing my own log files, often creating specific log files for each MediaFile processed. But that can get messy if you don't clean up the files. (Which I guess could be fixed by Slugger's cleanup script). But some times it is useful to have more history in your logs so you don't always want them purged right away.

Is there a better way to do this, such as using a centralized logging file? Would it make sense to use the sjq.log file or should that be kept for SJQ administration?

Should I set up a seprate centralized log file called something like sjqtasks.log? It looks like you are using log4j for SJQ logs - can I also use log4j(which I know nothing about - yet) for task logging? Can I just look up the docs on this to get started. Or is this a bad idea for some reason?
__________________
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
  #1079  
Old 01-09-2012, 11:27 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by wayner View Post
What's the best way to do logging for one's SJQ scripts? I have been writing my own log files, often creating specific log files for each MediaFile processed. But that can get messy if you don't clean up the files. (Which I guess could be fixed by Slugger's cleanup script). But some times it is useful to have more history in your logs so you don't always want them purged right away.

Is there a better way to do this, such as using a centralized logging file? Would it make sense to use the sjq.log file or should that be kept for SJQ administration?

Should I set up a seprate centralized log file called something like sjqtasks.log? It looks like you are using log4j for SJQ logs - can I also use log4j(which I know nothing about - yet) for task logging? Can I just look up the docs on this to get started. Or is this a bad idea for some reason?
SJQ already logs the stdout and stderr output produced by your tasks. So all the println statements are logged and recorded for each task.

If you wanted to use log4j then that's certainly doable, but I'd probably ensure the current SJQ task logging isn't sufficient.

The only issue with the current SJQ task logging is that the only place to read the log files is from the STVi or by directly accessing the SJQ database, neither of which is particularly user friendly. The good news is that I've started work on the various web views and editors for SJQv4 and am currently testing/using the task log viewer from the web UI, which makes reading the logs much easier. No ETA on this delivery, but it's coming.
__________________
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
  #1080  
Old 01-09-2012, 11:42 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 7,491
I do get at the logs through the STVi but I find it useful to have the logs for all of the tasks in one place. I have just set up a task that runs after any recording finishes at it is useful to see the relevant output from this task in one file for all processed files.
__________________
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
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
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


All times are GMT -6. The time now is 01:25 PM.


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