Help with program guide python code
#1
Hopefully Lunatixz will see this.  This is probably more of a python question than a PseudoTV question.  FYI, I have 30+ years of software development experience so don't be afraid to confuse me.  I began modifying my copy of PseudoTV to make it more to my liking.  It is part of a "retro" setup on an old school television that creates the old school cable experience.  As part of this I created a "program guide channel", a scrolling channel that scrolls what is currently playing.  Basically when a user turns to channel 2 my code kicks in and shows an overlay above the playing video that scrolls the listings.

To do this I borrowed some code from EPGWindow.py since I assumed this was the best part to grab code that would give me a list of channels as well as what is currently playing on them.  I took this code and wrote it up and modified it to do just that.  For the most part the code works flawlessly and provides me with a list of the current channels, their names, as well as what is currently playing.  However at random there are channels that are 100% wrong.  I don't just mean they are off by a show or two, they are way wrong.  I started putting in code that would tell me what is going on in the background and I have found that the channels that are incorrect are the ones that produce a playlistpos of 0 (the beginning of the playlist for that channel).   As the code stands right now I have it outputting the section of code where the calculations come from, as well as the current epochBeginDate.  This data is appended to the channel listings on my guide screen, just for me to reference and find out what is going on.

By analyzing the code it seems that Lunatixz was attempting to iterate through channels, use the current system time by comparing it to the "time" in the channel playlist.  In which a loop is created to loop through each video, compound the total time, and exit the loop when the total time reflects the currently playing program.  

I cannot figure out why certain channels are not pulling the info properly.  Also if a channel does not pull correct info and I turn to that channel and then turn back, the information is corrected.  So it seems that there is some data updating that is not taking place 100% of the time in regards to channel times.  Actually, I always remember PseudoTV being notorious for losing your place on channels, especially after you exit and come back in.  I would switch to a channel and it would be miles behind where you would basically experience a repeat.  I ended up fixing that particular issue so now the channels are 100% every time.  But I still cannot get this guide channel data to populate properly.

As it stands right now, the epochBeginDate as well as the playlist position is appended to each line of the guide data.  All listings show an epochBeginDate, which is usually a very long number, the incorrect channels show a playlistpos of 0.

Here is the code that populates the guide data, which is very similar to that from the program guide code.  I tried to comment as heavily as I could.

https://paste.kodi.tv/genaficolu

Any suggestions would be appreciated
Reply
#2
(2019-08-28, 18:55)soundman1611 Wrote: Hopefully Lunatixz will see this.  This is probably more of a python question than a PseudoTV question.  FYI, I have 30+ years of software development experience so don't be afraid to confuse me.  I began modifying my copy of PseudoTV to make it more to my liking.  It is part of a "retro" setup on an old school television that creates the old school cable experience.  As part of this I created a "program guide channel", a scrolling channel that scrolls what is currently playing.  Basically when a user turns to channel 2 my code kicks in and shows an overlay above the playing video that scrolls the listings.

To do this I borrowed some code from EPGWindow.py since I assumed this was the best part to grab code that would give me a list of channels as well as what is currently playing on them.  I took this code and wrote it up and modified it to do just that.  For the most part the code works flawlessly and provides me with a list of the current channels, their names, as well as what is currently playing.  However at random there are channels that are 100% wrong.  I don't just mean they are off by a show or two, they are way wrong.  I started putting in code that would tell me what is going on in the background and I have found that the channels that are incorrect are the ones that produce a playlistpos of 0 (the beginning of the playlist for that channel).   As the code stands right now I have it outputting the section of code where the calculations come from, as well as the current epochBeginDate.  This data is appended to the channel listings on my guide screen, just for me to reference and find out what is going on.

By analyzing the code it seems that Lunatixz was attempting to iterate through channels, use the current system time by comparing it to the "time" in the channel playlist.  In which a loop is created to loop through each video, compound the total time, and exit the loop when the total time reflects the currently playing program.  

I cannot figure out why certain channels are not pulling the info properly.  Also if a channel does not pull correct info and I turn to that channel and then turn back, the information is corrected.  So it seems that there is some data updating that is not taking place 100% of the time in regards to channel times.  Actually, I always remember PseudoTV being notorious for losing your place on channels, especially after you exit and come back in.  I would switch to a channel and it would be miles behind where you would basically experience a repeat.  I ended up fixing that particular issue so now the channels are 100% every time.  But I still cannot get this guide channel data to populate properly.

As it stands right now, the epochBeginDate as well as the playlist position is appended to each line of the guide data.  All listings show an epochBeginDate, which is usually a very long number, the incorrect channels show a playlistpos of 0.

Here is the code that populates the guide data, which is very similar to that from the program guide code.  I tried to comment as heavily as I could.

https://paste.kodi.tv/genaficolu

Any suggestions would be appreciated

epoch is only used for one particular chtype (8) which is live tv. The loop helps live TV's linear lineup stay in order. PseudoTV's modules are heavily interconnected and not well suited for dropping in channels and guide data. I would recommend you look into uEPG, its a basic EPG framework I wrote to help developers. Feel free to fork and contribute code to the project. https://forum.kodi.tv/showthread.php?tid=321231
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
I made some progress and discovered that there was some code that I mistakenly omitted from the program guide code.  Now all channels except for channel 3 is correct.  I can't figure out why only that channel is incorrect while the others are not.  All of my channels are the same, playlist based channels.  

Channel 3 is my second channel in my lineup.  Channel 2 is my program guide channel that plays the same two videos over and over again (the background for the guide channel itself).  By what I am seeing channel 3 is registering a video that is way far back in the schedule.  When looking at what was currently playing, which should have been playlistpos of about 30, it was showing the playlistpos of 2.  It only does this on this specific channel.  I am thinking that after the code processes a few channels that something is getting corrected since the rest of the channels are all accurate, even after exiting and going back in to the plugin.

Here is my updated code:
https://paste.kodi.tv/ufemirusil
Reply
#4
(2019-08-28, 20:11)Lunatixz Wrote:
(2019-08-28, 18:55)soundman1611 Wrote: Hopefully Lunatixz will see this.  This is probably more of a python question than a PseudoTV question.  FYI, I have 30+ years of software development experience so don't be afraid to confuse me.  I began modifying my copy of PseudoTV to make it more to my liking.  It is part of a "retro" setup on an old school television that creates the old school cable experience.  As part of this I created a "program guide channel", a scrolling channel that scrolls what is currently playing.  Basically when a user turns to channel 2 my code kicks in and shows an overlay above the playing video that scrolls the listings.

To do this I borrowed some code from EPGWindow.py since I assumed this was the best part to grab code that would give me a list of channels as well as what is currently playing on them.  I took this code and wrote it up and modified it to do just that.  For the most part the code works flawlessly and provides me with a list of the current channels, their names, as well as what is currently playing.  However at random there are channels that are 100% wrong.  I don't just mean they are off by a show or two, they are way wrong.  I started putting in code that would tell me what is going on in the background and I have found that the channels that are incorrect are the ones that produce a playlistpos of 0 (the beginning of the playlist for that channel).   As the code stands right now I have it outputting the section of code where the calculations come from, as well as the current epochBeginDate.  This data is appended to the channel listings on my guide screen, just for me to reference and find out what is going on.

By analyzing the code it seems that Lunatixz was attempting to iterate through channels, use the current system time by comparing it to the "time" in the channel playlist.  In which a loop is created to loop through each video, compound the total time, and exit the loop when the total time reflects the currently playing program.  

I cannot figure out why certain channels are not pulling the info properly.  Also if a channel does not pull correct info and I turn to that channel and then turn back, the information is corrected.  So it seems that there is some data updating that is not taking place 100% of the time in regards to channel times.  Actually, I always remember PseudoTV being notorious for losing your place on channels, especially after you exit and come back in.  I would switch to a channel and it would be miles behind where you would basically experience a repeat.  I ended up fixing that particular issue so now the channels are 100% every time.  But I still cannot get this guide channel data to populate properly.

As it stands right now, the epochBeginDate as well as the playlist position is appended to each line of the guide data.  All listings show an epochBeginDate, which is usually a very long number, the incorrect channels show a playlistpos of 0.

Here is the code that populates the guide data, which is very similar to that from the program guide code.  I tried to comment as heavily as I could.

https://paste.kodi.tv/genaficolu

Any suggestions would be appreciated

epoch is only used for one particular chtype (8) which is live tv. The loop helps live TV's linear lineup stay in order. PseudoTV's modules are heavily interconnected and not well suited for dropping in channels and guide data. I would recommend you look into uEPG, its a basic EPG framework I wrote to help developers. Feel free to fork and contribute code to the project. https://forum.kodi.tv/showthread.php?tid=321231 

Thanks for the reply.  As it always happens, I figured it out.  Only happens after I get frustrated enough to go online and ask for help.  After I post the problem online, it comes to me.

In my last code paste the following line was jamming me up:
if curchannel == self.currentChannel-1:

So although I was sitting on channel 2 looking at the guide channel, the above code was registering that I was actually on channel 3, so it wasn't using the correct block of code to figure out which show was on.

To correct this I simply added a -1 to self.currentChannel, because one variable carries the channel index and the other carries the actual channel number.:
if curchannel == self.currentChannel-1:

Now I have an old school channel listings channel that stays updated all the time.  The way I set it up was when you tune to channel 3 the processing code updates the listings, shows the overlay over the bottom half of the screen and starts the animation timer to animate.  When turning to a different channel the overlay is hidden and the animation timer is cancelled to save performance.  I made the base video in After Effects which carries a bunch of movie trailers that are "on demand" (aka, just in my Kodi library).  

By the way I love this plugin, and it has been fun digging into the code and tearing it apart, has been a great learning experience for me since most of my background is more of VB.net, java and html.  I've customized this thing so much that I will probably just stick with it after the new version comes out.  Performance is great and after my fixes it literally never loses track of when and where a channel is.  

This aspect of my project is done and working.  Next I'm off to create a basic "weather channel", the very basic ones we had when it was just some basic graphics, some cheesy background music and the current forecast.

Here is a video of my old school guide channel, which is automatic and updates with all available channels:
https://www.youtube.com/watch?v=dt4hVcIr...e=youtu.be
Reply
#5
(2019-08-28, 21:00)soundman1611 Wrote:
(2019-08-28, 20:11)Lunatixz Wrote:
(2019-08-28, 18:55)soundman1611 Wrote: Hopefully Lunatixz will see this.  This is probably more of a python question than a PseudoTV question.  FYI, I have 30+ years of software development experience so don't be afraid to confuse me.  I began modifying my copy of PseudoTV to make it more to my liking.  It is part of a "retro" setup on an old school television that creates the old school cable experience.  As part of this I created a "program guide channel", a scrolling channel that scrolls what is currently playing.  Basically when a user turns to channel 2 my code kicks in and shows an overlay above the playing video that scrolls the listings.

To do this I borrowed some code from EPGWindow.py since I assumed this was the best part to grab code that would give me a list of channels as well as what is currently playing on them.  I took this code and wrote it up and modified it to do just that.  For the most part the code works flawlessly and provides me with a list of the current channels, their names, as well as what is currently playing.  However at random there are channels that are 100% wrong.  I don't just mean they are off by a show or two, they are way wrong.  I started putting in code that would tell me what is going on in the background and I have found that the channels that are incorrect are the ones that produce a playlistpos of 0 (the beginning of the playlist for that channel).   As the code stands right now I have it outputting the section of code where the calculations come from, as well as the current epochBeginDate.  This data is appended to the channel listings on my guide screen, just for me to reference and find out what is going on.

By analyzing the code it seems that Lunatixz was attempting to iterate through channels, use the current system time by comparing it to the "time" in the channel playlist.  In which a loop is created to loop through each video, compound the total time, and exit the loop when the total time reflects the currently playing program.  

I cannot figure out why certain channels are not pulling the info properly.  Also if a channel does not pull correct info and I turn to that channel and then turn back, the information is corrected.  So it seems that there is some data updating that is not taking place 100% of the time in regards to channel times.  Actually, I always remember PseudoTV being notorious for losing your place on channels, especially after you exit and come back in.  I would switch to a channel and it would be miles behind where you would basically experience a repeat.  I ended up fixing that particular issue so now the channels are 100% every time.  But I still cannot get this guide channel data to populate properly.

As it stands right now, the epochBeginDate as well as the playlist position is appended to each line of the guide data.  All listings show an epochBeginDate, which is usually a very long number, the incorrect channels show a playlistpos of 0.

Here is the code that populates the guide data, which is very similar to that from the program guide code.  I tried to comment as heavily as I could.

https://paste.kodi.tv/genaficolu

Any suggestions would be appreciated

epoch is only used for one particular chtype (8) which is live tv. The loop helps live TV's linear lineup stay in order. PseudoTV's modules are heavily interconnected and not well suited for dropping in channels and guide data. I would recommend you look into uEPG, its a basic EPG framework I wrote to help developers. Feel free to fork and contribute code to the project. https://forum.kodi.tv/showthread.php?tid=321231 

Thanks for the reply.  As it always happens, I figured it out.  Only happens after I get frustrated enough to go online and ask for help.  After I post the problem online, it comes to me.

In my last code paste the following line was jamming me up:
if curchannel == self.currentChannel-1:

So although I was sitting on channel 2 looking at the guide channel, the above code was registering that I was actually on channel 3, so it wasn't using the correct block of code to figure out which show was on.

To correct this I simply added a -1 to self.currentChannel, because one variable carries the channel index and the other carries the actual channel number.:
if curchannel == self.currentChannel-1:

Now I have an old school channel listings channel that stays updated all the time.  The way I set it up was when you tune to channel 3 the processing code updates the listings, shows the overlay over the bottom half of the screen and starts the animation timer to animate.  When turning to a different channel the overlay is hidden and the animation timer is cancelled to save performance.  I made the base video in After Effects which carries a bunch of movie trailers that are "on demand" (aka, just in my Kodi library).  

By the way I love this plugin, and it has been fun digging into the code and tearing it apart, has been a great learning experience for me since most of my background is more of VB.net, java and html.  I've customized this thing so much that I will probably just stick with it after the new version comes out.  Performance is great and after my fixes it literally never loses track of when and where a channel is.  

This aspect of my project is done and working.  Next I'm off to create a basic "weather channel", the very basic ones we had when it was just some basic graphics, some cheesy background music and the current forecast.

Here is a video of my old school guide channel, which is automatic and updates with all available channels:
https://www.youtube.com/watch?v=dt4hVcIr...e=youtu.be
I don't understand any of the programming but I've got to post in the thread to say this is so cool! Thanks for sharing the video of it in action, hopefully we'll be able to use it or something like it once the main addon for PseudoTV Live is updated. I can't stop grinning, this is the kind of stuff I was hoping to eventually see when I first started using the addon back when it was TV Time... I love it! Smile
Reply
#6
(2019-08-28, 23:43)bornagainpengui Wrote:
(2019-08-28, 21:00)soundman1611 Wrote:
(2019-08-28, 20:11)Lunatixz Wrote: epoch is only used for one particular chtype (8) which is live tv. The loop helps live TV's linear lineup stay in order. PseudoTV's modules are heavily interconnected and not well suited for dropping in channels and guide data. I would recommend you look into uEPG, its a basic EPG framework I wrote to help developers. Feel free to fork and contribute code to the project. https://forum.kodi.tv/showthread.php?tid=321231 

Thanks for the reply.  As it always happens, I figured it out.  Only happens after I get frustrated enough to go online and ask for help.  After I post the problem online, it comes to me.

In my last code paste the following line was jamming me up:
if curchannel == self.currentChannel-1:

So although I was sitting on channel 2 looking at the guide channel, the above code was registering that I was actually on channel 3, so it wasn't using the correct block of code to figure out which show was on.

To correct this I simply added a -1 to self.currentChannel, because one variable carries the channel index and the other carries the actual channel number.:
if curchannel == self.currentChannel-1:

Now I have an old school channel listings channel that stays updated all the time.  The way I set it up was when you tune to channel 3 the processing code updates the listings, shows the overlay over the bottom half of the screen and starts the animation timer to animate.  When turning to a different channel the overlay is hidden and the animation timer is cancelled to save performance.  I made the base video in After Effects which carries a bunch of movie trailers that are "on demand" (aka, just in my Kodi library).  

By the way I love this plugin, and it has been fun digging into the code and tearing it apart, has been a great learning experience for me since most of my background is more of VB.net, java and html.  I've customized this thing so much that I will probably just stick with it after the new version comes out.  Performance is great and after my fixes it literally never loses track of when and where a channel is.  

This aspect of my project is done and working.  Next I'm off to create a basic "weather channel", the very basic ones we had when it was just some basic graphics, some cheesy background music and the current forecast.

Here is a video of my old school guide channel, which is automatic and updates with all available channels:
https://www.youtube.com/watch?v=dt4hVcIr...e=youtu.be 
I don't understand any of the programming but I've got to post in the thread to say this is so cool! Thanks for sharing the video of it in action, hopefully we'll be able to use it or something like it once the main addon for PseudoTV Live is updated. I can't stop grinning, this is the kind of stuff I was hoping to eventually see when I first started using the addon back when it was TV Time... I love it! Smile 

When the new version comes out maybe Lunatixz will have a way for others to easily create integrations to work within PseudoTV.  What I have now is very much hacked, but I did do it in such a way as to not interfere with any of the plugin's operations or without being a performance hog.  Part of me feels like releasing a slightly different version of the plugin, giving the user the ability to customize such features.  I don't have a lot of time on my hands though, and most likely by the time I get anything done Lunatixz will have released his version leaving anything I do in the dust.
Reply
#7
(2019-08-29, 00:00)soundman1611 Wrote:
(2019-08-28, 23:43)bornagainpengui Wrote:
(2019-08-28, 21:00)soundman1611 Wrote: Thanks for the reply.  As it always happens, I figured it out.  Only happens after I get frustrated enough to go online and ask for help.  After I post the problem online, it comes to me.

In my last code paste the following line was jamming me up:
if curchannel == self.currentChannel-1:

So although I was sitting on channel 2 looking at the guide channel, the above code was registering that I was actually on channel 3, so it wasn't using the correct block of code to figure out which show was on.

To correct this I simply added a -1 to self.currentChannel, because one variable carries the channel index and the other carries the actual channel number.:
if curchannel == self.currentChannel-1:

Now I have an old school channel listings channel that stays updated all the time.  The way I set it up was when you tune to channel 3 the processing code updates the listings, shows the overlay over the bottom half of the screen and starts the animation timer to animate.  When turning to a different channel the overlay is hidden and the animation timer is cancelled to save performance.  I made the base video in After Effects which carries a bunch of movie trailers that are "on demand" (aka, just in my Kodi library).  

By the way I love this plugin, and it has been fun digging into the code and tearing it apart, has been a great learning experience for me since most of my background is more of VB.net, java and html.  I've customized this thing so much that I will probably just stick with it after the new version comes out.  Performance is great and after my fixes it literally never loses track of when and where a channel is.  

This aspect of my project is done and working.  Next I'm off to create a basic "weather channel", the very basic ones we had when it was just some basic graphics, some cheesy background music and the current forecast.

Here is a video of my old school guide channel, which is automatic and updates with all available channels:
https://www.youtube.com/watch?v=dt4hVcIr...e=youtu.be 
I don't understand any of the programming but I've got to post in the thread to say this is so cool! Thanks for sharing the video of it in action, hopefully we'll be able to use it or something like it once the main addon for PseudoTV Live is updated. I can't stop grinning, this is the kind of stuff I was hoping to eventually see when I first started using the addon back when it was TV Time... I love it! Smile  

When the new version comes out maybe Lunatixz will have a way for others to easily create integrations to work within PseudoTV.  What I have now is very much hacked, but I did do it in such a way as to not interfere with any of the plugin's operations or without being a performance hog.  Part of me feels like releasing a slightly different version of the plugin, giving the user the ability to customize such features.  I don't have a lot of time on my hands though, and most likely by the time I get anything done Lunatixz will have released his version leaving anything I do in the dust. 

I love the look of that guide in the video.

You mentioned tearing apart the plugin, by any chance have you been able to tweak the part of the plugin where it has trouble playing episodes of a show in order. For example, my wife's favorite show is Friends and for the life of me I can never get the episodes to play in order. I feel like maybe I'm also missing something here.

Also, any chance you might be releasing your modified version of the plugin?
Reply
#8
(2019-08-29, 16:26)gamaru Wrote:
(2019-08-29, 00:00)soundman1611 Wrote:
(2019-08-28, 23:43)bornagainpengui Wrote: I don't understand any of the programming but I've got to post in the thread to say this is so cool! Thanks for sharing the video of it in action, hopefully we'll be able to use it or something like it once the main addon for PseudoTV Live is updated. I can't stop grinning, this is the kind of stuff I was hoping to eventually see when I first started using the addon back when it was TV Time... I love it! Smile  

When the new version comes out maybe Lunatixz will have a way for others to easily create integrations to work within PseudoTV.  What I have now is very much hacked, but I did do it in such a way as to not interfere with any of the plugin's operations or without being a performance hog.  Part of me feels like releasing a slightly different version of the plugin, giving the user the ability to customize such features.  I don't have a lot of time on my hands though, and most likely by the time I get anything done Lunatixz will have released his version leaving anything I do in the dust.  

I love the look of that guide in the video.

You mentioned tearing apart the plugin, by any chance have you been able to tweak the part of the plugin where it has trouble playing episodes of a show in order. For example, my wife's favorite show is Friends and for the life of me I can never get the episodes to play in order. I feel like maybe I'm also missing something here.

Also, any chance you might be releasing your modified version of the plugin? 

That I don't know, I haven't looked into the channel building code yet but I might get around to it.  I can release what I have but I do have to warn that it is highly modified, so people may not like it.  It's recoded to simulate old school cable, so the info popup is basically very basic looking and not nice and modern looking like the original.  Also the guide channel (2) is hard coded, but I suppose I could put an entry in the configuration window to customize which channel you wish to show the scrolling guide.  Keep in mind that the channel guide is a combination of a custom video that I created in Adobe After Effects and an overlay that is coded into PTV.  Basically you create a channel and set these fake videos in a playlist.  When you turn to that channel the code immediately places the overlay above the video.  So basically I had to create that video to specifically fit if you know what I mean.  I don't want anyone to think that I resized the video window itself to the upper right hand corner and the rest are all graphics.  So without that video you would not have too much, although I suppose I could design even older looking ones, the ones that were so basic they didn't have anything except for text.  The trailers that play are only a few, I need to put more together because it's starting to get repetitive.  Part of me wonders if there is a way for me to change the size of the video player only on that channel, and then actually put in labels and graphics for the rest of the screen.  Then you could simply establish a trailers folder and whatever trailers are in that folder would automatically play in the upper right hand corner.

I also replaced the channel number with a much larger and older looking one.  Before Lunatixz used images to build up the channel label using a smooth font and smaller letters.  I downloaded this old font called vcrosd.ttf and built a new channel number overlay that uses regular text with this font, to basically replicate the actual channel label on my television set.  The good thing about this is I could actually add entries into the configuration dialog to allow you to customize the channel number like change the font name, size, bold, etc.    Since I have so little channels I recoded the plugin to basically work with 2 digit channels, so if I enter (21) into my remote, it immediately turns to channel 21, so if I had a channel 221 I wouldn't be able to get there through direct input, but I could always change this back or allow it to be automatically configured based on whether or not you have 3 or 2 digit channels.

I will have to remove part of the code that is dependant specifically on my system.  I have an application that I designed that works on my tv computer, it's basically what I call a kiosk enforcement app.  It monitors Kodi and makes sure it keeps focus, restarts it if it crashes, handles issues with running emulators (when Windows decides to give focus to nothing at all after you exit an emulator, and my roommate is sitting there mashing buttons and nothing is happening.  Part of this app senses when I turn off my television and puts the computer to sleep.  However, an issue I found was that if PseudoTV is running while the computer goes to sleep, after waking Pseudotv is jammed up.  So I added some "cheater code" where pseudotv runs a timer every few seconds and checks a folder on my computer for a file called "sleep.txt".  Lunatixz is probably laughing right now, I said it was a cheater move!  Just before going to sleep my app puts that file in that folder, Pseudotv automatically exits and the system goes to sleep.  Then on wake my app relaunches PTV through jsonrpc, giving me live tv within about 10 seconds from powering the tv on.  So that was a long explanation but I will have to deal with this part of the code or the plugin will crash on anyone else's computer since that folder will not be present.

Also keep in mind that I did increase performance in the plugin, but at the cost of images.  Since I don't actually use them, I removed all artwork, channel logos, and downloading of images.  So channel generation is lightning fast, but you will not have any channel logos, or artwork associated with any videos.  I can see how many tasks in PTV were done the long way, but this has obviously been a project at work by Lunatixz, and from my experience you don't really get something good from a coder until a few major releases and revamps.  

With all of that said I will work towards releasing it, but not before I tie up these few loose ends.  Also I think it would be prudent for me to change the addon data folder to something different.  That way if you wanted to experiment with my plugin without having to remove PTV you can.  I would rather someone experiment with it on the side and if something goes wrong you can just go right back to PTV than to end up screwing up someone's configuration.

Oh Lunatixz if you are reading this I have a feature suggestion, although I have a feeling you may have already thought of this.  I noticed that sometimes if you have a system crash or Kodi crash it can cause your PTV channels to be lost, so after restarting it says there are no channels and that you have to autotune.  Right now I have my kiosk app doing secondary backups where settings2.xml is backed up to a completely different folder separate from PTVL.  I think the plugin should have the ability to backup to a folder of the user's choice (optional) because I have seen the PTV folder get messed up and even backups lost.  That's why I have my secondary app backing them up to a different folder.  A user could set a folder in the config for instance.  On startup you could code it that if no channels are detected, it then checks to see if any backups are present.  If they are present the most recent is restored, if no backups are present then the user is presented with the dialog asking if you want to autotune.  So in the end, you could have someone's channel config get messed up, and restored on startup and the user would barely even know what happened.

Another thing I wanted to suggest is the ability to share channels using a network shared folder.  In my house I have a few computers running Kodi and I plan on installing PTV on these others.  I was thinking it would be great if you could set a folder on a network drive, like my WD Mycloud that holds all of my content.  The "master" computer would generate the channels and upload the needed files to the folder, then the other computers would either copy or read in place the files when needed.  The reason why I would like to use a network folder is my computers are all set to go to sleep when the tv is turned off to save on electricity.  So the master computer may not be available all the time, but the network drive is always available.  Maybe this can already be done, your thoughts on this would be appreciated.

I will say this though, even with everything I am doing I think based on what I have read that the new version is going to still come on top performance wise.  That is probably my biggest desire is performance, I never liked how long it took to change channels.  Although mine is a little faster, it still could be quicker.  I remember years ago when I developed a live tv app in VB.net it was basically instant, but that app completely sucked otherwise, channels were completely random.

Lunatixz, do you know if there is a way to set up additional JSON RPC methods into a plugin that would allow outside applications to communicate with PTVL.  For instance, my stupid sleep.txt thing is obviously a cheat and should be done properly.  It would be cool to set up other methods like rpc calls to change to a specific channel, exit ptvl, or anything else using JSON instead of silly text files in a directory.  I haven't been able to narrow down the right documentation.  I was thinking of getting an old school cable box, the ones with the push buttons on top and wiring it up with a phidgets usb control board that would send rpc calls to PTV to set the specific channels as they are changed on the box.  Basically you would push a button, the control board sends the code to my app, my app then blasts the rpc call to change to that specific channel.  Because using new technology to bring old outdated technology back is what it's all about.
Reply
#9
Lunatixz I would like to pick your brain for a second, I'm sure I am probably making a very simple mistake.  I am trying to add the start time of each program in my scrolling program guide.  I adopted code from Tvoverlay.showinfo.  All of the other code I have in place works flawlessly, all guide data on my guide channel is accurate, but the start times seem to be very off and very random.  

For example, right now it's 12:23pm.  I'm seeing start times on my guide like 9:23am, 12:11am, 4:46pm, 6:19am, etc. 

The code is heavily commented and I put a very long marker "########################################################" to show exactly where the code in question is.  Basically it's only a few lines of code where I use the playlistpos, which is definitely correct to pull the itemtimestamp and convert that into the actual start time.

https://paste.kodi.tv/winikovequ
Reply
#10
Fixed!  Once again something that I just overlooked, and assumed the wrong blocks of code were being executed.  I tend to do this, miss the tiny little details.  Every channel I have is a custom playlist channel, aka the channel type is 0.  I have no idea why but for some reason I actually thought it was 8.  In hindsight seeing why you pointed out that 8 is only for live tv.  I incorrectly assumed that playlist channels were considered live tv, since they simulate live tv.  I now see that I guess you have the ability to actually watch live tv through this plugin, which I have never experimented with.  

Anyhow the start time labels are now 100% accurate in my scrolling listings using the very simple block of code:

timeToDisplay = reftime + videotime
                                
strStartTime = datetime.datetime.fromtimestamp(float(timeToDisplay)).strftime("%I:%M%p").lower()

So unless I am working with live tv streams, I need to stop thinking about epoch!
Reply
#11
(2019-08-28, 21:00)soundman1611 Wrote:
(2019-08-28, 20:11)Lunatixz Wrote:
(2019-08-28, 18:55)soundman1611 Wrote: Hopefully Lunatixz will see this.  This is probably more of a python question than a PseudoTV question.  FYI, I have 30+ years of software development experience so don't be afraid to confuse me.  I began modifying my copy of PseudoTV to make it more to my liking.  It is part of a "retro" setup on an old school television that creates the old school cable experience.  As part of this I created a "program guide channel", a scrolling channel that scrolls what is currently playing.  Basically when a user turns to channel 2 my code kicks in and shows an overlay above the playing video that scrolls the listings.

To do this I borrowed some code from EPGWindow.py since I assumed this was the best part to grab code that would give me a list of channels as well as what is currently playing on them.  I took this code and wrote it up and modified it to do just that.  For the most part the code works flawlessly and provides me with a list of the current channels, their names, as well as what is currently playing.  However at random there are channels that are 100% wrong.  I don't just mean they are off by a show or two, they are way wrong.  I started putting in code that would tell me what is going on in the background and I have found that the channels that are incorrect are the ones that produce a playlistpos of 0 (the beginning of the playlist for that channel).   As the code stands right now I have it outputting the section of code where the calculations come from, as well as the current epochBeginDate.  This data is appended to the channel listings on my guide screen, just for me to reference and find out what is going on.

By analyzing the code it seems that Lunatixz was attempting to iterate through channels, use the current system time by comparing it to the "time" in the channel playlist.  In which a loop is created to loop through each video, compound the total time, and exit the loop when the total time reflects the currently playing program.  

I cannot figure out why certain channels are not pulling the info properly.  Also if a channel does not pull correct info and I turn to that channel and then turn back, the information is corrected.  So it seems that there is some data updating that is not taking place 100% of the time in regards to channel times.  Actually, I always remember PseudoTV being notorious for losing your place on channels, especially after you exit and come back in.  I would switch to a channel and it would be miles behind where you would basically experience a repeat.  I ended up fixing that particular issue so now the channels are 100% every time.  But I still cannot get this guide channel data to populate properly.

As it stands right now, the epochBeginDate as well as the playlist position is appended to each line of the guide data.  All listings show an epochBeginDate, which is usually a very long number, the incorrect channels show a playlistpos of 0.

Here is the code that populates the guide data, which is very similar to that from the program guide code.  I tried to comment as heavily as I could.

https://paste.kodi.tv/genaficolu

Any suggestions would be appreciated

epoch is only used for one particular chtype (8) which is live tv. The loop helps live TV's linear lineup stay in order. PseudoTV's modules are heavily interconnected and not well suited for dropping in channels and guide data. I would recommend you look into uEPG, its a basic EPG framework I wrote to help developers. Feel free to fork and contribute code to the project. https://forum.kodi.tv/showthread.php?tid=321231  

Thanks for the reply.  As it always happens, I figured it out.  Only happens after I get frustrated enough to go online and ask for help.  After I post the problem online, it comes to me.

In my last code paste the following line was jamming me up:
if curchannel == self.currentChannel-1:

So although I was sitting on channel 2 looking at the guide channel, the above code was registering that I was actually on channel 3, so it wasn't using the correct block of code to figure out which show was on.

To correct this I simply added a -1 to self.currentChannel, because one variable carries the channel index and the other carries the actual channel number.:
if curchannel == self.currentChannel-1:

Now I have an old school channel listings channel that stays updated all the time.  The way I set it up was when you tune to channel 3 the processing code updates the listings, shows the overlay over the bottom half of the screen and starts the animation timer to animate.  When turning to a different channel the overlay is hidden and the animation timer is cancelled to save performance.  I made the base video in After Effects which carries a bunch of movie trailers that are "on demand" (aka, just in my Kodi library).  

By the way I love this plugin, and it has been fun digging into the code and tearing it apart, has been a great learning experience for me since most of my background is more of VB.net, java and html.  I've customized this thing so much that I will probably just stick with it after the new version comes out.  Performance is great and after my fixes it literally never loses track of when and where a channel is.  

This aspect of my project is done and working.  Next I'm off to create a basic "weather channel", the very basic ones we had when it was just some basic graphics, some cheesy background music and the current forecast.

Here is a video of my old school guide channel, which is automatic and updates with all available channels:
https://www.youtube.com/watch?v=dt4hVcIr...e=youtu.be 
I too know very little about the actual code as peng stated, I have dipped in to see if I could figure anything out and have purchased a few python books but am basically starting from nothing just to see what I can figure out. 

I also just wanted to say thank you for the video as this is very exciting and a rush of nostalgia. Definitely what I grew up on. Thank you for your time and effort and giving us a view into the inner workings. It all helps me have even the vaguest idea of what is going on lol.
Reply

Logout Mark Read Team Forum Stats Members Help
Help with program guide python code1