SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Customizations (http://forums.sagetv.com/forums/forumdisplay.php?f=27)
-   -   Plugin: Sage Job Queue (SJQ) v3 (http://forums.sagetv.com/forums/showthread.php?t=45174)

graywolf 08-24-2011 06:12 AM

Quote:

Originally Posted by BKeadle (Post 513688)
Hoping someone is still out there - I see the last post was in April, and alot has changed since then, especially with Google being the new owner.

I only now got around to getting SJQ v3.1 installed (I'm using SageTV v6). I'm having trouble getting any tasks to queue up. I've tried the media debugger, and though it finds the video of interest, nothing reports in the server log. I have no failed or completed tasks and I don't see items in the Active queue.

I've made my ruleset "wide open", in attempt to ensure *SOMETHING*, but I get nothing:

if [ Filename =$ ".mpg" && Filename =^ "Fringe" ]
{
MEDIASHRINKMQ
}

Help?

You might want to try:

Code:

if [IsObjMediaFile == true && $.IsTVFile{} == true && $.GetShowTitle{} == "Fringe" && Filename =$ ".mpg" ]
 {
  MEDIASHRINKMQ
 }

Or you can leave it as yours and double-check the file name. I don't recall, but think it might be case sensitive. So if the filename is FRINGE-S01E01.mpg, it would not match Fringe.

What is the output in the logs when you try MediaDebugger for one of the shows?

Also, what is your client config setting for MEDIASHRINKMQ ?

BKeadle 08-24-2011 07:41 AM

It's ALIVE! Yay! Thanks for your reply!

When I use the Media Debugger and type "Fri" it does find:
V:\Videos\Drobo2\Recordings\_TVShows\Fringe\Fringe-03.mpg
(I did notice that it is case sensitive)

However, nothing appears in the Server Logs after doing the Media Debugger, just this:
Code:

2011-08-24 08:31:07,940 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 08:31:47,455 INFO  [InternalTaskClient]: Run completed [0ms]
2011-08-24 08:31:49,784 INFO  [SJQServlet]: Servlet POST request completed [0ms]

My client config is this:
Code:

MEDIASHRINKMQ
{
  :CPU "NORMAL"
  :MAX 1
  :RESOURCES 51
  "\"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe\" \"%c%\" /inPlace /batch /vbitrate 2500 /onePass "
}

Nothing else is in the active queue.

The videos I'm trying process are not on the Recording drive, but the "archive" drive. I do have "Scan Imported Videos" enabled. Since the Media Debugger finds the show when I type, "Fringe", I assume that means SJQ is scanning that drive where I've moved much of my recordings.

Something else odd: When I go to the MediaFileQueueLoader, it shows the last run time as 5:28am, even though I've run it several times since then (it's now 8:38a), and the "Next Run" shows to be 6:12 AM, even though it is way past that time, and I've set Maxiumum time MediaFileQueueLoader to be 60 minutes.

I have set "Run in Debug Mode" to enabled, but the server log doesn't look any different - should it? I've restarted the client, but it's the server that I'd like to restart, but not sure how to do that (without a reboot). Does one "restart jetty"?

I had started with your code that you suggest, but wasn't sure how the "GetShowTitle{}" or "IsTVFile{}" get's determined, and whether the .mpg on the Archive drive might have somehow lost the title and type information somehow , so I thought by testing against the filename would be more..."sure".

Thanks again for your prompt reply. I'm hopeful now that this will be resolved since I'm not alone.
;)

nyplayer 08-24-2011 09:07 AM

If this is not working.

if [ Filename =$ ".mpg" && Filename =^ "Fringe" ]
{
MEDIASHRINKMQ
}


Try using contains =*

if [ Filename =$ ".mpg" && Filename =* "Fringe" ]
{
MEDIASHRINKMQ
}

graywolf 08-24-2011 11:03 AM

Quote:

Originally Posted by BKeadle (Post 513700)
However, nothing appears in the Server Logs after doing the Media Debugger, just this:
Code:

2011-08-24 08:31:07,940 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 08:31:47,455 INFO  [InternalTaskClient]: Run completed [0ms]
2011-08-24 08:31:49,784 INFO  [SJQServlet]: Servlet POST request completed [0ms]

Nothing else is in the active queue.

I had started with your code that you suggest, but wasn't sure how the "GetShowTitle{}" or "IsTVFile{}" get's determined, and whether the .mpg on the Archive drive might have somehow lost the title and type information somehow , so I thought by testing against the filename would be more..."sure".

Thanks again for your prompt reply. I'm hopeful now that this will be resolved since I'm not alone.
;)

GetShowTitle and IsTVFile is handled by the Sage API

Might want to do as NYPlayer suggested, use the Contains since Filename may (I don't know) include the entire path.

Strange that you are not getting stuff in the System Log. Should be something like the following:

Code:

2011-08-24 12:57:35,156 WARN  [MediaFileQueueLoader]: Processing 'Stossel'...
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating 'IsObjMediaFile == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating '$.IsTVFile{} == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating '$.GetAiringChannelName{} =% "TNT.*|USA.*|FX.*|DSC.*|WCCB.*"' == false
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating 'IsObjMediaFile == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating '$.IsTVFile{} == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating '$.GetAiringChannelName{} =% "WBTV.*"' == false

Do you have anything in your Completed or Failed Tasks lists?

can you include your Ruleset? might have a problem there.

Have you tried stopping/restart Sage Service (if you are in Service Mode)

doncote0 08-24-2011 03:16 PM

Try this.
 
Quote:

Originally Posted by BKeadle (Post 513688)
if [ Filename =$ ".mpg" && Filename =^ "Fringe" ]
{
MEDIASHRINKMQ
}

Help?

Try this

If [IsObjMediaFile == true && Filename =$ ".mpg" && Filename =^ "Fringe" ]
{
:SCANMEDIA "true"
:RUNQLOADER "true"
MEDIASHRINKMQ
}

you might also want to add IsViewingMedia == false && to the initial condition filter.

doncote0 08-24-2011 04:52 PM

CLIENT CONFIG
 
Quote:

Originally Posted by BKeadle (Post 513700)
My client config is this:
Code:

MEDIASHRINKMQ
{
  :CPU "NORMAL"
  :MAX 1
  :RESOURCES 51
  "\"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe\" \"%c%\" /inPlace /batch /vbitrate 2500 /onePass"
}

Nothing else is in the active queue.

Try this

MEDIASHRINKMQ
{
:CPU "NORMAL"
:MAX 1
:RESOURCES 51
"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe \"%c%\" /inPlace /batch /vbitrate 2500 /onePass "
}

and yes, using includes =* is better for the initial filter.

nyplayer 08-24-2011 05:04 PM

Quote:

Originally Posted by doncote0 (Post 513774)
Try this

If [IsObjMediaFile == true && Filename =$ ".mpg" && Filename =^ "Fringe" ]
{
:SCANMEDIA "true"
:RUNQLOADER "true"
MEDIASHRINKMQ
}

you might also want to add IsViewingMedia == false && to the initial condition filter.

That will never work because File name includes the whole path so unless your recording paths are named "Fringe" it will never find the files which can never be the case because all paths start with either \\ or drive letter. You need to use the Filename =* "Fringe" that way it will look at the whole filename not just the beginning (which is the path).

BKeadle 08-24-2011 09:25 PM

Thanks, all, for your suggestions. In response...

This is my entire rule set at the moment:
Quote:

/*
Media Shrink
*/

if [ Filename =$ ".mpg" && Filename =* "Fringe" ]
{
MEDIASHRINKMQ
}

I made the "=*" change you suggested. Still nothing. I have made the change and hit Save (what does "Reload" mean?), I went to MediaFileQueueLoader and selected "Run Now". Still, nothing shows up in active queue, and no Failed Tasks or completed tasks. The system log only shows this:
Code:

2011-08-24 22:04:29,279 INFO  [ClientMonitor]: Run completed [0ms]
2011-08-24 22:04:37,356 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:42,809 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:42,825 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:52,824 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:53,839 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:53,855 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:04:57,526 INFO  [SJQServlet]: Servlet POST request completed [15ms]
2011-08-24 22:04:57,542 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:05:01,214 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:05:01,229 INFO  [SJQServlet]: Servlet POST request completed [15ms]
2011-08-24 22:05:12,603 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 22:05:13,228 INFO  [SJQServlet]: Servlet POST request completed [5156ms]
2011-08-24 22:05:44,272 INFO  [InternalTaskClient]: Run completed [0ms]
2011-08-24 22:05:59,724 INFO  [SJQServlet]: Servlet POST request completed [6640ms]
2011-08-24 22:06:12,614 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 22:06:27,143 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:07:07,937 INFO  [SJQServlet]: Checking client '127.0.0.1': 100 resources free.
2011-08-24 22:07:07,952 INFO  [SJQServlet]: Client '127.0.0.1' cannot pop a task of type 'MEDIASHRINKHQ': Task disabled by :OFFHOUR setting!
2011-08-24 22:07:07,952 INFO  [SJQServlet]: Servlet POST request completed [15ms]
2011-08-24 22:07:12,608 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 22:07:44,262 INFO  [InternalTaskClient]: Run completed [0ms]
2011-08-24 22:08:12,634 INFO  [SystemMessageQueueLoader]: Run completed [16ms]
2011-08-24 22:08:27,148 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:09:12,644 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 22:09:29,252 INFO  [ClientMonitor]: Run completed [0ms]
2011-08-24 22:09:44,251 INFO  [InternalTaskClient]: Run completed [0ms]
2011-08-24 22:09:46,438 INFO  [SJQServlet]: Servlet POST request completed [5874ms]
2011-08-24 22:10:12,655 INFO  [SystemMessageQueueLoader]: Run completed [0ms]
2011-08-24 22:10:27,138 INFO  [SJQServlet]: Servlet POST request completed [0ms]
2011-08-24 22:10:27,528 INFO  [SJQServlet]: Servlet POST request completed [1968ms]

Note, the OFFHOUR setting is for MEDIASHRINKHQ - not MEDIASHRINKMQ that is being called.

Here's my client setting:
Code:

#:OFFHOUR "8-11,12-24," # No processing between 7a-11am and 6p-12pm

COMSKIP
{
  # REF: http://forums.sagetv.com/forums/showthread.php?p=394054&postcount=89

  :RESOURCES 25 # Up to 4 comskips can be run simultaneously (every client has exactly 100 resources available)

  # CPU priority to be used for this task process; one of LOW, NORMAL, HIGH (case sensitive)
  :CPU "NORMAL"  # Default is NORMAL if not specified

  # Comskip returns 1 on success instead of the universally accepted zero; tell SJQ that
  # a return code of 1 means success instead of the default value of zero
  :RETURNCODE 1

  "\"C:/Program Files/SageTV/comskip/comskip.exe\" \"--ini=C\:\\Program Files\\SageTV\\comskip\\comskip.ini\" \"%c%\""

}

MEDIASHRINKHQ
{
  :CPU "LOW"
  :OFFHOUR "0-1, 16-23"
#  :OFFDAY "1, 7"
  :MAX 1
  :RESOURCES 51
  "\"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe\" \"%c%\" /inPlace /batch /vprofile HQ /vbitrate 2500 /twopass"
}

MEDIASHRINKMQ
{
  :CPU "NORMAL"
#  :OFFHOUR "0-1, 16-23"
#  :OFFDAY "1, 7"
  :MAX 1
  :RESOURCES 51
  "\"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe\" \"%c%\" /inPlace /batch /vbitrate 2500 /onePass "
}

MEDIASHRINKLQ
{
  :CPU "NORMAL"
#  :OFFHOUR "0-1, 16-23"
#  :OFFDAY "1, 7"
  :MAX 1
  :RESOURCES 51
  "\"C:/Program Files/SageTV/MediaShrink/mediaShrink.exe\" \"%c%\" /inPlace /batch /vbitrate 1500 /onePass "
}

The COMSKIP *did* work (the rule set has been limited to just the mediashrink section during troubleshooting this issue). It's where I resolved the command line to work. I had tried:
"C:/Program Files/SageTV/comskip/comskip.exe" but it gave me an error about not being able to run the program, "C:/Program", so I had to quote-out the path like this to get COMSKIP to work:
"\"C:/Program Files/SageTV/comskip/comskip.exe\"

So I figure the same syntax will be required for Mediashrink.

What is still a bit disconcerting is the MediaFileQueueLoader last run still shows the 5:28am as the last run time. I did restart the client service, but I figure it's not the client that's having the problem, it appears to be the server component (jetty) not even getting things into the Active Queue for the client to work against. Is there a way to reset/restart the server component? It's feeling more like that's where the problem is since:
A) the last run time isn't being displayed
B) there is no activity in the Server logs.

I might just be at a point now that I just reboot my server - though if this continues to happen, I'd like to know how to "kick" the server component without having to reboot.

BKeadle 08-24-2011 09:36 PM

Ah ha! Server Snapshot (Debug) shows this:
Code:

Wed Aug 24 22:33:58 CDT 2011: SJQ Application Dump
        MediaQueueLoader thread is dead!
        SysMsgQueueLoader thread is alive...
                java.lang.Thread.sleep(Native Method)
                com.google.code.sagetvaddons.sjq.server.SystemMessageQueueLoader.run(SystemMessageQueueLoader.java:79)
                java.lang.Thread.run(Unknown Source)
        ClientMonitor thread is alive...
                java.lang.Thread.sleep(Native Method)
                com.google.code.sagetvaddons.sjq.server.ClientMonitor.run(ClientMonitor.java:38)
                java.lang.Thread.run(Unknown Source)
        InteralTaskClient thread is alive...
                java.lang.Thread.sleep(Native Method)
                com.google.code.sagetvaddons.sjq.server.InternalTaskClient.run(InternalTaskClient.java:68)
                java.lang.Thread.run(Unknown Source)
        Most recent LogCleaner thread is dead (this is normal behaviour)!
        Most recent FileCleaner thread is dead (this is normal behaviour)!
        Most recent VacuumCleaner thread is dead (this is normal behaviour)!

That would explain the Last Run issue, and perhaps why nothing is showing up. So...how does one bring the MediaQueueLoader thread back alive? (without a reboot?)

BKeadle 08-25-2011 04:52 AM

Voila! It's now working! I found that restarting the SageTV service restarts the webservices. The MediaFileQueueLoader, now running, has queued up the active tasks, and the client is busy at work.

Thanks again for your participation and suggestsions. I can now put back my original Ruleset. That was unnecessarily painful - in the end, it's a relatively easy diagnostic and resolution...now that I know!
:thumb:

graywolf 08-25-2011 05:28 AM

Wonderful. Glad you have it back up and running

graywolf 08-25-2011 05:45 AM

Another thing you might want to use is Tools => Media Debugger

That way you choose the particular file you want, and when you look in the system log file, you will see how SJQ evaluated the various Ruleset lines (true/false).

Very helpful in debugging. Would have shown that Filename =^ "Fringe" was evaluating to false.

Code:

2011-08-24 12:57:35,156 WARN  [MediaFileQueueLoader]: Processing 'Stossel'...
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating 'IsObjMediaFile == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating '$.IsTVFile{} == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 26: Evaluating '$.GetAiringChannelName{} =% "TNT.*|USA.*|FX.*|DSC.*|WCCB.*"' == false
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating 'IsObjMediaFile == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating '$.IsTVFile{} == "true"' == true
2011-08-24 12:57:35,156 WARN  [RulesParser]:        Line 32: Evaluating '$.GetAiringChannelName{} =% "WBTV.*"' == false


BKeadle 08-25-2011 06:49 PM

Yeah, I tried that (desperately), but apparently with the MediaFileQueueLoader being dead, *that* also doesn't work.

As for the quoting "mess" of the mediashrink in a directory containing spaces, I was thinking about having the client call out to a batch file, e.g.:
C:\SJQScripts\MediaShrink.bat

and then have it call out to the C:\Program Files\SageTV\MediaShrink\mediashrink.exe, *and* be able to do tasks afterwards, such as moving the resulting file to a certain subdirectory (and what ever other serial tasks I may want to do against the file which may be too difficult to accomplish through SJQ.) Any cautions or suggestions about doing that?

nyplayer 08-25-2011 09:08 PM

BKeadle,

You should look at this thread evilpenguin the author mediashrink has some very good samples on how to properly use mediashrink with SJQ.

Here is a sample of how I move my archived Mediashrink files.


Code:

if [IsObjMediaFile == "true" && Filename !* "SAGEO" && (Filename =$ ".avi" || (Filename =$ ".mkv")) && $.IsLibraryFile{} == "true"  && $.GetNumberOfSegments{} == "1"] {
  :SCANMEDIA "true"
  :MOVERECOPTS "\\\\SAGENET\\SAGEO"
    :PRIORITY 9999
  _MOVEREC
}


BKeadle 08-26-2011 05:27 AM

Thanks for the thread link. I'm familiar with that thread, and what I started with. Though I'm able to move recording to a different location from my recording drive to my archive drive, I like to move my videos to named subdirectories instead of all recordings in a single directory. For example, the video:
I've moved the recording
AllintheFamily-TheElectionStory-906972-0.mpg
to
V:\Drobo2\_TVShows
with _MOVEREC. But after I've converted it from mpg to mkv, I want to move it to it's associated subdirectory
.\_TVShows\AllInTheFamily\

I can easily do this using batch scripting, but I don't see how I can do this with SJQ rules. So hence, my idea to have the Client to call out to a batch file that will do the conversion, then afterward, moved to the proper recording subdirectory.

In fact, my rule set I'm considering is moving recordings from my recording drive according to conditions (watched, age, archived). Then a script that watches the archive directory for new (moved) recordings, then kick off the batch file that would then convert the video, then move it to the proper subdirectory, and log the before/after size into an easy-to-read log file-specific for the video conversion.

Know what I mean?

graywolf 08-26-2011 08:37 AM

Not that it helps much with SJQ3 but for my mv_recordings test script (groovy) for SJQ4 I do something similiar to move the recordings to different folders. Not sure if you could reverse engineer to something SJQ3 could use


Code:

/*
  Pretest if MediaFile is currently being Watched
*/

//def  SJQ4_METADATA = ["SJQ4_ID":"2849349","SJQ4_PATH":"c:\\SageRecordings","SJQ4_LAST_SEGMENT":"AmericasNewsHeadquarters-0.mpg"];
//def SJQ4_ARGS = ["\\\\Tower\\UnArchived\\br"];

import com.google.code.sagetvaddons.groovy.api.MediaFileHelpers ;
import org.apache.commons.io.FileUtils ;

String ParentPath = SJQ4_ARGS[0]
String id  = SJQ4_METADATA.get("SJQ4_ID");
Object mf = MediaFileAPI.GetMediaFileForID(id.toInteger());

String FileName = SJQ4_METADATA.get("SJQ4_LAST_SEGMENT");
String FilePath = SJQ4_METADATA.get("SJQ4_PATH");
String ShowTitle=ShowAPI.GetShowTitle(mf);
String ShowSeasonDir ;
String OutputPath ;
int ShowSeasonNum=ShowAPI.GetShowSeasonNumber(mf);

println ( "Test Started");

if ( AiringAPI.IsNotManualOrFavorite(mf) ) {
    println("${FileName} is not a Favorite or Manual Recording - skipped")
    return 2
}
   
if( MediaFileHelpers.isBeingViewed(FileName) ) {
    println("${FileName} is being viewed; Return task to queue!")
    return 1
}

if ( (FilePath.toUpperCase()) =~ "\\\\TOWER" ) {
        println("bypass since ${FilePath} is on TOWER")
        return 2
}

if ( ShowSeasonNum == 0 ) {
    ShowSeasonDir = "" ;
} else {
    ShowSeasonDir = "\\Season " + ShowSeasonNum ;
}

if ( ShowAPI.GetShowCategory(mf).equals ("Movie") ) {
        println("This is a Movie ");
        OutputPath = ParentPath + "\\Movies" ;
} else {
        println("This is a TV show") ;
        OutputPath = ParentPath + "\\" + ShowTitle + ShowSeasonDir ;
}

OutputPath = (OutputPath =~ /[?!*^&#$%@:;]/).replaceAll(" ") ;
println ("Modified OutputPath = ${OutputPath} ");
OutputFile = OutputPath + FileName;
File dest  = new File(OutputPath);

FileUtils.forceMkdir(dest);

Tools.setExeArgs("\"${OutputPath}\"")

println ("Would Start EXE with argument ${OutputPath}");

println ( "Test Ended");

return 0


nyplayer 08-26-2011 08:49 AM

Quote:

Originally Posted by BKeadle (Post 513927)
Thanks for the thread link. I'm familiar with that thread, and what I started with. Though I'm able to move recording to a different location from my recording drive to my archive drive, I like to move my videos to named subdirectories instead of all recordings in a single directory. For example, the video:
I've moved the recording
AllintheFamily-TheElectionStory-906972-0.mpg
to
V:\Drobo2\_TVShows
with _MOVEREC. But after I've converted it from mpg to mkv, I want to move it to it's associated subdirectory
.\_TVShows\AllInTheFamily\

I can easily do this using batch scripting, but I don't see how I can do this with SJQ rules. So hence, my idea to have the Client to call out to a batch file that will do the conversion, then afterward, moved to the proper recording subdirectory.

In fact, my rule set I'm considering is moving recordings from my recording drive according to conditions (watched, age, archived). Then a script that watches the archive directory for new (moved) recordings, then kick off the batch file that would then convert the video, then move it to the proper subdirectory, and log the before/after size into an easy-to-read log file-specific for the video conversion.

Know what I mean?

That is simple to do... your destination in the move simply includes the Media Title then you can use the relink if you want it to appear in recordings.

nyplayer 08-26-2011 12:51 PM

Here is a Simple one to Move Archives.... I copy the file first and make sure it is completely copied before doing a re-link..... which deletes the original.


Code:

//SJQMOVETVShows
if [IsObjMediaFile == true && IsSomethingRecording == "false" && $.IsFileCurrentlyRecording{} == "false" && Filename =$ ".mpg" && $.IsLibraryFile{} == "true" && $.GetNumberOfSegments{} == "1" && Filename !* "_TVShows"] {
  :RUNQLOADER "true"
  SJQMOVETVShows
}
//Relink TVShows
if [IsObjMediaFile == true && $.IsFileCurrentlyRecording{} == "false" && Filename =$ ".mpg" && FileExists == "%d%/%p%.relink" && FileExists == "C://_TVShows/$.GetShowTitle{}/%p%.mpg" && $.GetNumberOfSegments{} == "1"] {
  :PRIORITY 1500
  :RELINKOPTS "$.GetAiringID{}" "C://_TVShows/$.GetShowTitle{}/%p%.mpg"
  _RELINK
}

Code:

SJQMOVETVShows {
  :MAX 1
  :CPU LOW
  :RESOURCES 55
"C:\\SJQTEST\\SJQMOVETITLE.bat \"%c%\" \"$.GetShowTitle{}\" \"C:\\_TVShows\""
}


SJQMOVETITLE.bat
Code:

move "%~f1" "%~d1%~p1"
set checkuse=%ERRORLEVEL%
if %checkuse% NEQ 0 exit 1

set outdir=%3
for /f "useback tokens=*" %%a in ('%outdir%') do set outdir=%%~a

set MediaTitle=%2
rem for /f "useback tokens=*" %%a in ('%MediaTitle%') do set MediaTitle=%%~a
set MediaTitle=%MediaTitle:: = %
set MediaTitle=%MediaTitle:? = %
set MediaTitle=%MediaTitle::= %
set MediaTitle=%MediaTitle:?= %
set MediaTitle=%MediaTitle:& =& %
for /f "useback tokens=*" %%a in ('%MediaTitle%') do set MediaTitle=%%~a
if not exist "%outdir%" md "%outdir%"
if not exist "%outdir%\%MediaTitle%" md "%outdir%\%MediaTitle%"
START /B /W /MIN /BELOWNORMAL xcopy /Y "%~d1%~p1%~n1.**" "%outdir%\%MediaTitle%"
set checkxcopy=%ERRORLEVEL%
if %checkxcopy% EQU 0 echo "xcopy complete" >> "%~d1%~p1%~n1.relink"
if not exist "%~d1%~p1%~n1.relink" exit 1
exit 0



Here are the logs of a test
Code:

Task Log: 252548/SJQMOVETVShows
Fri Aug 26 11:10:25 PDT 2011: Starting task with priority 1/1/10
Executing command line: C:\SJQTEST\SJQMOVETITLE.bat "C:\SAGEREC\MarriedWithChildren-LifesaBeach-212140-0.mpg" "Married ... With Children" "C:\_TVShows"
C:\SJQService\sjqc_winntsvc\bin>move "C:\SAGEREC\MarriedWithChildren-LifesaBeach-212140-0.mpg" "C:\SAGEREC\"
C:\SJQService\sjqc_winntsvc\bin>set checkuse=0
C:\SJQService\sjqc_winntsvc\bin>if 0 NEQ 0 exit 1
C:\SJQService\sjqc_winntsvc\bin>set outdir="C:\_TVShows"
C:\SJQService\sjqc_winntsvc\bin>for /F "useback tokens=*" %a in ('"C:\_TVShows"') do set outdir=%~a
C:\SJQService\sjqc_winntsvc\bin>set outdir=C:\_TVShows
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>rem for /f "useback tokens=*" %a in ('"Married ... With Children"') do set MediaTitle=%~a
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle="Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>for /F "useback tokens=*" %a in ('"Married ... With Children"') do set MediaTitle=%~a
C:\SJQService\sjqc_winntsvc\bin>set MediaTitle=Married ... With Children
C:\SJQService\sjqc_winntsvc\bin>if not exist "C:\_TVShows" md "C:\_TVShows"
C:\SJQService\sjqc_winntsvc\bin>if not exist "C:\_TVShows\Married ... With Children" md "C:\_TVShows\Married ... With Children"
C:\SJQService\sjqc_winntsvc\bin>START /B /W /MIN /BELOWNORMAL xcopy /Y "C:\SAGEREC\MarriedWithChildren-LifesaBeach-212140-0.**" "C:\_TVShows\Married ... With Children"
C:\SAGEREC\MarriedWithChildren-LifesaBeach-212140-0.mpg
1 File(s) copied
C:\SJQService\sjqc_winntsvc\bin>set checkxcopy=0
C:\SJQService\sjqc_winntsvc\bin>if 0 EQU 0 echo "xcopy complete"  1>>"C:\SAGEREC\MarriedWithChildren-LifesaBeach-212140-0.relink"


Code:

Task Log: 252548/_RELINK
Fri Aug 26 11:12:34 PDT 2011
WARNING: Execution of this task will result in deletion of MediaFile #252548 [Married ... With Children]
'C:\_TVShows\Married ... With Children\MarriedWithChildren-LifesaBeach-212140-0.mpg' not registered with SageTV; registering it now...  DONE!
Deleted MediaFile 252548
Relinked MediaFile #252775 to Airing ID #212140


BKeadle 08-26-2011 07:35 PM

you are so *freaking* helpful! Thank you so much. I'll give this a go tomorrow. Thanks!
:goodjob:

BKeadle 08-27-2011 12:34 PM

Lost show information after archiving
 
Uh oh...

After having moved most of my recorded shows to my archive drive, now when I got to the My Videos page, I only a list of file names and no show information (or recording date).

I have .my files of the same name in the same directory. Shouldn't/can't these files be used to display information in Sage?


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

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