Frndly TV with Python on Windows without Docker: the easy way

You're almost there. It looks like for the IP address of your Channels DVR server, you typed 10.0.0.108:8089 but the batch script expected only the IP address without the port number, which is assumed to be 8089 by default.

You have two choices at this point:

  1. Delete your sources and rerun the second script with only the IP address without the port number (10.0.0.108)
  2. Edit your current sources and remove the extra :8089 in all URLs

The first window? That shouldn't be the case, it should not close by itself.

I'll edit the payloal.json .

The second try didn't.

1 Like

Given the fact that poor @RyzenBeast is having trouble with it, I guess I didn't make it that easy after all. :laughing:

I really threw this together quickly and made some assumptions. My bad. Sorry, @RyzenBeast.

I will make some improvements and let you know when that's ready.

I have uploaded new versions of the Batch scripts to my Google Drive.

I think they are more user friendly now. :crossed_fingers:

It's fine to rerun them if they were already run before.

Success! THANK YOU!

Since I just dropped Spectrum due to their ridiculous price increase after coming off a 2-year promo, I'm dabbling here. The YTTV and Frndly TV combo seems to be the ticket but I'm looking at Hulu too because for a couple bucks more it's all in one app. Apparently Hulu TVE in Channels DVR is broken at the moment but I know this happens with YTTV from time to time as well.

That said, Is there a way to automate running the *.bat files at startup in the case of a system reboot?

Sure, here are the steps to run a batch file at startup in Windows:

  1. Create a Batch file: Write your commands in a text file and save it with a .bat extension¹.
  2. Create a Shortcut: Right-click on the batch file and select Create shortcut⁴.
  3. Open Startup Folder: Press the Win + R keyboard shortcut to launch the Run dialog. Type shell:startup and press Enter to open the Startup folder for the current user⁶. If you want the batch file to run for all users, type shell:common startup instead⁶.
  4. Paste the Shortcut: Once the Startup folder has been opened, paste the shortcut into the folder⁸.

Now, every time you start your computer, the batch file will run automatically. Please note that you might need administrative privileges to perform these steps⁵.

Source: Conversation with Copilot, 6/11/2024
(1) How to Create a Batch (.bat) File in Windows. https://www.youtube.com/watch?v=sODXtX7jdcI.
(2) How to make a .bat file autorun on pc startup - Stack Overflow. cmd - How to make a .bat file autorun on pc startup - Stack Overflow.
(3) Run Batch File (.BAT) on Startup in Windows - ShellHacks. how to run a batch file at startup in Windows - Search.
(4) How to create batch script files on Windows 11. How to create batch script files on Windows 11 | Windows Central.
(5) how do i autostart batch file on windows startup - Stack Overflow. cmd - how do i autostart batch file on windows startup - Stack Overflow.
(6) How to Run Batch File as Administrator Without Prompt in Windows 10. https://www.youtube.com/watch?v=BH8N2eVHvUY.
(7) How to Create a Batch (.bat) File in Windows 11 [Solution]. https://www.youtube.com/watch?v=8fnVlKyjmGI.
(8) How To Run Batch File On Windows Startup - StackHowTo. https://stackhowto.com/how-to-run-batch-file-on-windows-startup/.
(9) undefined. How to Run a Batch File Each Time the Computer Loads Windows.

For the first step, create your own Batch file that you can call run_frndly_tv_on_startup.bat with the following content:

REM Full path where the code from Github was downloaded
cd C:\Users\<user>\<...>\frndlytv-for-channels

REM Replace %FRNDLY_EMAIL% and %FRNDLY_PASSWORD% with their real values
python app.py --PORT 8183 --USERNAME "%FRNDLY_EMAIL%" --PASSWORD "%FRNDLY_PASSWORD%"

I'll check into this and report back later but I think I can test without doing a reboot by closing the cmd window and then running the batch file I create per the instructions above manually.

Good Lord, this reminds me of editing my autoexec.bat and config.sys files back in the DOS days to get things started up and configured!

1 Like

As luck would have it my PC decided to reboot last night and I hadn't yet done this task.

I wrote (copy / paste / fill in the blanks) the batch file this morning and gave it a spin by manually triggering the *.bat file shortcut from the startup directory with a double click and it loaded everything but in Channels DVR I had to manually load the m3u's from the sources screen. Is there a way to automate this procedure?

I know I'm a POA but others may enjoy having this information too!

Yes, it should be possible to automate the refresh of the sources.

I'm going to be busy for a few days.
I probably won't be able to get to it until the weekend.

1 Like

No rush! Thanks for all you've done this far! Much appreciated!

1 Like

Well, guess what? So did mine!
I guess we both got hit with an update.

That got me moving on this and here it is:

This is the content of the file. Notice on top of the file that you will need to modify the values to fit your setup.

@echo off

REM Modify the values between the quotation marks for your setup
set FRNDLY_EMAIL="[email protected]"
set FRNDLY_PASSWORD="password"
set DVR_IP="127.0.0.1"
set DVR_PORT="8089"
set DIRECTORY_WITH_PYTHON_CODE="C:\Users\mjitk\frndlytv-for-channels"

REM Only change the values after the '=' signs if your Frndly TV sources have different names
set "FRNDLY_SOURCE_WITH_EPG=Frndly TV (with EPG)"
set "FRNDLY_SOURCE_NO_EPG=Frndly TV (no EPG)"


REM !!! Do not change anything below this line !!!


REM Start the Python server for Frndly TV in a new window
cd %DIRECTORY_WITH_PYTHON_CODE%
start cmd /k python app.py --PORT 8183 --USERNAME "%FRNDLY_EMAIL%" --PASSWORD "%FRNDLY_PASSWORD%"

REM Wait 5 seconds
timeout /t 5

REM Check whether the Channels DVR server is running
curl http://%DVR_IP%:%DVR_PORT%/dvr | findstr  /I /C:"running"
set running=%ERRORLEVEL%

if %running% EQU 0 (
    REM The Channels DVR server is already running. 

    REM Reload the Frndly TV M3U sources on the server
    set "SOURCE_1=%FRNDLY_SOURCE_WITH_EPG: =%"
    set "SOURCE_2=%FRNDLY_SOURCE_NO_EPG: =%"
    curl -X POST "http://%DVR_IP%:%DVR_PORT%/providers/m3u/sources/%SOURCE_1%/refresh"
    curl -X POST "http://%DVR_IP%:%DVR_PORT%/providers/m3u/sources/%SOURCE_2%/refresh"
)
2 Likes

Note that if the Sources page was already open before this was run, you will probably have to refresh the browser tab to see the updates.

1 Like

I'll check it out as soon as I am done watching The Acolyte..

One thing I just realized: this will fail to reload the M3Us on the server if this runs at startup before the Channels DVR server is started. That will depend on how Windows does it, if it starts services before the Startup folder.

I will need to add some logic to wait for the Channels DVR server to be running before sending the commands to refresh the M3U sources.
I have an idea what to do but that won't be until tomorrow night, maybe.

Thank you for your work on this!

Maybe check for dvr running ...

example

:loop
curl http://127.0.0.1:8089/dvr | findstr  /I /C:"running"
set running=%ERRORLEVEL%
if %running% EQU 0 do this
if %running% NEQ 0 timeout /t 60
if %running% NEQ 0 goto loop
2 Likes

This is a great solution that will work whether the server is running locally or remotely (with the right DVR URL). Thanks for the piece of code! :+1:

I will implement it as soon as I get the chance. :slightly_smiling_face:

Where would I put this code/script in the code @mjitkop presented above? I can combine the two and five it a whirl if I knew where to put it so as to be in the correct order. I'm thinking up front?

OTOH, I don't think that code is specific enough in that it probably needs path names etc. so I'll wait.

It should be at the end like this:

REM Wait 5 seconds
timeout /t 5

REM Check whether the Channels DVR is running
curl http://%DVR_IP%:%DVR_PORT%/dvr | findstr  /I /C:"running"
set running=%ERRORLEVEL%

if %running% EQU 0 (
    REM The server is already running. 

    REM Reload the Frndly TV M3Us on the server
    set "SOURCE_1=%FRNDLY_SOURCE_WITH_EPG: =%"
    set "SOURCE_2=%FRNDLY_SOURCE_NO_EPG: =%"

    curl -X POST "http://%DVR_IP%:%DVR_PORT%/providers/m3u/sources/%SOURCE_1%/refresh"
    curl -X POST "http://%DVR_IP%:%DVR_PORT%/providers/m3u/sources/%SOURCE_2%/refresh"
)

I just typed this here.
I'm not at my computer right now to try it out. There might be syntax errors in this post.

Note that I've chosen not to have a loop because if the server is not running, there is nothing that needs to be done. Whenever the server starts, it will automatically load all sources and the Python server for Frndly TV will be running already.

In theory, it should work. :crossed_fingers:

1 Like

I don't have time to test at the present as I have to go to work but will later.