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
  #561  
Old 03-13-2011, 10:11 PM
Korny Korny is offline
Sage Advanced User
 
Join Date: Nov 2010
Location: Minnesota
Posts: 87
in the UI plugin how exactly do you start a script file in linux
I've tried in the executable spot
sh /path/to/file/bash.sh
also
/path/to/file/bash.sh
and
"sh /path/to/file/bash.sh"
and
"/path/to/file/bash.sh"

also for the arguments I'm using just $SJQ4_LAST_SEGMENT
do I put it in quotation marks?

Basically I'm triggering the event after a show is complete. If I was looking at terminal it would simply be
sh /path/to/file/bash.sh filename.mpg
but I can't seem to get it right

Last edited by Korny; 03-13-2011 at 10:43 PM.
Reply With Quote
  #562  
Old 03-14-2011, 08:38 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by Korny View Post
in the UI plugin how exactly do you start a script file in linux
I've tried in the executable spot
sh /path/to/file/bash.sh
also
/path/to/file/bash.sh
and
"sh /path/to/file/bash.sh"
and
"/path/to/file/bash.sh"
Two choices:

1) Just put /path/to/file/bash.sh and make sure the executable bit it set on the file.

2) Just put sh as the executable and for the arguments put "/path/to/file/bash.sh" "$SJQ4_LAST_SEGMENT"

Quote:
also for the arguments I'm using just $SJQ4_LAST_SEGMENT
do I put it in quotation marks?
You need to double quote this only if there is a possibility of spaces in the file name when the var is expanded. To be safe, you can just always double quote it.

Quote:
Basically I'm triggering the event after a show is complete. If I was looking at terminal it would simply be
sh /path/to/file/bash.sh filename.mpg
but I can't seem to get it right
To do it this way, set the excutable as sh and the arguments as:

"/path/to/file/bash.sh" "$SJQ4_LAST_SEGMENT"
__________________
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
  #563  
Old 03-15-2011, 12:58 PM
K O K O is offline
Sage User
 
Join Date: Sep 2009
Location: Austin, TX
Posts: 68
I've been playing with the groovy scripts and been able to add some customizations that work for my needs, but I was wondering if there's a way to block adding an item to the queue if the task is already in the queue.

I setup a periodic scanner, but if the period is shorter than the speed at which the file can be processed, the item will queue up numerous times, potentially bogging down the system.

Is it possible to access the queued tasks from within a groovy script?
Reply With Quote
  #564  
Old 03-15-2011, 01:49 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by K O View Post
Is it possible to access the queued tasks from within a groovy script?
Yes, it's possible, but the easier/recommended approach is to tag items you've queued with metdata and then check the metadata before queuing an item.

So let's say your scanner finds a media file to queue, after adding it to the queue successfully, tag it with a special metadata value:

Code:
Object mf; // This is the media file object, obtained somehow, some way

// Do your checks, etc. and now you want to queue this media file...

String tag = MediaFileAPI.GetMediaFileMetadata(mf, "MY_TAG")
if(tag == null || tag != "1") { // We haven't queued this item before
   sc.addTask("MYTASK", Factory.get(mf))
   MediaFileAPI.SetMediaFileMetadata(mf, "MY_TAG", "1")
}
You could inspect the SJQ task queue to accomplish the same thing, but I think you'll find this way much easier (and not susceptible to breaking if the SJQ API changes).

If your scanner is based on my media_file_scanner.groovy script then I'd just add the metadata check inside the needsProcessing() function as one of the conditions to check. If you make it the last check then if it passes (and you're about to return true) then go ahead and tag the object with the metadata value. If it's not the last check, then you'll need to tag the object further down in the code where the object is added to the queue. Hopefully this all makes sense?
__________________
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
  #565  
Old 03-15-2011, 03:00 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Slugger View Post
This week's Groovy addition is my implementation of full SageTV backups.

Follow this wiki doc for details on how to set it all up. This is an advanced configuration for advanced SJQv4 users. The task must run on a standalone task client (or outside of SJQv4 altogether). You cannot run this task from the SageTV plugin version of the task client (because part of the process is to shutdown SageTV, more details in wiki).

Basically, when you set it all up, you get the following:

An SJQv4 task capable of determining when it's "safe" to stop SageTV and perform a full backup of the SageTV application folder then restart SageTV. See the wiki doc and the scripts for more details.

Happy scripting!
Slugger,

I downloaded these scripts and it's working very well. I modified the test script slightly to ignore connected clients because mine are always connected. (I might fiddle with it some more to not run if anybody is actually watching something.)

The only question I have (that I should probably know the answer to) is how long will it try to run the task before giving up? I have the task set to go off daily at 4:00 AM and I want to make sure if either executes or is removed from the queue by 6:00 AM.

Tom
__________________

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
  #566  
Old 03-15-2011, 03:29 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
By default tasks will run for up to 24 hours. You can configure that on the task client config by setting the maxtime for the task to 7200 seconds (two hours).
__________________
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
  #567  
Old 03-15-2011, 05:30 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Slugger View Post
By default tasks will run for up to 24 hours. You can configure that on the task client config by setting the maxtime for the task to 7200 seconds (two hours).
OK. That's what I had done but I wasn't sure if that was the best way.

One small comment, the exe will not run unless there is a 60 minute window because the test script checks for a 30 minute window but it usually gets run a few seconds past the hour or 1/2 hour mark. (So there are a few seconds less than 30 minutes to the next recording.) I changed the script to wait for a 15 minute window.
__________________

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
  #568  
Old 03-15-2011, 06:01 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by tmiranda View Post
One small comment, the exe will not run unless there is a 60 minute window because the test script checks for a 30 minute window but it usually gets run a few seconds past the hour or 1/2 hour mark. (So there are a few seconds less than 30 minutes to the next recording.) I changed the script to wait for a 15 minute window.
That's a good point, but you really shouldn't change it to 15 minutes, you should change it to like 29m30s or something like that if you're really after an approximate 30 minute window.
__________________
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
  #569  
Old 03-15-2011, 06:24 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Slugger View Post
That's a good point, but you really shouldn't change it to 15 minutes, you should change it to like 29m30s or something like that if you're really after an approximate 30 minute window.
You're probably right, but I think it's a moot point. About 99% of my recordings will be multiples of 30 minutes in length so 15 minutes is just as good.

I really like this script, it makes backup a snap.
__________________

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
  #570  
Old 03-15-2011, 07:46 PM
judoGTI judoGTI is offline
Sage Advanced User
 
Join Date: Mar 2005
Posts: 131
Quote:
Originally Posted by Slugger View Post
Tonight's Groovy addition is keep_stb_alive.groovy.

Inspired by shadeblue's STBKeepAlive plugin and the desire to do some IR testing on a Linux Sage server, this little Groovy script will allow you to issue an IR command to your SageTV configured STBs. Unlike the STBKeepAlive plugin, this script supports any IR device configured to work in Sage and will work on any Sage supported OS. In other words, if your IR commands are working in Sage then this script will happily issue the same IR commands (since it uses the Sage API to trigger the IR commands).

If you needed to periodically send an IR command to your STB(s) then simply setup this script to run periodically via the SJQv4 crontab. The script could be easily modified to only issue the IR command if the tuner attached to the remote is not currently recording or is about to be used, etc. Such enhancements are left as an exercise for the reader.

Happy scripting!
This looks perfect for my needs! Does Sjq4 work with Sage 6.x or only 7.0?

EDIT: Nevermind, just read the FAQ, 7.0 only
Reply With Quote
  #571  
Old 03-15-2011, 08:22 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by judoGTI View Post
This looks perfect for my needs! Does Sjq4 work with Sage 6.x or only 7.0?

EDIT: Nevermind, just read the FAQ, 7.0 only
Sorry.
__________________
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
  #572  
Old 03-18-2011, 08:46 AM
bikesquid's Avatar
bikesquid bikesquid is offline
Sage Aficionado
 
Join Date: Jan 2010
Location: California's North Coast
Posts: 392
Got a question about renaming files. Looking through the script library (great resource btw!) I see the move file script, which is close to what I'd like to do, I think....

I'm archiving files using Series/Season/Series - SxxExx format and have been using a batch file to do this with the .properties info, but I'm finding it not reliable and would rather pull the season/episode info and do this via sjq if possible.

Being none to bright to start with and an idiot with any coding I wonder if anyone can help me put together the move script with a line or two (hopefully) to pull season episode info and rename the file accordingly?

Any help much appreciated!
Reply With Quote
  #573  
Old 03-18-2011, 08:53 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by bikesquid View Post
Got a question about renaming files. Looking through the script library (great resource btw!) I see the move file script, which is close to what I'd like to do, I think....

I'm archiving files using Series/Season/Series - SxxExx format and have been using a batch file to do this with the .properties info, but I'm finding it not reliable and would rather pull the season/episode info and do this via sjq if possible.

Being none to bright to start with and an idiot with any coding I wonder if anyone can help me put together the move script with a line or two (hopefully) to pull season episode info and rename the file accordingly?

Any help much appreciated!
So you want to move the file, but also rename it to SxxExx format? That's not too difficult if you're just going to modify my move script. The only difficult thing is what to do if the season/episode data doesn't exist? Just leave the file name alone? You figure that out and I'll see what I can do with the script (probably not today, but maybe on the weekend. You might have to nudge me by middle of next week if I forget).
__________________
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
  #574  
Old 03-18-2011, 09:14 AM
bikesquid's Avatar
bikesquid bikesquid is offline
Sage Aficionado
 
Join Date: Jan 2010
Location: California's North Coast
Posts: 392
Quote:
Originally Posted by Slugger View Post
So you want to move the file, but also rename it to SxxExx format? That's not too difficult if you're just going to modify my move script. The only difficult thing is what to do if the season/episode data doesn't exist? Just leave the file name alone? You figure that out and I'll see what I can do with the script (probably not today, but maybe on the weekend. You might have to nudge me by middle of next week if I forget).
If you're able to put something together that would be outstanding!... and I'm sure some other sage users do something similar and would benefit.

Here's what I do now:
Test for existing season/episode info, if it exists rename to format:
Series - SxxExx (ex: Dexter - S05E02)

If season/episode info doesn't exist, rename to format:
Series - Episode (ex: Chuck - Chuck vs the Suitcase)
I've been doing this by stripping the last 10 characters from the file name.
It doesn't work too well with shows like Top Gear that often have no any episode title/info... so the work around I've been doing is naming the file sequentially so I'm not overwriting by simply doing a test on the name existing in archive location, if exist +1 and retest till it fails, that's my new name.... crude but it works. I'm sure there's a better way, but it's all I could think of... to be honest it doesn't always work and I never know why, which is why I'd rather go with a sjq script....

Then I move it to \\Sage-PC\TV\Series\Season\ folder structure. (ex: \\Sage-PC\TV\Dexter\Season 5\Dexter - S05E02.ts )
Reply With Quote
  #575  
Old 03-18-2011, 09:26 AM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by bikesquid View Post
If you're able to put something together that would be outstanding!... and I'm sure some other sage users do something similar and would benefit.

Here's what I do now:
Test for existing season/episode info, if it exists rename to format:
Series - SxxExx (ex: Dexter - S05E02)

If season/episode info doesn't exist, rename to format:
Series - Episode (ex: Chuck - Chuck vs the Suitcase)
I've been doing this by stripping the last 10 characters from the file name.
It doesn't work too well with shows like Top Gear that often have no any episode title/info... so the work around I've been doing is naming the file sequentially so I'm not overwriting by simply doing a test on the name existing in archive location, if exist +1 and retest till it fails, that's my new name.... crude but it works. I'm sure there's a better way, but it's all I could think of... to be honest it doesn't always work and I never know why, which is why I'd rather go with a sjq script....

Then I move it to \\Sage-PC\TV\Series\Season\ folder structure. (ex: \\Sage-PC\TV\Dexter\Season 5\Dexter - S05E02.ts )
That's a little more than a simple rename operation. That's fine, but if you really want me to look at this and whip something up then please open a ticket with all of these details pasted in on my project site.

The scope of this exercise just got a whole lot bigger. It's not a 30 minute job anymore, but seems like a solid few hours (minimum) to do this and test it properly, which is fine, but can't guarantee it'll even be this week now, but with a ticket I'll definitely eventually do it.

Something to address in the ticket: If there's no season/episode data available then how do you know which season folder to move the file to or does it just go under \TV\Series\?
__________________
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
  #576  
Old 03-18-2011, 10:18 AM
bikesquid's Avatar
bikesquid bikesquid is offline
Sage Aficionado
 
Join Date: Jan 2010
Location: California's North Coast
Posts: 392
Quote:
Originally Posted by Slugger View Post
That's a little more than a simple rename operation. That's fine, but if you really want me to look at this and whip something up then please open a ticket with all of these details pasted in on my project site.

The scope of this exercise just got a whole lot bigger. It's not a 30 minute job anymore, but seems like a solid few hours (minimum) to do this and test it properly, which is fine, but can't guarantee it'll even be this week now, but with a ticket I'll definitely eventually do it.

Something to address in the ticket: If there's no season/episode data available then how do you know which season folder to move the file to or does it just go under \TV\Series\?
Well, maybe I know not what I ask?

The archive I admit has "a little" more complexity than a simple move but I don't know that it has to be.... What I described is my current process, if I get the file name as right as it can be given the available info that would be hugely helpful and maybe is a legitimately separate script from an archiving process. The source info used seems the same which is why, to my pea-brain, they're done at the same time. Doing a manual move to the right place isn't a big deal these days, with eye-boggling transfer speeds it only takes a few seconds per show to transfer to the archive drive. If a simpler request would be to move to new location if all the needed info is there, and if not dump it in a manual archival holding directory, that would work well for me too.

Didn't intend to make work, if there's anything I can do/test to save some of your time on this let me know!
Thanks.
Reply With Quote
  #577  
Old 03-21-2011, 08:04 PM
phareous phareous is offline
Sage Advanced User
 
Join Date: Jul 2009
Posts: 234
I'm getting an error like this when comskip runs:

Permission denied - could not open file \\HTPC\E\shows1/UndercoverBoss-MGMGrand-8515047-0.mpg

The file is there, and I can open it via windows explorer. Its got full security permissions for any user to open it. Any ideas?
Reply With Quote
  #578  
Old 03-21-2011, 08:24 PM
graywolf's Avatar
graywolf graywolf is offline
Sage Icon
 
Join Date: Oct 2009
Location: NC
Posts: 1,389
Quote:
Originally Posted by phareous View Post
I'm getting an error like this when comskip runs:

Permission denied - could not open file \\HTPC\E\shows1/UndercoverBoss-MGMGrand-8515047-0.mpg

The file is there, and I can open it via windows explorer. Its got full security permissions for any user to open it. Any ideas?
Not sure what is causing it but you have / before UndercoverBoss whereas the rest is \
Reply With Quote
  #579  
Old 03-21-2011, 08:53 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by phareous View Post
I'm getting an error like this when comskip runs:

Permission denied - could not open file \\HTPC\E\shows1/UndercoverBoss-MGMGrand-8515047-0.mpg

The file is there, and I can open it via windows explorer. Its got full security permissions for any user to open it. Any ideas?
Quote:
Originally Posted by graywolf View Post
Not sure what is causing it but you have / before UndercoverBoss whereas the rest is \
My guess is you're passing "$SJQ4_PATH/$SJQ4_LAST_SEGMENT" as the exe args for the task? If so, change that slash to a backslash and that should fix you up. If your exe is a native Windows app then the slashes must always be backslashes in file paths, but if your exe is, for example, a Java app then the slash types (usually) won't matter. comskip is a Windows app and needs the slashes set correctly in this case.
__________________
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
  #580  
Old 03-21-2011, 09:11 PM
phareous phareous is offline
Sage Advanced User
 
Join Date: Jul 2009
Posts: 234
Thanks I will try changing the slash.

On an unrelated note, does anyone have a script or tutorial on how to setup SQJ4 to clean out old .edl and .txt files?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 4 (0 members and 4 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 03:39 AM.


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