Jump to content

Using a simple CLI alias to update the EPG (also for automation)


vdrover

Recommended Posts

vdrover

When modifying an Live TV channel lineup, it can be a bit cumbersome to update your electronic program guide or EPG. For example, if you are using an EPG editor, and you are hosting your own EPG files locally, the workflow might look like this:

  1. Update channels in EPG editor.
  2. Update the EPG files on your Emby server.
  3. Update your EPG in the Live TV or Scheduled Tasks area.

If you have multiple EPGs, step 2 alone can be tedious.

One way to simplify this process is to use a command line alias to merge multiple commands into one action. 

Before we start, let me jump a little bit ahead to show you how to create a command to run the scheduled EPG update task from the command line (step 3 above).

Launch the scheduled EPG update task from the command line

  1. Visit the Emby backend and select `API` from the left menu.
  2. Create an API key and save it for later. 
  3. Using the API key, list the IDs of all the scheduled tasks by entering the following command in your BROWSER: `http://your-emby-IP-address:8096/emby/ScheduledTasks?api_key=<your-API-Key>`
  4. Use your browsers search function to locate the following string: `RefreshGuide","Id":`. Note the task ID that immediately follows this string, such as `9492hsys60f7f17c9d0a4feb27`. 
  5. Using the API key and the task ID, create a URL that will launch the 'Refresh Guide` task: `http://your-emby-IP-address:8096/emby/ScheduledTasks/Running/taskID?api_key=<your-API-Key>`

Collect all your commands

OK, now that we have the refresh guide command ready, here are some sample commands one might decide to combine into a single, easy-to remember alias:

  1. Download EPG 1 via command line: `wget -q https://your-epg.host/your-epg-data-1.xml -O $HOME/your-epg-data-1.xml`
  2. Download EPG 2 via command line: `wget -q https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml`
  3. Download EPG 3 via command line: `wget -q https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml`
  4. Update the EPG via command line instead of the emby backend: `curl -s -d GET http://your-emby-IP-address:8096/emby/ScheduledTasks/Running/taskID?api_key=<your-API-Key>`

Combine commands

You can use the logical AND operator `&&` to combine all 4 commands into one line:

wget -q https://your-epg.host/your-epg-data-1.xml -O $HOME/your-epg-data-1.xml && wget -q  https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml && https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml && curl -s -d GET http://your-emby-IP-address:8096/emby/ScheduledTasks/Running/taskID?api_key=<your-API-Key>

Be sure to test that this works as expected from the CLI (remove the `-q` and `-s` flags to see the normal command output for example).

Create alias

Finally, create an alias using `nano ~/.bash_aliases` and enter the following:

alias epg-updates='wget -q https://your-epg.host/your-epg-data-1.xml -O $HOME/your-epg-data-1.xml && wget -q  https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml && https://your-epg.host/your-epg-data-2.xml -O $HOME/your-epg-data-2.xml && curl -s -d GET http://your-emby-IP-address:8096/emby/ScheduledTasks/Running/taskID?api_key=<your-API-Key>'

Once you've saved the file and exited nano, you need to run `source ~/.bash_aliases` for the new alias to be useable.

Use the alias

Simply type `epg-updates` from the CLI to update your local EPG files and the guide data in Emby.

Automating

If you prefer to automate this, simply use the commands above in a bash script, and schedule the script to run via crontask.

I thought the process above might help folks who are not as familiar with using the developer tools in a browser as is often suggested in the Emby community.

Edited by vdrover
Link to comment
Share on other sites

  • 3 months later...
joekingcool

@vdrover @Luke

 

On 8/23/2023 at 4:33 PM, vdrover said:

great work, unfortunately i'm still not able to get it to work.

i just need refresh guide cmd, because im creating a script that deletes timers.json and exports a list of movies to re add. series timers is usually fine but needs guide refresh to populate timers.json from series.json. 

im using windows and dont need to download the 3 guides. just need to trigger refresh guide. was hoping the curl cmd would work. i can use the curl cmd for shutdown restart. it would be nice if they had a list of curl cmds for emby since emby don't have a built-in cmd line that i could find. 

Edited by joekingcool
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...