SageTV Community  

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

Notices

SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-26-2010, 02:28 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
Initiate Media Scan script?

Is there a script/exe to initiate a scan of import folders by executing it?

I just bought ANYDVD for blu rays and set it as an import path. I can get anydvd to launch a script/program on media change and want that to initiate an import folder scan.

I don't want to set the auto interval to like 1 minute or anything as I don't watch that many blu rays yet.
Reply With Quote
  #2  
Old 12-26-2010, 05:54 PM
skiingwiz skiingwiz is offline
Sage Aficionado
 
Join Date: Jan 2005
Posts: 366
If you have installed the Sage Scripting Framework, then the following small python script will do it.

Code:
from sagex.api import Global
Global.RunLibraryImportScan(False)
Reply With Quote
  #3  
Old 12-26-2010, 08:29 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
Apologies but not being a java coder Im not sure where to put everything and how. I have the framework downloaded but not sure where to put the files. I assume the script you supplied goes in the scripts folder but how do I initiate it?

Thanks again.
Reply With Quote
  #4  
Old 12-26-2010, 08:51 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
I think there's a sendmessage utility. I don't remember if there's a command to initiate a scan, but if so you could use sendmessage to send the rescan command.
Reply With Quote
  #5  
Old 12-26-2010, 09:34 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by stanger89 View Post
I think there's a sendmessage utility. I don't remember if there's a command to initiate a scan, but if so you could use sendmessage to send the rescan command.
No, there's no scan command. The scripting framework thing may be the only currently available method.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #6  
Old 12-26-2010, 10:23 PM
skiingwiz skiingwiz is offline
Sage Aficionado
 
Join Date: Jan 2005
Posts: 366
Quote:
Originally Posted by David HVR1600 View Post
Apologies but not being a java coder Im not sure where to put everything and how. I have the framework downloaded but not sure where to put the files. I assume the script you supplied goes in the scripts folder but how do I initiate it?

Thanks again.
Sorry about that. I guess I didn't give you all of the details.

You can put the files for the scripting framework anywhere. They connect remotely to sage, so it doesn't matter where they are. (Which reminds me, you have to have the Sage Remote APIs plugin installed on the server.)

Then you can call the script using the command
Code:
java -jar ssf.jar scripts/yourScript.py
replace scripts/yourScript.py with the path to your script.

A better rundown of all of this is at the wiki page that I originally linked to. If it works for you, you can run the script by hand and then watch on your TV for the "Library Scan in Progress" icon to appear in the sage interface.

I do all of this on my own machine, so I can verify that it works as intended. (I'm using DirMon to trigger the script whenever I add files to a directory, but otherwise it is exactly what you are trying to do.)
Reply With Quote
  #7  
Old 12-27-2010, 09:26 AM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
Thanks, the script works great. Unfortunately it seems Anydvd isnt launching it I will play with that more later but thanks for the help!
Reply With Quote
  #8  
Old 12-30-2010, 05:37 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
So... second question.... Can I alter things like import folders with a similar script? When the CD is removed but the drive letter is shown as an import folder it can't scan it so it just leaves the last disk on my media list.
Reply With Quote
  #9  
Old 12-30-2010, 06:43 PM
skiingwiz skiingwiz is offline
Sage Aficionado
 
Join Date: Jan 2005
Posts: 366
Quote:
Originally Posted by David HVR1600 View Post
So... second question.... Can I alter things like import folders with a similar script? When the CD is removed but the drive letter is shown as an import folder it can't scan it so it just leaves the last disk on my media list.
Yep. You can call any Sage API from these scripts. In this case check out the Configuration API. You'll be interested in the AddLibraryImportPath and RemoveLibraryImportPath calls.
Reply With Quote
  #10  
Old 12-31-2010, 01:13 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
Ok well I got the add path working fine but the remove path is not.

Curiously the Add command passes a string but the remove wants a file object.

I tried just passing a string but got a type cast error (c# verbiage sorry)

This is the script as I wrote it:
Code:
from sagex.api import Global
from sagex.api import Configuration
Configuration.RemoveVideoLibraryImportPath(java.io.File("f:\\"))
Global.RunLibraryImportScan(False)

This code yields the following result:

Code:
Error Launching Class: sagex.ScriptRunner
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at ScriptingFrameworkLauncher.main(ScriptingFrameworkLauncher.java:122)
Caused by: javax.script.ScriptException: Traceback (innermost last):
  File "<unknown>", line 3, in ?
NameError: java

        at com.sun.script.jython.JythonScriptEngine.evalCode(JythonScriptEngine.
java:292)
        at com.sun.script.jython.JythonScriptEngine.eval(JythonScriptEngine.java
:170)
        at com.sun.script.jython.JythonScriptEngine.eval(JythonScriptEngine.java
:175)
        at javax.script.AbstractScriptEngine.eval(Unknown Source)
        at sagex.ScriptRunner.main(ScriptRunner.java:46)
        ... 5 more
Caused by: Traceback (innermost last):
  File "<unknown>", line 3, in ?
NameError: java

        at org.python.core.Py.NameError(Unknown Source)
        at org.python.core.PyFrame.getglobal(Unknown Source)
        at org.python.core.PyFrame.getname(Unknown Source)
        at org.python.pycode._pyx0.f$0(<unknown>:3)
        at org.python.pycode._pyx0.call_function(<unknown>)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyCode.call(Unknown Source)
        at org.python.core.Py.runCode(Unknown Source)
        at com.sun.script.jython.JythonScriptEngine.evalCode(JythonScriptEngine.
java:289)
        ... 9 more
At this point I am wondering if this is due to the fact that there is no DVD in the drive or I am trying to pass a "File" object but supplying a diretctory name?
Reply With Quote
  #11  
Old 01-05-2011, 10:27 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
Anyone? any ideas how to use the remove function correctly?

Thanks in advance.
Reply With Quote
  #12  
Old 08-16-2012, 10:20 PM
David HVR1600 David HVR1600 is offline
Sage User
 
Join Date: May 2008
Posts: 60
This is pretty old and maybe nobody needs this but I will answer my own question.

AnyDVD never panned out the way I wanted it to so I stopped looking at this not too long after making my alst post. I ran in to the need to get this working today and realized my mistake from above in that the remove line argument needed to be instantiated correctly as a "file" type variable and then the variable needed to be passed to the remove call.

so the remove script looks like this:

from sagex.api import Global
from sagex.api import Configuration
from java.io import File
IDir = File("//server/share/subfolder")
Configuration.RemoveLibraryImportPath(IDir)
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
Satellite Channel Scan Error: Can't do C-Band and Ku-Band Providers in the same scan Kiwi_Tim Hardware Support 0 09-16-2009 05:19 AM
Scan for Media New Beta nyplayer SageTV Beta Test Software 5 05-30-2009 03:24 PM
What Is Currently Recording Script joe123 SageTV Customizations 18 02-05-2007 09:40 PM
init script n8willis SageTV Linux 7 01-15-2007 03:33 PM


All times are GMT -6. The time now is 07:55 AM.


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