Jump to content

How to build the EMBY EPG using JS


VicMoore

Recommended Posts

VicMoore

I know how to read and display the EMBY (and VirtualTV) EPG using JavaScript.  What I don't know how to do, is to Create the EPG using the Emby ApiClient.  Can anyone give me a JS code segment that illustrates how to build the EPG?  I am trying to learn the ApiClient better.  I would like to know how to construct the EPG.

Vic

Link to comment
Share on other sites

VicMoore

No - I understand how to retrieve the data - I want to actually build a row in the EPG.  Then when I fetch the EPG I will see the row I added.

For example, in the ApiClient how are the two methods below used to build the Emby epg?

function modifyEpgRow(result) {

    result.Type = 'EpgChannel';
    result.ServerId = this.serverId();
}

function modifyEpgResponse(result) {

    result.Items.forEach(modifyEpgRow.bind(this));

    return result;
}

Vic

Edited by VicMoore
Link to comment
Share on other sites

It’s just a vertical list of channels with program cells that scroll horizontally. It’s more complex than a regular list but it is essentially just that.

Can you be more specific with your question?

Link to comment
Share on other sites

VicMoore

I understand what you are saying.  I am building a plugin that creates the illusion of a Cable Company.  IT has a very visual experience (like the Bulky plugin) for selecting channel content. Unlike VirtualTV, the user experience is not split between defining channels and then tagging Emby content to populate the respective channels. My intent is not to irritate the VirtualTV team. I am willing to give them my code when I am done. I don't even want credit. I get the joy of learning and building something useful that I will use every day.

I can visually select and automatically tag Emby content for each channel. I am using an altered version of Bulky (it's in the plugin library). Now I need to populate the Emby EPG with this data so users (me) can play the chosen content.

I have already built (in JS) a tool that can read the current Emby EPG and display its content in the same manner that the Emby Web client does.  I can select and play (via HLS) any show in the EPG (both Emby and IPTV content).   So, I don't need help in this area.  Where I need help is with building the Emby EPG one line (channel) at a time.  I am very good with the ApiClient and JS. What I need is direction on how to build the EPG, one line at a time.

I hope this helps,  I am not very good explaining things 🙂

Vic

Link to comment
Share on other sites

pünktchen

I guess what you want to ask is how to get your visually selected items into Emby's database? After that you will have to query the database for program items to fill your custom EPG.

Link to comment
Share on other sites

VicMoore

@pünktchenwhat I really want to do is to create a simple and pleasing way to build TV channels.  At the moment I use the Bulky plugin to tag channels. For example, I tag all of the content for channel 1 with the tag "Channel_1."  Then in virtual TV, I set up channel 1 to use content from channels tagged with "Channel_1".  With this tool, I can quickly and easily change the played status of media and add or remove specific tags as needed. So, it's easy for me to redefine channels as often as I like. My desire is to integrate the GUI of this tool with the channel building and EPG capability of virtualTV.  I want to build my own EPG, because I didn't want to bother anyone else with what I was doing. I also wanted to learn more about the internal API for the EPG.  More than anything else, my goal is to learn.

Take a look at the Bulky plugin and you will get a feel for how the GUI can be modified to visually build TV channels. I know the Bulky GUI will have to be disassembled and built into the GUI needed. This is not a problem.

I would be interested in your ideas and thoughts. 

Vic

p.s.  you are welcome to all of the code I create.  You are also welcome to the bulky code, if you want to implement ideas of your own.  I am not interested in credit. I would rather have you as a friend. If you have ideas that I can help you with, just let me know.

 

Edited by VicMoore
Link to comment
Share on other sites

VicMoore

One GUI possibility is that we could begin by displaying all of the EPG channels, which could be hundreds. Of these channels 30 could be selected and published to the EPG.

image.thumb.png.e1997154d26e55540ff8fd2f12fada82.png

A channel can also be clicked and edited.  Here Emby media can be associated with this channel, by surfing the Emby library, using code similar to Bulky.

image.png.ec186b68e4f80d3abb8beccc9973af1f.png

Tags are automatically added to the media selected for a channel.  These tags can also be removed  when content is deleted.

image.png.9c89d63c9179e8af592f1e0732099808.png

These are just ideas

Vic

 

 

  • Thanks 1
Link to comment
Share on other sites

BillOatman

My suggestion would be to build m3u and xmltv files and have Emby import them rather than trying to put the data right into the database. Easier and keeps any DB change by Emby from breaking your plugin.

Link to comment
Share on other sites

VicMoore

After considering @BillOatmanidea,  I don't know how to programmatically load the created M3U file into Emby from a plugin.  Does anyone know how to do this?

Vic

Link to comment
Share on other sites

BillOatman
1 hour ago, VicMoore said:

After considering @BillOatmanidea,  I don't know how to programmatically load the created M3U file into Emby from a plugin.  Does anyone know how to do this?

Vic

Yeah there is a scheduled task that you run.  I do that here

Link to comment
Share on other sites

VicMoore

WOW @BillOatmanyou have some great stuff.  My stuff is not so good.  I just finished my first plugin "Bulky."   It's in the Emby library.  

Bill, you are way ahead of me when it comes to plugins.  I looked at your code and learned many things. 

I think you refreshed the tv-guide by executing a scheduled task via the Emby API. Keep in mind that I am a novice compared to you. So, I may be wrong.

I know how to create the m3u file to create the EPG.  That's about all I know. Do I need to install a live tv host that links to my plugin, so the m3u can be fetched? 

Could you explain the process to me? I would be very grateful.

Vic

Link to comment
Share on other sites

BillOatman
1 hour ago, VicMoore said:

WOW @BillOatmanyou have some great stuff.  My stuff is not so good.  I just finished my first plugin "Bulky."   It's in the Emby library.  

Bill, you are way ahead of me when it comes to plugins.  I looked at your code and learned many things. 

I think you refreshed the tv-guide by executing a scheduled task via the Emby API. Keep in mind that I am a novice compared to you. So, I may be wrong.

I know how to create the m3u file to create the EPG.  That's about all I know. Do I need to install a live tv host that links to my plugin, so the m3u can be fetched? 

Could you explain the process to me? I would be very grateful.

Vic

Sure thing.  You would configure live tv as usual with m3u and epg files.  Your plugin would overwrite one or both of those files then kick off that scheduled task shown in my code referenced above.  I'm not sure off the top of my head if you can run a scheduled task directly from a plugin or not or if you need to make that REST call like in that code.  If it wasn't obvious, that code I referenced above is not a plugin, but a standalone program.

Maybe ITaskManager allows you to run scheduled tasks?  @Cheesegeezerdo you have any sample code to run scheduled tasks from a plugin?

Edited by BillOatman
Link to comment
Share on other sites

VicMoore

Thanks Bill -- yes the ApiClient can kick off a scheduled program. So, I create m3u and epg files and then configure Live Tv with their local file urls.  Then my app can overwrite these files and then trigger a scheduled app to cause Emby to ingest these files and populate the EPG.

I suspect there is a way to do this without creating any files. It might be possible to install a m3u tuner to do the same thing.  What do you think?

Vic

Link to comment
Share on other sites

VicMoore

Hello @Cheesegeezerdo you have any code concerning Emby Live TV - for example, can I add a tuner that is a plugin?  

Vic

Link to comment
Share on other sites

pünktchen
On 6/6/2023 at 8:24 PM, VicMoore said:

At the moment I use the Bulky plugin to tag channels.

How do you do this? I mean do you really select the wanted items one by one or do you use your filter functions? If the later, what filters are these that are missing in VirtualTV? I have the feeling what's really missing for you in my plugin is some kind of preview of the outcome.

Link to comment
Share on other sites

BillOatman
2 hours ago, VicMoore said:

Thanks Bill -- yes the ApiClient can kick off a scheduled program. So, I create m3u and epg files and then configure Live Tv with their local file urls.  Then my app can overwrite these files and then trigger a scheduled app to cause Emby to ingest these files and populate the EPG.

I suspect there is a way to do this without creating any files. It might be possible to install a m3u tuner to do the same thing.  What do you think?

Vic

M3U Tuner is what I was talking about.  

 

image.png.8184f575f6412d2397d16dfd60cfe1b5.png

Link to comment
Share on other sites

pünktchen

The export - import epg approach will not work, because VirtualTV wont know what database items are meant to be played by the program entries.

Link to comment
Share on other sites

VicMoore

Hello @pünktchenyes I do miss seeing the outcome.  To mitigate this, I populate my own EPG when you create new EPG data. I can see exactly what was created. I can even select a channel (or a specific program from a channel) and send it as a playlist (1 to 25 items) to any Enby client on my network (basically 4 TVs). I have a control panel where I can watch what's playing on my network, the bandwidth consumed, and send control messages to manage the content playing. For example, if my wife plays the TV too loud, I can turn it down. If She is not watching the TV, I can stop the playback. The display is similar to the Emby dashboard, but is designed for a tablet. It's my master remote. 

I use the Bulky plugin to surf my Emby libraries (just like the Emby Web Client does) and to tag (via clicking an item) the content within those libraries with tags that identify which channel the item belongs to. I can also remove all of these tags, or the tags for a specific channel, and set or reset the played tags. I can do this individually or in bulk. For example, I can tag all of my movies simultaneously.

All I need to do in virtualTV is to create 30 channels, each configured with their tag field set to "Channel_x", where x is the channel number. Once this is done, I never have to touch the virtual TV GUI again.  I just set my tags and refresh virtualTV via the scheduled programs. Of course, I also clicked all of the folder checkboxes. I know this is not a good practice. 

I can keep doing what I am doing, but my curiosity drives me to understand how things work. The part of virtualTV that I don't understand is how to build the Emby EPG one row at a time. I know the ApiClient and how to get and manipulate Emby content, and how to play it on my Emby devices. I don't know how to build the EPG so my Emby devices can choose from the EPG what to play. 

I am not trying to make a virtualTV replacement.  You are welcome to all of the code I create.  If you like the GUI (and I would hope that you would help me design what it should be) I will modify it to meet your requirements. You never need to mention my name.  I am a retired tech executive and have already received more credit than I deserve.

Vic

Link to comment
Share on other sites

VicMoore

@pünktchenand @BillOatmanMy ambition is to replace my EPG above with the embedded Emby EPG.  I want to learn how to do it. Emby players can then choose what they want to play from my Emby library.  I can then use my tablet and the associated dashboards to monitor and manage all of the Emby clients playing content on my network.  I used my integrated content selection tool to select what each channel includes.  I can post screen shots of this if you like.

Through this exercise I have learned the Emby REST API, the ApiClient, how to build plugins, the plugin API, how to build an Emby Web Client, a little about the Emby architecture, the Emby Library and how to surf its contents, how to fetch and edit images, and so much more.  The end game is to grow and learn. This keeps me young and alert. My give back to the Emby community is all of my code and sharing what I have learned with others.

Vic

  • Thanks 1
Link to comment
Share on other sites

pünktchen
53 minutes ago, VicMoore said:

My ambition is to replace my EPG above with the embedded Emby EPG.

From my understanding "EPG" is just the specialized grid view. It's about the visual aspect. But i think what you are actually mean is programdata! How to build your own programdata and how to transfer it to Emby's database. The rest api has a get endpoint livetv/program. Take this as a starting point, so you know about the scheme and what data is needed for a program item. Mainly StartDate, EndDate, ChannelId, ProgramId, Name, Overview and Genre. After building your own list of program items, you can post it to livetv/program.

Edited by pünktchen
Link to comment
Share on other sites

VicMoore

@pünktchenthe database I am using is the Emby database. I know how to use the REST API and I do fetch the data for my EPG via the API.  I provided the screenshots above to illustrate that I know how to use these APIs. I understand that I was not clear on that point.  The data you mentioned is easily obtained by deconstructing Emby Objects, which is what I do. 

What I don't know is how to take this data for every program in a TV Channel (which I have) and build from it a row in the Emby EPG for that channel.  I know how to read data from the Emby EPG.  I don't know how to write data to this EPG.  I need someone to explain how to do this.  

Vic

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...