Merge branch 'develop'

This commit is contained in:
Justin Emter
2017-09-07 10:04:04 -07:00

View File

@@ -67,6 +67,17 @@ When you start the application with this bash script, you can close your termina
Features are being added to the xml but as of now there are a few. Within the XML `<time>` entry you are able to pass in various attributes to set certain values. As of now, aside from "title" and "type" which are mandatory, you can take advantage of "time-shift". This parameter accepts values in minutes and can be no lower than "1". If the attribute, "strict-time" is set to "false", then this `<time>` entry will be shifted to a new time based on the previous time with a smaller gap calculated according to the value in "time-shift". Basically, if you do not want any gaps in your daily generated schedule you would leave "strict-time" false and set "time-shift" to "1" for all `<time>` entries. However, this will create a schedule with weird start times like, "1:57 PM". Taking advantage of the "time-shift" perameter will correct this. If you set it to a value of "5", all media is shifted and hooked on to a "pretty" time that is a multiple of 5. So if used, rather then having a "Seinfeld" episode being set to "1:57 PM" it may be recalculated and scheduled for "2:00 PM". However, if you would like to make sure that "The Simpsons" will always start every weekday at "6:00 PM" then you can simply set that `<time>` entry to `srtict-time="true"`. This will ensure that despite other non-strict times shifting around, "The Simpsons" will air every weekday at the desired "6:00 PM" as scheduled (be sure that you haven't accidentally made two time entries "strict-time" for the same day/time - this sort of thing will cause weird scheduling errors). When using "strict-time" or having the "time-shift" value > than 1 (minute), this will result in empty gaps in the schedule. Currently I have a flag in the config for "commercial injection" to fill up the gaps as much as possible with commercials from commercials in your Plex server "Commercials" library. If you do not want to use this feature or if you don't have any commercials in your Plex server, just open up that `pseudo_config.py` file and set `useCommercialInjection` to `False`. Please check the `pseudo-channel.xml` for more information.
## Specifying Random Movies in Your Schedule:
You are able to specify random movies in your XML schedule by adding a `<time>` entry as follows:
```xml
<time title="random" type="movie" strict-time="false" time-shift="5" xtra='actor:mike myers genre:comedy contentRating:PG-13'>9:00 PM</time>
```
I have placed this time entry in the `<weekdays>` block of the XML. You can only specify `title="random"` for movie time blocks... however, you can further define parameters in the `xtra=` attribute. The `xtra` params are passed-in separated by a `:` as the delimiter as seen above. As I am using the Python Plex API to handle that logic, you can view their list of options: http://python-plexapi.readthedocs.io/en/latest/modules/library.html#plexapi.library.LibrarySection.search
Furthermore, if you'd like to specify multiple values in the `xtra` params, say to schedule saturday morning kid-friendly movies, you could do something like: `xtra="contentRating:G,PG"`. This works for other parameters, like `genre`: `xtra="genre:comedy,romance"`. Just beware that if the app cannot find a single movie in your library that matches your parameters, it will just give you a random movie dismissing all the params.
## The Automatically Generated .HTML Daily Schedule / Server
To view the automatically generated "Daily Pseudo Schedule" index.html as seen in the image above, find it in the generated `./schedules/` directory within the project folder. The html file is generated both when the daily schedule is updated and whenever a media item from the schedule plays or ends (you can manually generate it with the `-m` flag).
@@ -78,6 +89,67 @@ http://192.168.1.28:8000
```
*Where `192.168.1.28` is the IP of your controller & `8000` is the port - both perameters are configured in the `pseudo_config.py` file.*
## Adding New TV/Movies/Commercials to Your Channel:
Whenever you add new content to your Plex library, you need to run: `python PseudoChannel.py -u`. This will tell the app to check the Plex library and update the local database with new media.
## Multi-Channel Support:
You can have multpile instances of this app, specify different schedules for each instance and control it via a USB remote. Let's say you choose to have 3 channels, an all day movie channel, a 'cartoon network' channel, and a 90's channel. You would simply create a directory named something like `/channels`. Then within your `/channels` dir you would have your `plex_token.py` file and your channels named something like: `/channel_1`, `channel_2` & `channel_3`. Note: the only important naming convention here is that `_1`, `_2`, etc. is contained at the end of each directory title. Each channel directory will contain the contents of this repository, set up just as if you had a single channel. So your directory structure would look like this:
```bash
-channels/
--plex_token.py
--channel_1/
---pseudo-channel.db
---PseudoChannel.py
---...etc.
--channel_2/
---pseudo-channel.db
---PseudoChannel.py
---...etc.
--channel_3/
---pseudo-channel.db
---PseudoChannel.py
---...etc.
```
In order to get this working with a usb remote hooked up to your Raspberry Pi, you need to configure the remotes channel buttons to trigger the corresponding bash scripts. I have placed a `channelup.sh` and a `channeldown.sh` within the projects `bash-scripts/` dir. You need to move these files to the `channels/` directory to make it work. When everything is setup properly and you have configured your remote, your channel up/channel down buttons should trigger the corresponding scripts triggering the channel to change. Lastly you need to configure a crontab so your controller automatically triggers each channel to generate a new daily schedule when the clock hits, `12:00 AM`. If you are running a single channel the the app knows to update when the clock strikes mid-night. However, if you are using this multi-channel method, the bash scripts will start / stop the corresponding channels depending on what channel you are watching. There is another bash script that you configure a crontab to trigger that will generate a new daily schedule for each channel that isn't currently running.
*This is a work in progress.*
## Known Issues/Workarounds
By far, the most issues result from XML errors. It's important to make sure that all XML `<time>` entries are properly formatted and that you do not squeeze in too many `<time>` entries in your daily schedule. A good example of too many time entries is when you try and fill up a full 24 hours with daily content. Since PseudoChannel.py generates a new daily scedule every 24 hours, it will overwrite the previous 24 hours with the new content. So, if you were watching a movie that was scheduled to start at `11:00 PM`, the app will generate a new daily schedule when the clock hits `12:00 AM`. However, I added some logic that should allow any previous playing media to finish before beginning the next days schedule. It's best to try and avoid overfilling your schedule.
### Problem Solving
The best way to pinpoint errors and wonky-ness is to run the app in your console using: `python PseudoChannel.py -r`. Although there is a `.log` file that is generated in the working directory, the output from running the app manually is more verbose. Also, it is important open up `psuedo_config.py` and change, `debug_mode` from `False` to `True`. This will not only show more verbose output when running PseudoChannel.py, but will also show all scheduled content (including commercials) in the generated daily schedule .html.
#### Inspecting the Database.
If you'd like to dig deeper I recommend using a database inspector utility like, [sqlitebrowser](http://sqlitebrowser.org/). The app generates a local sqlite db called, `psuedo-channel.db` located in the root of the project directory. There are a few tables to look at, the `daily_schedule` table and the `schedule` table. The former is the where all the daily generated time entries are placed and the latter is where the XML time entries are stored.
#### Don't Be Afraid to Delete Your Local Database/Start Over:
If for some reason you want to delete your old DB but don't want to lose your TV queue you can do the following...
1) Export the TV queue by running `python PseudoChannel.py -e`. This exports the queue to a json file.
2) Delete the pseudo-channel.db file.
3) Re-generate the fresh database by running: `python PseudoChannel.py -u`
4) Import the old TV queue: `python PseudoChannel.py -i`.
*...this has been helpful mostly when debugging/developing, but it may be helpful for others too. Of course if you don't care about your TV queue you can skip steps, 1 & 4.*
## Contact Mark Or Me
We set up [discord](https://discord.gg/7equn68) channel where you can ping Mark and I with any issues you may run into. You can find us there or file an "issue" here in this repo.
Stay tuned for a polished version / bug fixes. I've also started a user friendly web version that hopefully will be working soon.
Special thanks to Mark @ [Fake TV](https://medium.com/@Fake.TV). Without his creative ideas and love for TV, this "PseudoChannel" wouldn't be as cool as it is. I look forward to tinkering with this project and seeing others "unplugging" and creating their own home network. Mark has some excellent ideas in regard to making this thing much more usable as a "pseudo-cable" network - I think this will be in the next version as it is the 'icing on the cake' sort of feature. Anyway, enjoy!
## Special Thanks
Special thanks to Mark @ [Fake TV](https://medium.com/@Fake.TV). Without his creative ideas and love for TV, this "PseudoChannel" wouldn't be as cool as it is. I look forward to tinkering with this project and seeing others "unplugging" and creating their own home network. Mark has some excellent ideas in regard to making this thing much more usable as a "pseudo-cable" network - I think this will be in the next version as it is the 'icing on the cake' sort of feature. Anyway, enjoy!