Sagetv Download Mac

Posted April 8, 2006 by Jimmy S in Batch file programming

Last Updated on

I used to run SageTV as my PVR front-end but have later decided to switch to MCE2005 due to its cleanness and integration into XP. Anyway, in that time, I found a For statement batch file I used to create my own script to auto-encode video. After playing with For statements for quite some time, I realized that it could be used for so much more!

Run SageTV Clienton Mac, Linux & Chrome OS. Sage TV is a TV PVR application (and server) that runs on PC, Mac, and Linux. Their Placeshifter and Client applications allow you to watch your TV/Recordings over the Internet and Local Network, respectively. Download SageTV Of the media center apps I've tested, it performs better at avoiding duplicate recordings than almost any competitor, which is important if you record series. A recommend feature (not unlike the one found on Tivo consoles) supports intelligent recording and scheduling to find shows you might like based on your existing recording.


Requirements:
-Windows XP (any flavor) or 98 (I believe the statements will read fine.)
-Basic understanding of .bat files
-Full batch file contents for converting in sagetv (http://forums.sagetv.com/forums/showthread.php?t=10709)

Sagetv Forums

Sagetv free download, and many more programs. Sagetv free download, and many more programs. Join or Sign In. Integrate Mac, PVR, online video.

Overview:

This tech-recipe is another of my sagetv/htpc based ones, but it also can be used for much more! This tutorial will explain how to use a For statement in a way you never thought you could. For statements can allow one to send data to apps via command line (if they support this), move data, create webportals, and more!

Also, I have included my own date parsing code. It is handy to have and hard to find on the web..

Date Code:
Usage: use in any batch file you need to use the current date in a MMDDYYYY format; can be called in script by %date; place in beginning of script

Sagetv Download Mac
    @REM parses month, day, and year into mm, dd, yyyy formats to create folders
    FOR /F “TOKENS=1* DELIMS= ” %%A IN (‘DATE/T’) DO SET CDATE=%%B
    FOR /F “TOKENS=1,2 eol=/ DELIMS=/ ” %%A IN (‘DATE/T’) DO SET mm=%%B
    FOR /F “TOKENS=1,2 DELIMS=/ eol=/” %%A IN (‘echo %CDATE%’) DO SET dd=%%B
    FOR /F “TOKENS=2,3 DELIMS=/ ” %%A IN (‘echo %CDATE%’) DO SET yyyy=%%B
    SET date=%mm%%dd%%yyyy%

____________________

Here is a simple example of a For statement that will be used in this tutorial.

@echo on
@REM Seamonkey420's SageTV Batch File - MPG to WMV
@REM created on: 3/14/05
@REM RECOMMENDED TO TEST IN A TEMP DIR FIRST

Sagetv v9 windows download

@REM Setup as is; it will encode mpg to divx, then
@REM clean up the log, txt, ccno and VPrj files
@REM Then moves the avi file to a new folder (odir)
@REM Then finally deletes the original mpg

Mac

@REM 3/15/05: Added creation of subfolders with date encoded
@REM and also allows date variable to be globally available
@REM and added in cleanup of orphan files
@REM 3/19/05: Updated date parsing/folder to be more accurate
@REM also added in new functionality to create an embeded webpage
@REM for each movie file created, is created in the same folder as
@REM avi is encoded to!
@REM 3/27/05: Updated batch now to create a log file of any .wmv or the filetype your
@REM encoding your movies to prior to encoding, then checks to see if log file exists, if so,
@REM skips the file so you do not have to waste time re-encoding movies you have already encoded.
@REM 4/5/2005: Added PSP Video 9 integration; Requires PSPvideo9 be set up for auto-converting
@REM Must have Videora installed or this folder created(C:Program FilesVideora)
@REM moves original mpgs to new psp folder defined in pdir variable.

@REM Be sure to put this batch file in the same folder as your Virtualdub.exe/windows media encoder folder
@REM ALSO Be sure to create a .vcf settings file in Virtualdub or .prx profile in windows media encoder
@REM This file then needs to be saved in the same folder as virtualdub.exe/wme and this batch file
@REM And the embedE.txt, embedS.txt, ndexE, indexS, TVindexE, TVindexS text files
@REM need to be created in this same directory/folder

Download Sagetv Windows 10

@REM PSPvideo9 can then autoconvert files later in day! Added for my PSP!! moves the movie to a new folder for psp video to look for!
@REM Be sure to setup PSP Video9 with videora (note, you only need the folder for it create and have settings in psp video 9
@REM look for this location: C:Program FilesVideora , just make that folder if you don't want to install videora

@REM parses month, day, and year into mm , dd, yyyy formats to create folders off of!
FOR /F 'TOKENS=1* DELIMS= ' %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F 'TOKENS=1,2 eol=/ DELIMS=/ ' %%A IN ('DATE/T') DO SET mm=%%B
FOR /F 'TOKENS=1,2 DELIMS=/ eol=/' %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F 'TOKENS=2,3 DELIMS=/ ' %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%mm%%dd%%yyyy%

@REM SETS SCRIPT VARIABLES, ie folder paths for files to be encoded
@REM idir = the directory that sageTV saves mpg recordings to
@REM odir = folder where wmv files will be saved and webpages
@REM oFile = File extension to be outputted, .wmv by default
@REM ldir = Log file directory
@REM trigger = file to check for to see if programs are done recording/viewed
@REM pdir = Folder where original mpg gets moved if encoded correctly! for use w/
@REM PSP Video 9 and autoconvert feature

set idir=T:Recorded Shows
set odir=T:Encoded Shows
set oFile=wmv
set profile=psp.prx
set ldir=T:Recorded ShowsLog
set trigger=VPrj
set pdir=T:Recorded ShowsPSP

@REM This line checks for a .VPrj file in the idir location.
@REM If it finds the file, it will first create a folder with todays date using mmddyyyy format
@REM into the odir folder and it will then call virtualdub/cscript (windows media encoder) w/the parameters
@REM and the .vcf/.prx profile and encode the mpg into avi/wmv, (a more streamable format than divx)

for /f 'tokens=1 delims=.' %%i in ('dir /s/b '%idir%*-?.%trigger%') do if EXIST '%%i.mpg' (md '%odir%%date%') 2>&1

@REM Newly added, creates log files for existing movies in the logdir folder
@REM Then checks for log file, if log file exists, it will not encode the mpg, but if it does, it will.

for /f 'tokens=4 delims=.' %%i in ('dir /s/b '%odir%*-?.%oFile%') do if NOT EXIST '%ldir%*%%i.log' (echo exists > '%ldir%%%i.log')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%idir%*-?.%trigger%') do if NOT EXIST '%ldir%%%i.log' (cscript.exe wmcmd.vbs -input '%idir%%%i.mpg' -description '%%i' -author 'seamonkey420' -output '%idir%%%i.%oFile%' -loadprofile %profile%)

Mac

@REM this section cleans up the old files and moves the avi to the odirdate folder

for /f 'tokens=1 delims=.' %%i in ('dir /b '%idir%*-?.%oFile%') do if EXIST '%idir%%%i.%oFile%' (move '%idir%%%i.%oFile%' '%odir%%date%%%i.%oFile%')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (del '%idir%%%i.log')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (del '%idir%%%i.txt')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (del '%idir%%%i.%trigger%')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (del '%idir%%%i.ccno')

@REM This line move the original mpg movie if the avi/wmv is created and moved successfully to the psp directory for PSP Video 9 to encode!
@REM I would @REM this line when testing! NOTE, do your deleting in sagetv, batch shouldn't re-encode already encoded files!
@REM NEED TO FIX MOVING PART!!

DEL /Q '%pdir%*.*'
for /f 'tokens=1 delims=.' %%i in ('dir /b '%idir%*-?.%trigger%') do if NOT EXIST '%ldir%%%i.log' (COPY '%idir%%%i.mpg' '%pdir%%%i.mpg')

@REM Remove the @REM from the line below to delete the movie if its been encoded. Defaulted to not delete.
@REM for /f 'tokens=1 delims=.' %%i in ('dir /b '%idir%*-?.%trigger%') do if NOT EXIST '%ldir%%%i.log' (DEL /Q '%idir%%%i.mpg')

Sagetv

@REM These lines create a web page for each movie encoded, embeds into page, play movie from page!
@REM NOTE! this again requires the embedE.txt and the embedS.txt to be located in the same folder
@REM as windows media encoder, this batch file, and the .prx profile (usually, C:Program FilesWindows Media ComponentsEncoder )
@REM Also creates an index.html with links to all html embedded pages in the %date% folder (ie 03192005index.html)
@REM And finally a shows_index.html in the root of the odir (all pages are linked together, so easy to use for your webserver!)
@REM Files are linked! Test before using, like always!

Sagetv Client Download

for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (type embedS.txt > '%odir%%date%%%i.html')

for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (echo ^ >> '%odir%%date%%%i.html')

for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (echo ^^ >> '%odir%%date%%%i.html')

for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.%oFile%') do if EXIST '%odir%%date%%%i.%oFile%' (type embedE.txt >> '%odir%%date%%%i.html')

for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.html') do if EXIST '%odir%%date%%%i.html' (type TVindexS.txt > '%odir%%date%index.html')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.html') do if EXIST '%odir%%date%%%i.html' (echo ^%%i^^ >> '%odir%%date%index.html')
for /f 'tokens=1 delims=.' %%i in ('dir /b '%odir%%date%*-?.html') do if EXIST '%odir%%date%%%i.html' (type TVindexE.txt >> '%odir%%date%index.html')

    Overview: Well, it is amazing what a little time, thinking, discussing, and testing can accomplish. I know that currently ajuhawk has created an application to do most of this and more, but I am a fan of the batch file still, so here is the latest of my batch files.

    Notes: This DOES NOT handle compression in SageTV. Movies/shows may be encoded more than once if compression is used.

    Installation:

    Required Programs:
    -SageTV
    -Cayars Ultimate STV installed
    -Windows Media Encoder 9 (click to go to download page)
    -PSP Video 9 (http://pspvideo9.com)
    -Videora (http://videora.com )

    _________

    Where to Put Files
    -wme.bat put in Windows Media Encoder folder (i.e., C:Program FilesWindows Media ComponentsEncoder)
    -psp.prx or whatever you call your Windows Media Encoder profile; put in Windows Media Encoder folder (i.e., C:Program FilesWindows Media ComponentsEncoder)
    -All the .txt files (i.e., embedS.txt, embedE.txt, indexS.txt, etc.) Put this in Windows Media Encoder folder (i.e., C:Program FilesWindows Media ComponentsEncoder).
    -Put the Encode.cmd into your cayarsexternal folder (i.e., C:Program FilesFrey TechnologiesSageTVSTVsOriginalV2cayarsExternal )

    _________

    Files That Need to Be Modified
    -wme.bat
    You will need to change the idir and the odir parameters.
    The idir is the location where sagetv saves your TV recordings.
    The odir contains the locations where you want to save your encoded files. (Note: This batch will create a new folder in this directory with the date stamp mmddyyyy format)

    Here are the parameters that can be changed/need (with examples) and to what they refer:

    set idir=T:Recorded Shows (where sagetv saves the mpgs of tv shows)
    set odir=T:Encoded Shows (where you want to create your encoded tv show webportal)
    set oFile=wmv (file type you want to encode to)
    set profile=psp.prx (windows media player profile to use)
    set ldir=T:Recorded ShowsLog (location of log folder, be sure to create it before running)
    set trigger=VPrj (main trigger file )
    set pdir=T:Recorded ShowsPSP (location that PSP Video 9 looks for movies to auto-convert)

    Also, if you want to have the batch search for a different file type to trigger the encoding, you can do so here. By default, I have it set to look for a .VPrj file.

    -.txt files
    Modify these files to your liking. I would suggest to run the script/batch first and see how things look. These files are basically templates. I have my batch use to create the webpages and embed the movie into a webpage.

    -Encode.cmd (put and located in C:Program FilesFrey TechnologiesSageTVSTVsOriginalV2cayarsExternal)
    Edit this batch so that it points to where the wme.bat is saved (
    C:Program FilesWindows Media ComponentsEncoderwme.bat).

    -Then once you have all of this done, in Cayars Ultimate STV.
    you can add a menu item to point to this file.
    -Right-click in the menu/submenu where you want to add the encoding option.
    -Choose
    Add New Menu Item > External Program.
    -Then, for the external program, use cmd.exe.
    -For arguments/parameters, use /C “C:Program FilesFrey TechnologiesSageTVSTVsOriginalV2cayarsExternalEncode.cmd”
    (You can copy this line, and then use the Paste From Clipboard option.)
    -Then enter the menu title/text to show the following: i.e., Encode and Publish
    -Then once you are done, right-click again and now Save Menu Definition File.
    Hopefully, you should now be able to just click the option, and the encoding will start automatically in the background.

    ________

    Here is exactly what the batch does:
    1. In sagetv, click the new menu item we added that points to the batch/encode script.
    2. This calls our wme.bat script. This script does it all!
    3. First, it creates a new folder and is created with the current date mmddyyyy (i.e., 03192005)
    4. It then will check for a .VPrj file in the idir.
    5. If it finds one, it will then check the log file folder for a log. If not,
    6. it will then go and encode all the mpg movies that have a .VPrj file using Windows Media Encoder and the profile we saved in the psp.prx.
    7. Once it finishes encoding the .VPrj, it will go back and then create a webpage file .html with the show name/episode (i.e., FamilyGuyFunnyDay-3.html) in the folder that was created (i.e. 03192005/FamilyGuyFunnyDay-3.html).
    8. After the embedded webpage is created, it will go back and then create a main index.html file for that folder (i.e., 03192005index.html).
    9. After the date index is created, another index is then created with links to all of the index.html files that might exist.
    10. Finally, once this is done, the batch will go back and clean up all of the files assocated with the newly encoded wmv (i.e., ccno, txt, log, etc.) if it successfully encoded. Also, move the mpg to the psp folder (for psp video to auto-convert later).
    However, if the encoding of the mpg failed, the original mpg is left alone.
    11. Then it will do some quick orphaned file cleanup.

About Jimmy S

Jimmy Selix is an early adopter that loves to be one of the first on the block to have the latest and greatest in technology and gadgets. Another love of his is being able to share his knowledge to others seeking it. Feel free to drop any comments or questions that you may have.
View more articles by Jimmy S

Sagetv 9

The Conversation

Follow the reactions below and share your own thoughts.

Explanation:
NEW SOFTWARE= New tool since your last visit
NEW VERSION= New version since your last visit
NEW REVIEW= New review since your last visit
NEW VERSION= New version
Latest version
Version number / Beta version number / Update version number and when it whas released.
Type and download
NO MORE UPDATES? = The software hasn't been updated in over 2 years.
NO LONGER DEVELOPED = The software hasn't been updated in over 5 years.
RECENTLY UPDATED = The software has been updated the last 31 days.
Freeware = download free, software.
FreewareTrialware = download free, software but some parts are trial/shareware.
Free software = download free, software and also open source code also known as FOSS (Free and Open Source Software).
Free softwareTrialware = download free, software and also open source code but some parts are trial/shareware.
Freeware Ads = download free, software but supported by advertising, usually with a included browser toolbar. It may be disabled when installing or after installation.
Free software Ads = free download. software and open source code but supported by advertising, usually with a included browser toolbar. It may be disabled when installing or after installation.
Trialware = Also called shareware or demo. Free Trial version available for download and testing with usually a time limit or limited functions.
Payware = No demo or trial available.
Portable version = A portable/standalone version is available. No installation is required.
v1.0.1 = Latest version available.
Download beta = It could be a Beta, RC(Release Candidate) or an Alpha / Nightly / Unstable version of the software.
Download 15MB = A direct link to the software download.
Win = Windows download version. It works on 32-bit and 64-bit Windows.
Win64 = Windows 64-bit download version. It works only on 64-bit Windows.
Mac = Mac download version. It works on 32-bit and 64-bit Mac OS.
Mac64 = Mac OS download version. It works only on 64-bit Mac OS.
Linux = Linux download version.
Portable = Portable version. No installation is required.
Ad-Supported = The software is bundled with advertising. Be careful when you install the software and disable addons that you don't want!
Visit developers site = A link to the software developer site.
Download (mirror link) = A mirror link to the software download. It may not contain the latest versions.
Download old versions = Free downloads of previous versions of the program.
Download 64-bit version = If you have a 64bit operating system you can download this version.
Download portable version = Portable/Standalone version meaning that no installation is required, just extract the files to a folder and run directly.
Portable version available = Download the portable version and you can just extract the files and run the program without installation.
Old versions available = Download old versions of the program.
Version history available = Complete changelog on our site.
= Windows version available.
= Mac OS version available.
= Linux version available.
Our hosted tools are virus and malware scanned with several antivirus programs using www.virustotal.com.
Rating
Rating from 0-10.