cdosea-play/cdoseaplay/play.py

55 lines
1.4 KiB
Python
Raw Normal View History

2017-08-25 19:21:36 +00:00
#!/usr/bin/python3
2017-08-30 14:07:50 +00:00
import argparse
from glob import glob
2017-08-25 19:21:36 +00:00
import os
import sys
2017-08-30 14:07:50 +00:00
from .utils import update_playlist, get_player
2017-08-25 19:21:36 +00:00
2017-08-30 14:07:50 +00:00
import logging
logger = logging.getLogger('cdosea')
2017-08-25 19:21:36 +00:00
2017-08-30 14:07:50 +00:00
player = None
2017-08-25 19:21:36 +00:00
def q_binding(*args):
global player
player.quit()
del player
2017-08-30 14:07:50 +00:00
def main():
global player
playlist = os.path.expanduser('~/Videos/cdosea.m3u')
prefix = os.path.expanduser('~/Videos/CDOSEA')
parser = argparse.ArgumentParser(description='play 2 screens in sync')
parser.add_argument('--playlist', help='play.m3u', default=playlist)
parser.add_argument('--prefix', help='video location', default=prefix)
parser.add_argument('--window', action='store_true', help='run in window', default=False)
parser.add_argument('--debug', action='store_true', help='debug', default=False)
args = parser.parse_args()
DEBUG = args.debug
if DEBUG:
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
logging.basicConfig(level=logging.DEBUG, format=log_format)
base = os.path.dirname(os.path.abspath(__file__))
os.chdir(base)
player = get_player()
player.register_key_binding('q', q_binding)
update_playlist(args.playlist, args.prefix)
player.loadlist(args.playlist)
while True:
try:
player.wait_for_playback()
except:
sys.exit()
del player
2017-08-25 19:21:36 +00:00
2017-08-30 14:07:50 +00:00
if __name__ == '__main__':
main()