# pushCast - Re-Automating Webcasts to TiVo



## markp99 (Mar 21, 2002)

Sorry if this is a re-tread for some of you:

Using a collection of existing utilities, I am able to nicely automate the process of downloading Webcasts to my TiVo:

1. gPodder - http://gpodder.org/

I identified my favorite podcast URLs in the app and set the refresh frequency (i.e., 30 min). This utility checks for new episodes and grabs them automatically into a designated folder on my PC. After a specified period, the webcasts are auto deleted from the PC (i.e., 1 day). A logfile is created with paths/filenames.

2. pyTivo AutoPush - https://code.google.com/p/pytivo-auto-push/

This app monitors the designated folders (i.e., the identified Media folder config'd in pyTivo). As new content arrives in the folder structure, a pyTiVo push is initiated automatically.

3. pyTivo - http://pytivo.sourceforge.net/wiki/index.php/PyTivo

Our trusty utility used to PUSH (and pull) content to TiVo.

4. Webcasts work great; but, as "other" content arrives in my \Media folders, they get also PUSHED to my TiVo in the same automated manner.

Nice!

Thanks to all the authors of the utilities noted above! Your work is much appreciated.

If you have an alternate approach or utilities in your workflow, please share them.

PS> I realize this whole approach may soon be taken down by TiVo, but I am happy to leverage the tools while I can.


----------



## jtdon99 (Oct 26, 2014)

Nice work. I'll give it a try. Thanks


----------



## Fofer (Oct 29, 2000)

Cool, thanks for the write up. Gonna give this a whirl.


----------



## jpwbikes (Feb 19, 2014)

I'm using Juice and pushing the download folder using TiVo Desktop. Working great!:up:


----------



## Mikeguy (Jul 28, 2005)

jpwbikes said:


> I'm using Juice and pushing the download folder using TiVo Desktop. Working great!:up:


For audio podcasts, correct?


----------



## reneg (Jun 19, 2002)

Thanks, your legwork inspired me to re-install auto_push so I can get my weekly episodes of TWiT on my Tivo the way I want them vs having to use the awful Hotlist Web Video app.


----------



## Mikeguy (Jul 28, 2005)

^ +1.


----------



## markp99 (Mar 21, 2002)

Working very nicely, hands-off, w/no GUIs:

*pushCast v0.1*

*Requires:*

1. pyTivo - Installed & running in background
2. pyTivo AutoPush - installed as a service
3. gPodder (podcasts added via GUI & imported iTunes .OPML file)
4. pushCast.bat (see below)
5. Windows Task Scheduler

*The pushCast.bat Process:*

1. pushCast.bat is run every 4 hours via Windows Task Scheduler
- "Run with Highest Privs" option selected to avoid Admin/User intervention

2. pyTivo AutoPush Service - is stopped

3. gPodder - is called from command line (gpo.exe)
- Updates and Downloads NEW podcasts automatically
- gPodder deletes podcasts > specified period

4. Metadata files in \Media directories
- Deletes existing metadata files
- Creates new metadata files in a new \.meta directory when content is found
- Uses the content's parent directory as the TiVo foldername
- Uses the content's filename and the TiVo program/episode title

5. pyTivo AutoPush Service - is started
- Just NEW podcasts are automatically pushed to TiVo
- Service is left running in case new content (torrents, etc.) arrives in the \Media folders

*Remaining Tasks v0.1:*

1. Check if pyTiVo is already running, else launch (i.e., after a reboot)
2. Check if pyTivo AutoPush service is running, else prompt
3. Consolidate TiVo folders
- My ~10 podcasts will create ~10 folders on TiVo when content arrives
- Example - all cnet podcast can go into a single "cnet" folder on TiVo
4. Create some sort of alert if any pushCast steps fail
5. Use a config file to point to apps/folders vs hardcoded
6. If gpo.exe is already running, don't run again (i.e., for a very large/long download)


----------



## markp99 (Mar 21, 2002)

*pushCast v0.2*

*Added: *

1. Group podcasts into logical folders (ex: all 10 CNET podcasts into a single folder - vs one folder per podcast)

*Remaining Tasks:*

1. Check if pyTiVo is already running, else launch (i.e., after a reboot)
2. Check if pyTivo AutoPush service is running, else prompt
3. Create some sort of alert if any pushCast steps fail
4. Use a config file to point to apps/folders vs hardcoded
5. If gpo.exe is already running, don't run again (i.e., for a very large/long download)

pushCast.bat v0.2


----------



## MacBrian (Feb 24, 2002)

Any Mac-centric solutions out there to do this?


----------



## markp99 (Mar 21, 2002)

*pushCast v0.3* - Working great!

*Added: *

1. Simple menu system for more granular control of the program elements
2. Display app status (Running vs Stopped) for pyTivo and Auto_Push service
3. Run Automatically (w/no menu) with "-a" switch
4. Run Silently (from taskbar) with "-s" switch
5. Launch pyTivo if not already running
6. Launch gPodder GUI if desired
7. Created PATH variables at the start of the script - easier to config
8. Recurring Err messages >Nul

My shortcut command line: "pushCast.bat -a -s"

*Remaining Tasks:*

1. Use a config file to point to apps/folders vs hardcoded
2. Use config file to capture Folder rules vs hardcoded


----------



## atmuscarella (Oct 11, 2005)

Mark,

Are you having any issue with gpodder and YouTube? All the pod casts I subbed to via a YouTube Link no longer work and I get a video from YouTube that says: "YouTube is upgrading to a newer version which is not supported by this device or app. To learn more and see where you can watch YouTube, visit www.youtube.com/devicesupport"

I got the same video for a number of (all) YouTube pod casts including: Earth911TV, FastLaneDaily, geekbeattv, HowStuffWorks, jon4lakers, and others. 

Thanks


----------



## atmuscarella (Oct 11, 2005)

markp99 said:


> Yes! I have bunches of these:
> 
> 
> 
> ...


Just tried deleting pod cast then adding it back in by using podcast's YouTube URL instead of using gpodder's YouTube search feature (which is how I added them the first time) this seems to work on the 3 I have tried so far.


----------



## atmuscarella (Oct 11, 2005)

markp99 said:


> Where are you grabbing the new YouTube URL? I've tried to re-grab a couple from iTunes via an OPML playlist export. Same issue.


I actually bring up the pod-cast's channel in YouTube (in Firefox, my default browser) and then go to gpodder and use the "Add podcast via URL" option under subscriptions. Example: TechnoBuffalo's URL is: https://www.youtube.com/user/jon4lakers.

I haven't even had to copy the URLs gPodder seems to preload the URL of my active tab in the "Add podcast via URL" option under subscriptions.


----------



## markp99 (Mar 21, 2002)

*pushCast v0.4*

*Added: * - Added stuff to support my usage prefs

1. Moved user config elements to top of pushCast.bat file
2. Config - Program Paths 
3. Config - Frequency of Refresh (hours)
4. Stop pyTivo option
5. Start/Create & Stop Task Scheduler @ Specified Frequency
6. *Pause & Resume pushCast Macro*
7. Clear Status Indicators (Running/Stopped)

*Remaining Tasks:*

1. Use a config file to point to apps/folders vs hardcoded
2. Use config file to capture Folder rules vs hardcoded

*Suggested Usage:*

1. *(P)AUSE* pushCast when downloading large torrent files
2. *(R)ESUME* pushCast when torrent downloads are complete
3. Run Automatically (-a) & silently (-s) via shortcut, i.e., "*pushCast.bat -a -s"*
4. Run Manually via shortcut, i.e., "*pushCast.bat"* - no command line switches


----------



## Series3Sub (Mar 14, 2010)

For me, I can go several days without turning on my PC. So, while this may work for others, not so for me, and, ironically, this is the very reason the auto downloads on the TiVo was so great. If I boot the PC, I just may as well watch it on the PC. Thanks for all your efforts to help those you can use this solution.


----------



## markp99 (Mar 21, 2002)

Series3Sub said:


> For me, I can go several days without turning on my PC. So, while this may work for others, not so for me, and, ironically, this is the very reason the auto downloads on the TiVo was so great. If I boot the PC, I just may as well watch it on the PC. Thanks for all your efforts to help those you can use this solution.


Before assembling these tools, I had been grabbing webcasts to my phone using a Podcasts app. I would play them back over my phone (ugh), or on the TV via Chromecast - with none of my trusty TiVo controls. I never watch webcasts on my PC.

Watching these on my TV using my TiVo is the use model I wanted.

Series3Sub, yep, this approach won't help you much. Though, even turning on your PC 1-2 times per week will still collect and send your favorite webcasts to your TiVo handsfree. Might be a reasonable compromise.


----------



## Anotherpyr (May 6, 2015)

MacBrian said:


> Any Mac-centric solutions out there to do this?


All of the components listed appear to support Apple's Mac OS X. I hope to try it on my Mac mini in the near future.


----------



## markp99 (Mar 21, 2002)

I was waiting to see if the new Plex app on TiVo would provide an improved use model. I am not a big fan of the interface, and I VERY MUCH prefer to see my external content on my TiVo directly, among my other programming vs hopping out via another app. All of webcast content grabbed by gPodder is visible via Plex, but most of it is ~disposable (managed/removed in pushCast approach by Auto_Push after 1-2 days). I don;t have any permanent content/movies to serve to Plex.

The pushCast approach has been working very well for me - I see about ~10 webcasts added each day onto my TiVo, and then any Torrents that I might grab during the week, all hands free - they just appear in TiVo folders just like any other program. :up:

I've added and trimmed the list of video podcasts I track to the following, in the Folders I create via metadata tags:


```
CNet
	Googlicious (HD) http://feed.cnet.com/feed/podcast/googlicious/hd.xml
	Next Big Thing (HD)	http://feed.cnet.com/feed/podcast/next-big-thing/hd.xml
	CNET On Cars (HD)	http://feed.cnet.com/feed/podcast/cnet-on-cars/hd.xml
	Crave (HD)	http://feed.cnet.com/feed/podcast/crave/hd.xml
	News (HD)	http://feed.cnet.com/feed/podcast/cnet-news/hd.xml
	CNET Top 5 (HD)	http://feed.cnet.com/feed/podcast/cnet-top-5/hd.xml
	First Look (HD)	http://feed.cnet.com/feed/podcast/first-look/hd.xml
	How to (HD)	http://feed.cnet.com/feed/podcast/how-to-video/hd.xml
	Cracking Open (HD)	http://feed.cnet.com/feed/podcast/cracking-open/hd.xml
	CNET Update (HD)	http://feed.cnet.com/feed/podcast/cnet-update/hd.xml
	Apple Byte (HD)	http://feed.cnet.com/feed/podcast/apple-byte/hd.xml
	Car Tech (HD)	http://feed.cnet.com/feed/podcast/car-tech/hd.xml

TedTalks
	TEDTalks (hd)	http://feeds.feedburner.com/TedtalksHD
	TEDTalks Technology	http://feeds.feedburner.com/iTunesPodcastTTTechnology

Photography
	The Art of Photography	http://s3.amazonaws.com/Public-Broadcast/aop-itunes.xml
	Photography Tips & Tricks	http://kelbytv.com/photographytnt/feed/
	Jared Polin	https://www.youtube.com/user/JaredPolin

Misc
	Applied Science	https://www.youtube.com/user/bkraz333
	World Science U	https://www.youtube.com/user/WorldScienceU
	NOVA PBS	https://www.youtube.com/user/NOVAonline
	ReelNASA	https://www.youtube.com/user/ReelNASA
	NASA.gov Video	https://www.youtube.com/user/NASAgovVideo
	NASA Jet Propulsion Laboratory	https://www.youtube.com/user/JPLnews
	engineerguy	https://www.youtube.com/channel/UC2bkHVIDjXS7sgrgjFtzOXQ
	TechnoBuffalo	https://www.youtube.com/user/jon4lakers

The Verge
	The Verge	https://www.youtube.com/user/TheVerge
	The Verge - All Posts	http://www.theverge.com/rss/index.xml
	The Verge - Verge Video Posts	http://www.theverge.com/video
	The Verge - 90 Seconds	http://www.theverge.com/video/90sotv
	The Verge - Detours	http://www.theverge.com/video/detours
	The Verge - Reviews	http://www.theverge.com/video/reviews
	The Verge - The Big Future	http://www.theverge.com/video/big-future
	The Verge - Verge Update	http://www.theverge.com/video/verge-update
	The Verge - Featured Videos	http://www.theverge.com/video/featured_videos

TechCrunch
	TechCrunch	https://www.youtube.com/user/techcrunch
```
I have attached my OPML file (importable into gPodder) if anyone is interested.


----------



## VeeTeeF (Jun 9, 2015)

Mark,

Thanks for all this info. I don't really want to watch podcasts on my computer as I'm not on my home PC very often, and my data usage amounts are monitored at work. Plus I'd rather just have my videos setup like TV programs that I can watch at my leisure.

I realized last month that I hadn't seen a CNET podcast on my Roamio in a while (and they're pretty frequent), then found out Tivo cut the podcast feature with no real replacement method... Really Tivo? REALLY?? I had a number of podcasts that I had been watching since I bought my first Tivo (a Series 2) in college close to a decade ago. NOT.HAPPY.

I looked around for a while for an alternative but got lazy and gave up. Then I ran across gPodder a couple weeks ago and it works great! I've been using it in conjunction with pyTivo to get my YouTube videos back on my TV, but I've been wanting some automation. I saw pyTivo-auto-push today on another thread here, and then ran across this thread while looking for a place to download pytivo-auto-push.

Once I try out your .bat file sometime this week I'll report back here with any issues/successes. Thanks again!


----------



## MacBrian (Feb 24, 2002)

Anotherpyr said:


> All of the components listed appear to support Apple's Mac OS X. I hope to try it on my Mac mini in the near future.


On a Mac, how would I run the "pushCast.bat" file, and what takes the place of the Windows Scheduler??


----------



## markp99 (Mar 21, 2002)

Sorry, I'm not fluent in Mac , but guessing you'd need to replicate the pushCast functionality in:

- Apple Scripts
- Create Cron job(s) to call the script http://www.maclife.com/article/columns/terminal_101_creating_cron_jobs

pushCast.bat is not complicated:

1. Calls/Toggles the various utilities in a predefined order:
>> pyTivo
>> gPodder
>> pyTiVo Auto_Push

2. Creates the necessary Metadata files (& folders)

I have pushCast running on my MacBook, but only in a Win8 VM. Maybe I'll poke around with Applescripts and see if I can make any headway.


----------



## Fofer (Oct 29, 2000)

markp99 said:


> Maybe I'll poke around with Applescripts and see if I can make any headway.


 :up:

I've only tinkered by investigating/tweaking other people's code, but I can say this: AppleScript and Automator are pretty awesome.


----------



## telemark (Nov 12, 2013)

Someone should rewrite pushcast.bat in python, then it'll work in Windows, Mac and Linux.

Is there something in this process that deletes the videos from the Tivo? Or is that manual?


----------



## Fofer (Oct 29, 2000)

Yes, the TiVo and Kodi remote apps I use on my Macs are in Python. Of course, pyTiVo is too


----------



## markp99 (Mar 21, 2002)

telemark said:


> Is there something in this process that deletes the videos from the Tivo? Or is that manual?


Manual on TiVo side after the webcast is viewed.

But auto_push automates the delete of the files on the pc side after nn days. No need for these webcasts to hang around on the pc after they're pushed to TiVo.


----------



## markp99 (Mar 21, 2002)

Python might be a better approach for me. I've been poking around and it appears to be quite familiar to stuff I've used elsewhere.

The only unknowns are (may be trivial):

1. Detection and handling of the PC vs Mac executables for the associated utilities

2. String handling (filenames, paths) - guessing this should be trivial, but will be different for PC vs Mac

3. Detection of app/task status - Running/Stopped - on the Mac (PC already works)


----------



## spynotebook (Jan 28, 2015)

I am working on getting this working on my linux server. I see a lot of Mac and windows discussion, does pushCast work on Ubuntu? I have autopush working through the gui as of a few minutes ago.


----------



## markp99 (Mar 21, 2002)

pushCast is a Windows batch file in its current form. When I return from vacation I'll take a stab at converting to python.


----------



## Fofer (Oct 29, 2000)

markp99 said:


> pushCast is a Windows batch file in its current form. When I return from vacation I'll take a stab at converting to python.


Sweet! That post made my day. :up: Good luck and thanks. No expectations of course, but you just giving it a shot makes me hopeful and happy.


----------



## Anotherpyr (May 6, 2015)

markp99 said:


> Sorry, I'm not fluent in Mac , but guessing you'd need to replicate the pushCast functionality in:
> 
> - Apple Scripts
> - Create Cron job(s) to call the script http://www.maclife.com/article/columns/terminal_101_creating_cron_jobs
> ...


Under the hood OS/X is based on BSD Unix and the Mach kernel. The equivalent to bat files would be shell scripts. As far scheduling, crontab is the command for creating the file cron will read for scheduling execution. OS X and Linux versions should be almost identical if not the same.


----------



## markp99 (Mar 21, 2002)

*pushCast v0.5.4*

*Bug Fix: *

1. 0.5.1 (7/13) - pyTivo toggle during Auto mode (-a) was not working properly.
2. 0.5.2 (7/14) - Auto Push toggle during Auto issue fixed
3. 0.5.3 (7/20) - bug fix - Auto option select from Menu fixed
4. 0.5.4 (7/22) - AutoPush should be paused before running gPodder

*New: *

1. pushCast determines the current state [Running vs Stopped] upon launch
2. Replaced menu system with simple App toggles - more compact menu
3. App toggles is actually a better/simpler approach for these tasks - IMO



















*Remaining Tasks:*

1. Use a config file to point to apps/folders vs hardcoded
2. Use config file to capture Folder rules vs hardcoded

*Suggested Usage:*

1. *(P)AUSE* pushCast when downloading large torrent files
2. *(R)ESUME* pushCast when torrent downloads are complete
3. Run Automatically (-a) & silently (-s) via shortcut, i.e., "*pushCast.bat -a -s"*
4. Run Manually via shortcut, i.e., "*pushCast.bat"* - no command line switches

*Python Version*

1. I actually made very good progress creating a Python version for Windows, but realized I cannot determine app status in a reliable way without needing to include 3rd party utilities (like psutils). I really wanted to keep the vanilla Python install used for pyTivo. The Python version is functional, but I doubt I will continue on that path.

2. I made zero attempts to extend the Python version to support OSX or Linux as I am simply not familiar with those OSs and was pretty certain I'd need additional 3rd party utilities to get the functionality I wanted

*Windows Batch File*

*pushCast.bat v0.5.4*


```
@echo off
:: pushCash v0.5.4

::===User Config=================================================

set myFreq=4
set mediaPath=c:\users\mark\downloads\media
set pyTivoPath=c:\pyTivo\pyTivo.py
set pythonPath=c:\python27\python.exe
set gPodderPath="c:\program files (x86)\gpodder"

::===============================================================
:Start   
   set ver=0.5.2
   setlocal enabledelayedexpansion
   for %%I in (%*) do if /i "%%~I"=="-s" (
       powershell -window minimized -command ""
   )

::===========myMenu=============
:myMenu

   call :setScreen
   call :checkPyTivo
   call :checkGpodder
   call :checkAutoPush
   call :checkTaskScheduler

   ::====Command Line - Auto=======

   if "%1"=="-a" (
:pushCastAuto
	set AutoPush=Running
   	set pushCast=Auto
	call :AutoPush
   	goto pushCast
   )

:pushCastManual
   set pushCast=Manual
   echo.
   echo ====================================
   echo  pushCast v%ver%            
   echo  OS: Windows                                        
   echo ====================================
   echo  App Toggles:                      
   echo.                   
   echo    1. pyTivo              [%pyTivo%]             
   echo    2. gPodder             [%gPodderGUI%]           
   echo    3. Auto_Push           [%AutoPush%] 
   echo    4. Scheduler [%myFreq%Hr]     [%TaskScheduler%]
   echo.
   echo ====================================
   echo  pushCast:                       
   echo.                                          
   echo    A. Run Auto ^& Exit    
   echo    M. Process Metadata
   echo.                                
   echo    G. gPodder GUI 
   echo    V. View AutoPush Log
   echo.
   echo    P. Pause All   
   echo    R. Resume All
   echo.                                          
   echo    X. Exit                           
   echo.                                          
   echo ====================================
   echo.
   choice /C:1234AMGVPRX /N /M "Select: "
   echo.
  
   if errorlevel 11 goto end
   if errorlevel 10 call :Resume
   if errorlevel 9 call :Pause
   if errorlevel 8 goto AutoPushView
   if errorlevel 7 goto gPodderGUI
   if errorlevel 6 goto MetaData
   if errorlevel 5 goto pushCastAuto
   if errorlevel 4 call :taskScheduler
   if errorlevel 3 goto AutoPush
   if errorlevel 2 call :gPodder
   if errorlevel 1 call :pyTivo

goto myMenu

::====================================
:gPodderGUI

   if %gPodderGUI%==Stopped (
      cd %gPodderPath%
      start gpodder.exe 
   )
   goto myMenu

::====================================
:AutoPushView

   start notepad %mediaPath%\auto_push.txt
   goto myMenu

::====================================
:pushCast

   cls
   echo.
   echo Running pushCast - Auto v%ver%
   echo ============================
   echo.

::====================================
:pyTivo

   if %pyTivo%==Stopped (
      echo pushCast - Starting pyTivo
      Start "pushCast - pyTivo" /min %pythonPath% %pyTivoPath% /wait
   ) else (
      if %pushCast%==Manual (
      	echo pushCast - Stopping pyTivo
      	if %pyTivo%==Running taskkill /im python.exe >Nul
      )
   )
   if !pushCast!==Manual goto :eof
   
::====================================
:gPodder

   cls
   echo.
   echo pushCast - Running gPodder
   echo ==========================
   echo.
   cd %gPodderPath%
   call gpo update 2>nul 
   echo.
   call gpo download 2>nul
   echo.
   if !pushCast!==Manual goto myMenu

::====================================
:Metadata

   echo pushCast - Preparing Metadata

   set File1=filelist.txt
   set File2=filelist2.txt

   set cdPath=%mediaPath:~3%
   cd/%cdPath%

   ::Remove existing metadata files
   for /f "delims=" %%f in (%File2%) do del "%%f" 2>nul

   ::List current \Media files
   dir /s/b *.mp4 *.mkv *.m4v > %File1%

   ::Write metadata
   for /f "tokens=*" %%a in (%File1%) do ( 

      :: filename, w/extension
      set myFile=%%~nxa

      :: filename, no extension
      set myTitle=%%~na

      :: Full path, no filename
      set myPath=%%~dpa

      :: Parent folder
      for %%b in ("!myPath:~0,-1!") do set "myParent=%%~Nb" && set myFolder=~Misc Podcasts

rem ::===TiVo Folders=====================

      echo !myParent!|FINDSTR /i /c:"project loon" /c:"google" /c:"nat and lo" >NUL
      if !errorlevel! == 0 set myFolder=~Google Podcasts

      echo !myParent!|FINDSTR /i /c:"science" /c:"scishow" /c:"numberphile" /c:"veritasium" /c:"vsauce" >NUL
      if !errorlevel! == 0 set myFolder=~Science Podcasts

      echo !myParent!|FINDSTR /i /c:"B and H" >NUL
      if !errorlevel! == 0 set myFolder=~Photo Podcasts

      echo !myParent!|FINDSTR /i /c:"thrones" >NUL
      if !errorlevel! == 0 set myFolder=~Game of Thrones

      echo !myParent!|FINDSTR /i /c:"photo" /c:"jared polin" >NUL
      if !errorlevel! == 0 set myFolder=~Photo Podcasts

      echo !myParent!|FINDSTR /i /c:"crunch" >NUL
      if !errorlevel! == 0 set myFolder=~TechCrunch Podcasts

      echo !myParent!|FINDSTR /i /c:"verge" >NUL
      if !errorlevel! == 0 set myFolder=~The Verge Podcasts

      echo !myParent!|FINDSTR /i /c:"cnet" /c:"how to" /c:"crave" /c:"googlicious" /c:"first look" /c:"next big thing" /c:"news" /c:"cracking open" /c:"apple byte" /c:"crave" /c:"car tech" >NUL
      if !errorlevel! == 0 set myFolder=~CNET Podcasts

      echo !myParent!|FINDSTR /i /c:"tedtalks" >NUL
      if !errorlevel! == 0 set myFolder=~TED Talks

      rem ::=============================
      :: Create Meta folder
      if not exist "!myPath!\.meta" mkdir "!myPath!.meta"

      set myMetaFile="!myPath!\.meta\!myFile!"
      echo title : !myFolder! > !myMetaFile!.txt
      echo seriesTitle :  !myFolder! >> !myMetaFile!.txt
      echo seriesId :  !myFolder! >> !myMetaFile!.txt
      echo episodeTitle :  !myTitle! >> !myMetaFile!.txt
      echo description :  !myTitle! >> !myMetaFile!.txt
      echo isEpisode : true >> !myMetaFile!.txt
      echo isEpisodic : true >> !myMetaFile!.txt
   )

   ::=============================
   
   dir /s/b *.*.txt > %File2%

   ::Count the Metadata files
   Set /a Qty=0
   For /f %%j in ('Type %File1%^|Find "" /v /c') Do Set /a Qty=%%j
   echo pushCast - %Qty% files processed
   if !pushCast!==Auto set AutoPush=Stopped
   if !pushCast!==Manual goto myMenu

::=============subroutines============
:AutoPush

   if %AutoPush%==Stopped (
   	echo pushCast - Starting Auto_Push Service
   	echo. >> auto_push.txt
   	echo ***** pushCast - %date% %time% ***** >> auto_push.txt
   	cd\pytivo\service\win32
   	call start-service.bat >nul
   ) else (
   	echo pushCast - Stopping Auto_Push Service
	cd\pytivo\service\win32
	call stop-service.bat >nul
   ) 

if %pushCast%==Manual goto myMenu
if %pushCast%==Auto goto :eof
		
::====================================
:end

   echo.
   echo pushCast - Complete
   echo.
   echo.
   exit

::====================================
:checkPyTivo

   tasklist /FI "IMAGENAME eq python.exe" | find /I "python.exe">nul &&(
      set pyTivo=Running
   )||(
      set pyTivo=Stopped
   )
   goto :eof

::====================================
:checkGpodder

   tasklist /FI "IMAGENAME eq gPodder.exe" | find /I "gPodder.exe">nul &&(
      set gPodderGUI=Running
   )||(set gPodderGUI=Stopped)
   goto :eof

::====================================
:checkAutoPush

   sc query Auto_Push| find "RUNNING" >nul 2>&1 && set  AutoPush=Running
   sc query Auto_Push| find "RUNNING" >nul 2>&1 || set AutoPush=Stopped
   goto :eof

::====================================
:checkTaskScheduler

   set TaskScheduler=Stopped
   schtasks /query >doh
   findstr /B /I "pushCast" doh >nul
   if %errorlevel%==0  set TaskScheduler=Running
   goto :eof

::====================================
:TaskScheduler

   if %TaskScheduler%==Running (
      echo pushCast - Stopping Task Scheduler
      schtasks /delete /tn pushCast /F >Nul
   ) else (
      echo pushCast - Starting Task Scheduler
      schtasks /create /tn pushCast /tr "C:\pyTiVo\pushCast.bat -a -s" /sc hourly /mo %myFreq% > Nul
	)
   goto :eof

::====================================
:setScreen

   MODE CON: COLS=100 LINES=50
   COLOR 1B
   CLS
   goto :eof

::====================================
:Pause
   
   echo pushCast - Pausing...
   echo =====================
   echo.
   set pyTivo=Running
   set TaskScheduler=Running
   set autoPush=Running
   call :pyTivo
   call :TaskScheduler
   call :AutoPush
   echo.
   goto :eof
   
::====================================
:Resume

   echo pushCast - Resuming...
   echo ======================
   echo.
   set pyTivo=Stopped
   set TaskScheduler=Stopped
   set autoPush=Stopped
   call :pyTivo
   call :TaskScheduler
   call :AutoPush
   echo.
   goto :eof

::====================================
```


----------



## Anotherpyr (May 6, 2015)

3rd party may not be so bad if it's available on PyPI. https://pypi.python.org/pypi

The only issue I ran into was when pip install downloaded a newer version of a package we used to execute Python code from Java and we didn't update our code to use the newer jar file it installed.


----------



## markp99 (Mar 21, 2002)

v0.5.1 update is inserted above - fixes a bug on pyTivo toggle during Auto mode (-a).

edit:.
v0.5.2 update is inserted above - fixes a bug on Auto Push toggle during Auto mode (-a).


----------



## markp99 (Mar 21, 2002)

Related - You can easily add your YouTube subscriptions to gPodder and PUSH them to your TiVo via pushCast!

http://www.tivocommunity.com/tivo-vb/showthread.php?t=530192


----------



## Anotherpyr (May 6, 2015)

I had some time and wanted to get video podcasts back on my TiVo, so I thought I'd take a stab at getting this working on a Mac mini. I started with gPodder to get podcasts outside of iTunes. The default directory for the podcasts turns out to be:

~/Library/Application Support/gPodder/Downloads

You'll need to know that for pyTiVo configuration and the gPodder wiki seemed to imply it would be in ~/gPodder/Downloads

Currently working on getting pyTiVo setup. I've got Plex serving them up right now. More to come as I get time to play with this.

<pet peeve><rant>When choosing a compression algorithm, one should choose the one native to the platform, not the latest, greatest, gee whiz algorithm like 7zip. I'm looking at you ffmpeg.</rant></pet peeve>

Since pyTiVo needs ffmpeg, you'll need to get an app off the App Store that supports the 7zip compression algorithm. I pulled ffmpeg off of the ffmpeg site and not the ffmpeg Mac site since it was an older version. That may have been my first mistake.

After resolving the 7zip issue (where zip would've been the better cross platform, supported solution), I have pyTiVo working. Pretty much following the README to create and edit the config using the supplied sample one. On to pyTiVo-auto-push. I'd probably be done by now, but I had to run some errands.

After resolving the missing Java issue, I have pytivo-auto-push working. I recommend downloading the JDK instead of just the JRE. I couldn't find the Java command after installing the JRE and it seemed more bent on installing Java in Safari than actually providing a working Java environment. Next step is to tackle porting the windows bat file to a shell script.

And then making it available. I probably won't get to it this weekend, but at least the parts are in place to start.


----------



## Anotherpyr (May 6, 2015)

Just a quick status update. I have command line gPodder working on the Mac. The way gPodder gets packaged for the Mac results in a gpo command that doesn't work or at least can't be called directly. It mostly boils down to creating a shell script to setup the environment for running gpo so it can find Python and its dependencies.

I'm currently looking at the metadata creation. I ran a test last night and pushed content to the TiVo using the default.txt approach. Acceptable, but not what we had. The rss and atom feeds should have the information needed to produce decent metadata files. Now just to figure out where gPodder stores the information, and automate extraction and metadata file extraction.

I can't help but think how cool it would be if we could just integrate the TiVo push into gPodder.


----------



## markp99 (Mar 21, 2002)

Anotherpyr said:


> JThe rss and atom feeds should have the information needed to produce decent metadata files. Now just to figure out where gPodder stores the information, and automate extraction and metadata file extraction.


Thanks! I too poked around to find the gPodder metadata - you can see it in the app - but gave up. I simply use the Feed Title for metadata, organized into pre-defined folders (based on title) in pushCast. For me, program descriptions are not too critical for these podcasts. I simply to binge thru these on a folder-by-folder basis.


----------



## Anotherpyr (May 6, 2015)

markp99 said:


> Thanks! I too poked around to find the gPodder metadata - you can see it in the app - but gave up. I simply use the Feed Title for metadata, organized into pre-defined folders (based on title) in pushCast. For me, program descriptions are not too critical for these podcasts. I simply to binge thru these on a folder-by-folder basis.


It's stored in an sqlite3 database. The file name is Database no less. Two tables, one for the podcast and another for the episodes.


----------



## Anotherpyr (May 6, 2015)

I think I have metadata generation from the gPodder database working. I need to do some more testing before I post it first. I was tired last night when I was putting it all together and missed that pytivo wanted .txt added to the file name instead of replacing the extension with .txt (which I had assumed) so it failed to work on the transfer last night. Some choices I'm not happy with, but appear to work:

Series ID: I simply add the podcast id from the podcast table to the string 'PC'
It works in that it generates unique ids for each podcast, but isn't globally unique

Episode ID: Sadly season and episode information is not in the database. For some it can be extracted from the url which is in the database, but I doubt this is consistent amongst the various sources. I'm toying with using the row id from the episode table. It is increasing, but I'm not sure how the TiVo will react to that.


----------



## markp99 (Mar 21, 2002)

Anotherpyr said:


> Episode ID: Sadly season and episode information is not in the database.


For me, Season info has little bearing for podcasts I catch. Just lumping into a few select folders is working very well for the typical 4-6 minute episode.

I have recently added a new layer of filtering to BLOCK some podcast from reaching my TiVo. Some of the podcasts I grab via gPodder are inclusive of many titles, some of which I just do not enjoy. So, gPodder will still grab them, but I delete the file during the metadata creation step, just before Auto_Push.

Example:

I like many in the TechCrunch collection of podcasts, but simply cannot stand the host of "Crunch Report", so pushCast promptly kills the file for me.


----------



## Anotherpyr (May 6, 2015)

It's looking like the metadata generation is working. It may not need an episode id, but I'm using the row id for now.

One thing I've noticed is that descriptions are getting truncated. I suspect it has something to do with embedded new lines.

Filtering sounds like a good idea.

Make that filtering is mandatory. At least the description text needs to be filtered. Removing the embedded new lines solved the first part of the title getting truncated issue. The second part is the descriptions are just too long for some podcast episodes and contain a lot of URLs. TekThing's descriptions are good example of too much. Any idea on the maximum numbers TiVo allows for the description?


----------



## markp99 (Mar 21, 2002)

I migrated to Windows 10 this week on a new machine.

Windows Task Scheduler is handling permissions slightly differently than Win7. I am getting an "Access Denied" message when pushCast is launched by Task Scheduler. I run pushCast silently in this mode, so I did not see any messages until I went digging.

I'll need to do some poking around. In the meantime, I can still run manually. In Auto, Win10 does seem to require one extra manual click at: "Do you want let this app to make changes...", not seen under Win7.


----------



## Anotherpyr (May 6, 2015)

Made some more progress tonight. Mostly been working on getting the metadata kinks worked out. I'm generating a list of files for which metadata didn't exist to use for pushing.

What's left?

Starting and stopping pytivo
Sending the commands to pytivo for pushing each file in the list
Merging with the pushcast menu code

The how is mostly worked out, it's just coding and testing at this point. It doesn't look like I'll have much time this weekend to work on it.


----------



## markp99 (Mar 21, 2002)

Sounds like great progress. In my current version, the windows task scheduler piece is not working as expected. I'm not sure what changed, but I ok running on demand until I find time or motivation to fix it.


----------



## Anotherpyr (May 6, 2015)

I can start pytivo, and I've eliminated the need for auto push as I can send the commands directly to pytivo. I'm currently working on parsing the output of pytivo to determine when the file as been downloaded to the TiVo. I was thinking of removing the file and its metadata file upon successful completion.

The more I mess with it the more things I think of doing. Personally I'm happy to just have it auto push for me and not have a menu.


----------



## markp99 (Mar 21, 2002)

Anotherpyr said:


> I can start pytivo, and I've eliminated the need for auto push as I can send the commands directly to pytivo. I'm currently working on parsing the output of pytivo to determine when the file as been downloaded to the TiVo. I was thinking of removing the file and its metadata file upon successful completion.
> 
> The more I mess with it the more things I think of doing. Personally I'm happy to just have it auto push for me and not have a menu.


Nice!

When a media file appears via magical means into the folder structure, autopush will discover and push it. Not all my content arrives from gPodder. I do need to adjust pushCast to allow me to tag these new files with .metadata prior to the push. I do drop them into a "\torrent" directory upon completion of the download, pause autopush, tag manually, & restart autopush. Can be better than that for sure.

Using Windows scheduler, I run pushCast automatically and silently every 2 hours, passing in "-a" and "-s" command line switches. No menus.


----------



## Anotherpyr (May 6, 2015)

Sadly auto push is really more than is needed to do the job. You just need to issue http get commands to pytivo. It gives you more control over the upload.

Looking through the pytivo forum I started thinking it might make sense to just modify pytivo to upload anything dropped in an upload directory. This lead me to thinking that a staging process would be best.

1) download and create meta files.
2) move download and meta file to upload directory
3) modified pytivo uploads file and moves file to processed directory upon completion
4) cron job or Windows scheduler removes files from the processed directory after 1 week

The reason for 1 week delay is to give you time to detect and resolve possible upload issues.


----------



## markp99 (Mar 21, 2002)

I do like the log file produced by auto_push. If I notice a file was not properly tagged or not successfully pushed, I can revisit on my PC, correct whatever he issue was, remove the entry from the auto_push log file - and the file(s) will be auto_pushed once more.

Yes, I can manually re-push from pyTivo (or re-pull from TiVo), but I do prefer the mostly hands-off aspect of this approach. 

I'll be curious to see your implementation. Running simply via cron job/task scheduler works well, until you have an exception.


----------



## Zaphod (Feb 18, 2003)

Anotherpyr said:


> I think I have metadata generation from the gPodder database working. I need to do some more testing before I post it first. I was tired last night when I was putting it all together and missed that pytivo wanted .txt added to the file name instead of replacing the extension with .txt (which I had assumed) so it failed to work on the transfer last night. Some choices I'm not happy with, but appear to work:
> 
> Series ID: I simply add the podcast id from the podcast table to the string 'PC'
> It works in that it generates unique ids for each podcast, but isn't globally unique
> ...


I have this auto-push of my podcasts working at a basic level by just having pyTivo Auto Push monitor the folder that gPodder downloads to. Each podcast downloads to a separate directory. I created a very basic default.txt metadata file in each podcast's directory setting title and seriesTitle to the podcast's main title, so at least they get grouped together in a folder for each podcast on the Tivo. The main down-side, I don't have actual individual episode titles. Every episode just reflects the main podcast title.

Side note, I DID find that the Tivo will group based on the title/seriesTitle even without having a series ID in the default.txt. (I just set both title and seriesTitle to the same thing in the default.txt, based on the examples I saw on the pyTivo web page. I haven't tested having only one or the other.)

So, Anotherpyr, I'm interested in your effort to be able to pull episode information from the gpodder database and create a metadata file with that information? What all information are you able to get? Really the only information I need is episode title, and episode description. But if there's other useful information in podcast feed, I'd be interested to know what it is.

What form is your tool/program to pull the info from the gpodder database in? I think you were were working on a Mac? Is it Mac specific, or is it in Java or Python or something that is cross-platform? Is it something you can share here? (Even if it's not cross-platform, you can share the code, someone, maybe me, might be able to convert it to something that will work on Windows. Though for me to do it would also be limited to either a .bat file, or a .vbs script.)

Thank you!


----------



## Zaphod (Feb 18, 2003)

Okay, I figured out reading the gPodder database for metadata, on a Windows PC. It works gloriously! My podcasts now show up on my Tivo with all the nice episode title and description info just like they did when Tivo downloaded them on the back end. More on that my next post. (I'll post that info in a separate post after this post, because I don't want this post to get too long or confusing between the two topics.)

But, first I want to say...

If you do want episode specific metadata for your podcasts, particularly now that we have reading the gPodder database for true title and description, then you need pushCast, or something like it. You can't keep auto-push running all the time, as described below, because you have to intervene to generate the metadata files before letting them be pushed to the Tivo.

HOWEVER, not to take anything away from the work that markp99 and Anotherpyr have done, pushCast is definitely useful for metadata and I'll use it for that reason (especially now that I can pull actual title and description metadata)...

but if you DON'T care about having nice episode specific metadata, don't bother with this whole thing in my opinion. There is a MUCH easier setup if you don't care about metadata. You can still group your podcasts into folders on the Tivo for each podcast, but every "episode" of the podcast will just show up with the same name as the overall podcast title name. Here's how to set that up...


Just let gPodder (or your favorite RSS aggregator) run all the time. Configure it to check for new updates however often you want it, and to automatically start up on Windows startup.
* I will say, gPodder isn't the most friendly in this regard. It needs a "minimize to system tray", or "install as service" option. As it is now, you have the icon for gPodder in your main task bar all the time (again, this is on a Windows PC). I used to use FeedDemon with FeedStation and they had a nice "minimize to system tray" option. But since I personally am going to use pushCast for the metadata piece, I'm sticking with gPodder because it has the command line interface to control it.​

Add a default.txt metadata file in the subdirectory of each podcast. For example, here is my default.txt metadata file for the CNET Update (HD) podcast:
seriesId : CHCNETUPDATE
title : CNET Update (HD)
seriesTitle : CNET Update (HD)
isEpisode : true
isEpisodic : true
time : File
callsign : CNET
showingBits : 4096

(Note, seriesId can literally be anything for pushes. Just make something up. It just has to be consistent across all the content you want grouped in the same folder on the Tivo.)​

Install pyTivo as a service with automatic startup. Configure pyTivo with a share just pointing to your top level directory under which all of your podcasts are stored.


Configure auto-push for pyTivo to auto-push from your podcast pyTivo share to your desired Tivo. Then, also install auto-push as a service with automatic startup. And you can close the GUI of auto-push.

That's it. Now, all 3 of your RSS program, pyTivo, and auto-push for pyTivo are just always running. Your RSS reader will just automatically download things as new episodes come up, and auto-push for pyTivo just monitors the RSS download directory directly and will automatically push to your Tivo when the RSS aggregator downloads them.


----------



## Zaphod (Feb 18, 2003)

Okay, and now on to my experiments with pulling metadata from the gPodder database. As Anyotherpyr mentioned, it's a sqlite 3 database. I found the sqllite3.exe command line shell tool. I was able to write a one line command line query using the sqlite3.exe (thus easily callable from a .bat file) that queries the gPodder database and redirects the output to a metadata .txt file. 2 calls like this is all it takes, one for title and one for description. Code is below.

First, I don't have any MAC experience so this is all for Windows PCs. It does appear that there's a sqlite shell for Mac too (even linux) that you could incorporate in a similar fashion.

Get the sqlite shell executable from https://www.sqlite.org/download.html. You want to download the "sqlite-shell-..." item for your appropriate operating system. It doesn't need to be "installed", at least on Windows, it's just a standalone .exe file that you can place anywhere that's convenient for you. For Windows, you DON'T need the "sqlite-dll-..." items, or at least I didn't.

One other difference that I do from markp99's pushCast.bat file. The metadata .txt file that pushCast.bat creates for every video file contains ALL of the metadata. Instead, I manually created a default.txt metadata file with the stuff that would be common for every episode within the same podcast and put one in each podcast's directory on the PC. For example, this is my default.txt file for my CNET Update (HD) podcast:

seriesId : CHCNETUPDATE
title : CNET Update (HD)
seriesTitle : CNET Update (HD)
isEpisode : true
isEpisodic : true
time : File
callsign : CNET
showingBits : 4096​
(Note, seriesId can literally be anything for podcast pushes. Just make something up. It just has to be consistent across all the content you want grouped in the same folder on the Tivo.)

Then each individual episode metadata file contains only 2 lines, episodeTitle and description.

Also, I prefer to have all of my podcasts as separate folders on my Tivo (CNET Update, CNET Top 5, etc.). However, markp99 said he prefers to group all of his CNET podcasts in one folder on the Tivo. That's fine. If you want to group different podcasts into the same folder on Tivo, you'll still have a separate default.txt file in each different podcast's download directory, but inside the default.txt make sure they all have the same information for the different podcasts you want grouped. I.e., each separate podcast you wanted grouped in the same folder on Tivo just has a copy of the same default.txt file in it's download directory on the PC. Using this method, pushCast.bat shouldn't need any code in it at all for combining separate podcasts into one Tivo folder. It just happens automatically from the default.txt files.

So here's the Windows .bat file code I wrote to read the gPodder database, extract episode title and description info, and write the episode specific metadata files.

This assumes you have all of your podcasts contained in one single top level directory, and then in further subdirectories under that top level directory if you want. (This is how gPodder sets things up by default anyway.) In my case, my top level directory is R:\VideosPodcasts\Downloads, then each podcast is in a subdirectory under that; "R:\VideosPodcasts\Downloads\CNET Update (HD)", "R:\VideosPodcasts\Downloads\CNET Top 5 (HD)", etc. In comparing to pushCast.bat, I think my R:\VideosPodcasts\Downloads directory would be the equivalent of markp99's c:\users\mark\downloads\media directory.

It also has a flag in it (set metaFolder) to tell it if you want to use the .meta subdirectory or not. Just change it to false if you don't want to use the .meta subdirectory.

*EDIT:* Updated version includes code to clean up old metadata files for old podcast media files that no longer exist. (I just let gPodder purge the old files after a while.)

```
@echo off

REM EnableDelayedExpansion, and the EndLocal at the end of the script, is required
REM because of trying to set the metaFileName variable in the middle of the For loop.
SetLocal EnableDelayedExpansion

set podcastPath="R:\VideosPodcasts\gPodder Downloads"
set sqlite3exe="D:\APPS\gPodder\Data\sqlite3.exe"
set gPodderDBPath="D:\APPS\gPodder\Data\Database"

REM Set the following metaFolder line to true if you want your metadata .txt files in a .meta subfolder.
REM Set the following metaFolder line to false if you DON'T want your metadata .txt files in a .meta subfolder.
REM true and false are case sensitive, must be all lower case
set metaFolder=true

REM Generate metadata files for new downloads
for /R %podcastPath% %%f in (*.*) do (
	REM skip existing metadata .txt files, or folder.jpg files created by the RSS aggregator
	If not %%~xf==.txt if not %%~xf==.jpg (
	
		set metaFileName=%%~dpf%%~nxf.txt
		if %metaFolder%==true set metaFileName=%%~dpf.meta\%%~nxf.txt
		
		REM Note the use of ! instead of % for metaFileName.  This is required for the Delayed Expansion.
		If not exist !metaFileName! (
			if %metaFolder%==true if not exist "%%~dpf.meta" md "%%~dpf.meta"

			%sqlite3exe% %gPodderDBPath% "select 'episodeTitle : ' || title from episode where download_filename = '%%~nxf';">!metaFileName!
			%sqlite3exe% %gPodderDBPath% "select 'description : ' || description from episode where download_filename = '%%~nxf';">>!metaFileName!
		)
	)
)

REM Clean up metadata files from old purged downloads
for /R %podcastPath% %%f in (*.txt) do (
	REM skip pyTivo "default.txt" metadata files
	If not %%~nf==default if not %%~nxf==auto_push.txt (
	
		set mediaFileName=%%~dpf%%~nf
		if %metaFolder%==true set mediaFileName=%%~dpf..\%%~nf
		
		REM Note the use of ! instead of % for metaFileName.  This is required for the Delayed Expansion.
		If not exist !mediaFileName! (
			del "%%f"
		)
	)
)

set mediaFileName=
set metaFileName=
set metaFolder=
set gPodderDBPath=
set sqlite3exe=
set podcastPath=
EndLocal
```
Two other little comments that are just my own opinion.

I would just install pyTivo (the base pyTivo, in addition to auto-push) as a service with automatic startup and let it run all the time. It doesn't hurt anything. pyTivo by itself never automatically pushes anything. It's only the "auto-push" piece you have to control the starting and stopping of. Then the pushCast.bat file doesn't have to do anything with pyTivo itself. (I guess you could still check for it if it's not running and start the service as a safeguard. But I wouldn't provide controls in the pushCast script to control starting and stopping pyTivo manually. Except of course, that funcion is already there so, I guess, why remove it.)

Anotherpyr suggested not using auto-push at all and just issuing the commands directly to pyTivo. He has a point. I did test using curl.exe to issue the push commands directly to pyTivo without using auto-push and it works. However, then you have to program your own tracking of which files have already been pushed to the Tivo or not, so you don't re-push ones that have already been pushed. Why go through that much work when auto-push already does that for you?


----------



## markp99 (Mar 21, 2002)

Hey Zaphod,

Thanks for taking this effort a bit further. pushCast is still running here everyday! I am adding new podcasts (and removing old ones) as I find them or as my taste changes.

The only issues I've seen recently:

1. Some podcast do not get .meta created properly * (or in time for auto-push) * and get pushed onto my TiVo without a containing folder. For me, if it's not a named podcast it goes into a "Misc Podcasts" folder by default. This does not happen all the time. I am not seeing a pattern. I have not spent any time tracking it down. Podcast are mostly disposable for me so they get watched or simply deleted pretty quickly. Just a minor annoyance for now.

2. Occasionally, a podcast filename will contain a troublsome character (', #, @, &, etc.). I am trapping these as I bump into them one-by-one, but there is most surely a better way. This one is pretty quick. Occasionally I'll have >100 podcasts to process, no real lag in this method.


```
rem Remove "&" characters:
for /R "c:\Media\Downloads" %%a in ("*&*") do (
   set "fileName=%%~NXa"
   ren "%%a" "!filename:&=!"
)
```
3. I get a "duplicate filename found" error frequently during metadata creation - though I don't actually see duplicates. I have not troubleshooted at all. This may be partly the cause of my missing .meta data.

You are right, I almost never toggle pyTiVo directly via the interface. But I do like that the interface does indicate which tools are [Running] or [Stopped]. That's good info.

AUto-Push is sometimes *too quick* to see new titles and needs to be paused if I am moving in media files from other source (like torrents). I like having the option: Stop auto-push > move files > create metadata > restart auto-push > profit. 

I'll poke around the sqlite stiff when time permits. I have a new client project starting this week that will probably be consuming my time.


----------



## Zaphod (Feb 18, 2003)

markp99, I have a question about how you call the gPodder command line in your pushCast.bat.

When you call gPodder command line, you use these two commands:

call gpo update 2>nul
call gpo download 2>nul​
I do understand what the >nul part does (suppressed output from displaying on the screen).

I DON'T understand what the "2" does in each of these. In looking at the gpo help, the only parameter on update and download is that you can specify the URL of a specific podcast to update or download, or leave the parameter off to update or download all podcasts. So based on that, adding the "2" parameter would essentially be a URL that I'm guessing doesn't really exist, and therefore gpo doesn't do anything at all, attempting to update/download the specific "URL" of "2", which it won't find so it won't do anything.

I'm sure that's not what's happening or you'd be having issues, but can you please explain the 2? And where you found the information that told you to use the "2", because I can't find anything anywhere on the gPodder command line that give me any indication that you can use a number there.

Thanks much!


----------



## moyekj (Jan 24, 2006)

A > without the 2 means redirect STDOUT to a file. The 2> means redirect STDERR to a file, in this case nul which means basically suppress all error messages.


----------



## Zaphod (Feb 18, 2003)

moyekj, thanks for the clarification on the "2>nul" thing.

Okay, here is my extremely stripped down version of pushCast.bat. No fancy features like markp99's version, but performs the core functions.

Install both pyTivo and auto_push for pyTivo as services, with automatic startup.

The CreateEpisodeMetaDataFromGPodderDB.bat that I call from this .bat is the .bat file I posted the code for earlier to create the metadata files by reading the gPodder database. This .bat file also cleans up old metadata .txt file from old podcast media files that no longer exist.

I just let gPodder automatically purge old podcast media files after 30 days. (Set this to whatever you want in the gPodder config.)

I don't bother with having this .bat file reschedule itself in Task Scheduler. I just manually built a task in Task Scheduler to run this .bat file on system startup (with a 15 minute delay to ensure the pyTivo and auto_push services are up an running), and then repeat every 2 hours (or however often you want). Also make sure you set the task to run with Highest Privileges (requires administrator rights to stop and restart the auto_push service).


```
@echo off

REM Stop pyTivo auto_push service
call "D:\APPS\pyTivo_Auto_Push\service\win32\stop-service.bat"

REM Update Feeds in gPodder
call "D:\APPS\gPodder\gpo.exe" update 2>nul

REM Download any new episodes in gPodder
call "D:\APPS\gPodder\gpo.exe" download 2>nul

REM Generate Metadata for any new downloads
call "R:\VideosPodcasts\CreateEpisodeMetaDataFromGPodderDB.bat"

REM Start pyTivo auto_push service
call "D:\APPS\pyTivo_Auto_Push\service\win32\start-service.bat"

exit
```


----------



## markp99 (Mar 21, 2002)

Nice. I suppose you could use another batch to just PAUSE the auto-push service to permit you to generate Meta data before auto-push becomes aware of new content copied in from non gPodder sources.

"stop-service.bat"

I hope to play with gPodder meta data this weekend.


----------



## Zaphod (Feb 18, 2003)

markp99 said:


> Nice. I suppose you could use another batch to just PAUSE the auto-push service to permit you to generate Meta data before auto-push becomes aware of new content copied in from non gPodder sources.
> 
> "stop-service.bat"
> 
> I hope to play with gPodder meta data this weekend.


I'm not quite sure what you mean. I use the same method you did for handling auto_push (I think so anyway). I leave the auto_push service running most of the time. When the task triggers to run the .bat file, the .bat file stops the auto_push service, runs the gPodder command line to update and download new episodes, runs my other .bat file for generating metadata, then restarts the auto_push service to push any new files to the Tivo.

So auto_push is stopped already when downloading new episodes and doesn't get started again until after the metadata is generated.

(Side note, I did just edit my previous post too, to add the part about scheduling the main pushCast.bat file in Task Manager.)

*Edit: Sorry, never mind.*
I just reread your post and now see the "from non gPodder sources" piece. Yeah, I see what you mean. The trick would be how to know there's new media files there before auto_push finds them.

One way would be to use two different directories. Your media is initially downloaded into its own folder that is NOT monitored by auto_push. Every couple of hours you iterate through that directory and build the metadata for any new files (if any), then move the new media files and metadata files to the folder that auto_push actually does monitor. If you keep them in two separate subdirectories on the same hard drive, then the "move" would happen very quickly (just has to rewrite directory entries, not actually copy file contents).

You could actually use the same method FOR podcasts too, using gPodder or any RSS aggregator. gPodder downloads to one location. You move the files with metadata file to another location after generating the metadata.

Then you could just leave auto_push AND gPodder (the GUI, or whatever other RSS aggregator you want) ALWAYS running, and essentially the new pushCast.bat file just becomes purely the metadata generator, and moving the files to the auto_push location. Still schedule the pushCast.bat to run every few hours in Task Scheduler, but it's a greatly simplified .bat file.

Side note, I did also figure out how to read the episode metadata out of FeedDemon's database, which also uses SQLite 3. Exact same method as for gPodder, just a different query text in the sqlite3.exe statements.

Can anyone think of any reason moving the files from one directory to another like would have any down sides?


----------



## markp99 (Mar 21, 2002)

No downside, IMO.

I do download torrents into a temp folder, then have uTorrent move them to a new destination folder (resides within the pushCast structure) upon completion. This way, auto-push does not attempt to move the files before the torrent is fully complete. uTorrent also knows the new location, so seeding can continue without issue.

Further, I use another tool to collect YouTube videos one-by-one, or a full channel at a time as I may bump into them while browsing - nice drag and drop interface. I drop YouTube videos into a staging folder.

https://www.4kdownload.com/products/product-videodownloader

Once the dls are complete, I stop auto-push > move the files > create meta data > start auto-push.

Thinking - meta data creation could happen in the staging folders just as easily, then moved over without touching the auto-push service.


----------



## Zaphod (Feb 18, 2003)

markp99 said:


> Thinking - meta data creation could happen in the staging folders just as easily, then moved over without touching the auto-push service.


Exactly.

The hard part would be for something like uTorrent, you couldn't let uTorrent move the files after download itself. The script (.bat file, whatever) that generates the metadata would need to move the files after generating the metadata.

Edit:
Or have 3 directories involved. 1) The temporary uTorrent download directory, 2) the uTorrent completed directory, this is where your metadata script picks up from, 3) the final auto-push directory, the metadata script moves the files to here after it generates the metadata.


----------

