justinemter / pseudo-channel

This is a python based cli-app using the python-plex-api to control a plex-client and act like a real TV channel with show scheduling, commercial breaks, movie nights, etc. "Home-Brewed TV Channel(s) for Hackers"
GNU General Public License v3.0
128 stars 18 forks source link

[REQUEST] Update web schedule with currently playing using -m #56

Closed irodimus closed 6 years ago

irodimus commented 6 years ago

I had a small request if it was possible to also update the web schedule with what was currently playing when using the -m option, like what happens when PseudoChannel.py is currently running and the web schedule highlight the current video along with the background. Reason being that I wanted to update the non playing channels by setting up a job to do that every couple of minutes. It would just make it easier to spot if the video that would be playing is highlighted when switching between schedules.

justinemter commented 6 years ago

Hmm, could you clarify a little more what you wanted with the -m option, sorry I couldn't quite pick up your intentions. Thanks man

irodimus commented 6 years ago

Currently, I have 18 channels and have a web page setup with tabs incorporating each channel's web schedule per tab. When a channel is playing, the current web schedule shows the background picture and highlights the currently playing video, which is the normal operation. But I also like to switch tabs into the other channel's web schedule and see what is currently "playing" at that time, but unlike the currently playing channel, their web schedule has a plain white background and the media that would be playing at that time is not highlighted.

I was hoping that the -m option, when run, would generate the web schedule HTML and also update the background and highlight the media that would be playing at that time, but I don't think it was designed that way. The reason I was looking for the -m option to do this, or even another option all together, was so that it update the schedule with background and highlight the video playing without PseudoChannel actually running. This option would, with a script in a job, update all the non playing channels web schedules as if PseudoChannel was running for each one, which the script would do like it does now for the channel's generating daily schedules or updating the channel's databases.

EDIT: This is just my way of having some sort of programming guide, but if there was a way to make a programming guide incorporating all the channel's schedules together on one page, that would be amazing.

justinemter commented 6 years ago

But I also like to switch tabs into the other channel's web schedule and see what is currently "playing" at that time, but unlike the currently playing channel, their web schedule has a plain white background and the media that would be playing at that time is not highlighted.

Ahh I think I see what you mean...so the item will highlight & the background image will show if that particular channel is currently playing (& that channel is running), right? For your other 17 pseudo-channels they are running only in concept and so their schedules do not reflect the currently playing item unless you change to the specific channel.

This is just my way of having some sort of programming guide, but if there was a way to make a programming guide incorporating all the channel's schedules together on one page, that would be amazing.

Yeah this makes sense. I think the best method is to have one app create / run all the channels rather than 18 different instances of the app. I'll have to revisit this though to see if I can come up with a short-term solution. Great ideas.

justinemter commented 6 years ago

I was hoping that the -m option, when run, would generate the web schedule HTML and also update the background and highlight the media that would be playing at that time, but I don't think it was designed that way.

Ok, so I was casually thinking about this issue and yeah the -m flag does not show what is currently playing but rather it just creates the html schedule (or recreates it). The highlight/bg image for the currently playing item is triggered 1 time when the show or movie starts... if you open up the python file: ./src/PseudoDailyScheduleController.py you will find a function named: get_html_from_daily_schedule(..). Toward the bottom of the class you can see that it is being called once when play(...) is triggered and once when it see's an endtime: check_for_end_time(...). It is also helpful to note that I have a Javascript function that either refreshes the html (within the html file) every 30 seconds if the simple python server is not used, and checks for a refresh flag every second if the simple python http server is being used.

I wrote another function that exports a .xml in the projects ./schedules/ dir. Within that xml I am exporting all sorts of info, including the data-current and data-start-time for each scheduled show. @MoeFwacky is using this for is really cool external VCR display. You could utilize this or find what is currently playing by scraping the .html and comparing the start time of an entry with the current time and the start time of the next scheduled item. I am using Bootstrap 4 for all table styles so all you need to do is append the CSS class bg-info to the row element in the html to highlight it. The BG image can be found in the xml for that entry. It sounds harder than it is I think. So you would use my updatechannels.sh script, alter it so it steps through each one of your channels.

justinemter commented 6 years ago

Ok, so the previous suggestion seemed overkill. I just pushed a new update to develop that should highlight the current item when running python PseudoChannel.py -m. @MoeFwacky, I haven't implemented this in your .xml output. If this seems important to you tell me and I can re-work the xml output to act like the .html.

irodimus commented 6 years ago

I updated to the develop branch and when I ran PseudoChannel.py -m, I get this error at the end:

Caught exception socket.error : [Errno 48] Address already in use

I am running an instance of PseudoChannel already on the Pi 3 so I'm guessing this might have something to do with it.

justinemter commented 6 years ago

hmm, the specific channels are trying to start a simple http web server on your channels using port 8000. One way to fix that is to go into each channels' config and update the ports to reflect their channel number (i.e. '8001', '8002', '8003', etc.). Or if you'd rather not use the python webserver thing, you can leave the port/IP setting in the configs blank for each channel. I think that is the solution for that particular error. Try it out and if not we'll try something else. Haha 18 channels is crazy man, what kinda channels are you running anyway? I remember you said you were mostly interested in movies! Cheers, brother.

irodimus commented 6 years ago

D'oh! You just reminded me that the config file had been updated recently for removing the Google Calendar integration and replaced all the channels' config file replacing the old one that had those blank :)

I basically have 3 random movies channels and 15 genre channels. It's kinda cool just getting home and seeing whats playing without having to really choose through my collection.

irodimus commented 6 years ago

Removing the server and port from config file solved the problem above.

I wanted to add that I did run into a few channels that showed all the times and then 'Here' and 'None' at the end and didn't appear to update the web schedule. Not all the channels did this but the majority did.

justinemter commented 6 years ago

I basically have 3 random movies channels and 15 genre channels. It's kinda cool just getting home and seeing whats playing without having to really choose through my collection.

Yes! That's really fun. I too really enjoy the mindlessness of it - exactly like when I was younger and watching whatever was on after school. (I'm 34 now and haven't had cable in years). Netflix can be exhausting trying to find something to commit to.

I wanted to add that I did run into a few channels that showed all the times and then 'Here' and 'None' at the end and didn't appear to update the web schedule. Not all the channels did this but the majority did.

Hmm, so using super genius debugging methodologies I am echoing the bgImage url (if found) and the "here" if I didn't find a match to retrieve the bgImage... that being said I guess I am happy I left that in there. Is it possible that the channels that this happened on weren't supposed to be playing anything (including commercials)? That's about the only time we should see that output...the "None" and "here" when running the -m flag. I'll go in there and make some proper debugging stuff if the problem persists.

irodimus commented 6 years ago

Hmm, so using super genius debugging methodologies I am echoing the bgImage url (if found) and the "here" if I didn't find a match to retrieve the bgImage... that being said I guess I am happy I left that in there. Is it possible that the channels that this happened on weren't supposed to be playing anything (including commercials)? That's about the only time we should see that output...the "None" and "here" when running the -m flag. I'll go in there and make some proper debugging stuff if the problem persists.

No commercials playing. Each channel just goes from one movie to the next. I ran it on a channel that would have something playing and it didn't pick anything up.

justinemter commented 6 years ago

Ok I'll add in some proper debugging to help us. Right now my single channel is highlighting the right item (empire strikes back) and the previous item...

justinemter commented 6 years ago

Ok, I think it's working now! Take it for a spin when you can. Thanks! :)

irodimus commented 6 years ago

Just tested it, working great now. Thanks for this!

justinemter commented 6 years ago

Ok, awesome man. Np.