Cleanup / added cli flags for info gathering / debugging.

This commit is contained in:
Justin Emter
2017-07-22 19:38:05 -07:00
parent 693a9784ff
commit 78f4aeb7cb
11 changed files with 1318 additions and 1241 deletions

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from src import PseudoChannelDatabase
@@ -29,7 +30,6 @@ sys.setdefaultencoding('utf-8')
class PseudoChannel():
PLEX = PlexServer(config.baseurl, config.token)
MEDIA = []
def __init__(self):
@@ -646,6 +646,40 @@ class PseudoChannel():
previous_episode = entry
def show_clients(self):
print "##### Connected Clients:"
for i, client in enumerate(self.PLEX.clients()):
print "+++++", str(i + 1)+".", "Client:", client.title
def show_schedule(self):
print "##### Daily Pseudo Schedule:"
daily_schedule = self.db.get_daily_schedule()
for i , entry in enumerate(daily_schedule):
print "+++++", str(i + 1)+".", entry[11], entry[8], entry[6], " - ", entry[3]
def exit_app(self):
print "Exiting Pseudo TV & cleaning up."
for i in self.MEDIA:
del i
self.MEDIA = None
self.controller = None
self.db = None
sleep(1)
if __name__ == '__main__':
pseudo_channel = PseudoChannel()
@@ -660,9 +694,16 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Pseudo Channel for Plex. Update pseduo_config.py & pseudo_schedule.xml before this step.",
usage="PseudoChannel.py [-u] update local db with plex db [-xml] update db with xml schedule data [-g] generate daily schedule [-r] run the app"
usage="PseudoChannel.py [-u] update local db with plex db [-xml] update db " \
"with xml schedule data [-g] generate daily schedule [-r] run the app"
)
'''
*
* Primary arguments: "python PseudoChannel.py -u -xml -g -r"
*
'''
parser.add_argument('-u', action='store_true')
parser.add_argument('-xml', action='store_true')
parser.add_argument('-g', action='store_true')
@@ -670,16 +711,23 @@ if __name__ == '__main__':
'''
*
* Show connected clients: "python PseudoChannel.py -u -xml -g -r"
* Show connected clients: "python PseudoChannel.py -c"
*
'''
parser.add_argument('-sc', action='store_true')
parser.add_argument('-c', action='store_true')
'''
*
* Show schedule (daily): "python PseudoChannel.py -s"
*
'''
parser.add_argument('-s', action='store_true')
globals().update(vars(parser.parse_args()))
args = parser.parse_args()
print(args)
#print(args)
if args.u:
@@ -693,11 +741,21 @@ if __name__ == '__main__':
pseudo_channel.generate_daily_schedule()
if args.c:
pseudo_channel.show_clients()
if args.s:
pseudo_channel.show_schedule()
if args.r:
try:
print "++++ Running TV Controller"
print "##### Running TV Controller"
print "+++++ To run this in the background:"
print "+++++", "screen -d -m bash -c 'python PseudoChannel.py -r; exec sh'"
"""Every minute on the minute check the DB startTimes of all media to
determine whether or not to play. Also, check the now_time to
@@ -724,7 +782,9 @@ if __name__ == '__main__':
except KeyboardInterrupt, e:
pass
pseudo_channel.exit_app()
del pseudo_channel

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
#!/usr/bin/env python
"""
1) Create a file outside of this proj dir called "plex_token.py":

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from Media import Media
class Commercial(Media):

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from Media import Media
class Episode(Media):

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
"""
*** Inherited by Commercial, Episode & Movie
"""

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from Media import Media
class Movie(Media):

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from Media import Media
class Music(Media):

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sqlite3
import datetime
import time

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from plexapi.server import PlexServer
from datetime import datetime
import sqlite3

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
from Media import Media
class Video(Media):