cdosea-play/cdoseaplay/play.py
2017-10-04 13:02:13 +02:00

57 lines
1.5 KiB
Python
Executable file

#!/usr/bin/python3
import argparse
from glob import glob
import os
import sys
from .utils import update_playlist, get_player
from .subtitleserver import SubtitleServer
import logging
logger = logging.getLogger('cdosea')
player = None
def q_binding(*args):
global player
player.quit()
del player
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)
sub = SubtitleServer(player, args.playlist)
player.loadlist(args.playlist)
while True:
try:
player.wait_for_playback()
except:
sys.exit()
del player
sub.join()
if __name__ == '__main__':
main()