add title, option to play from a and restart
This commit is contained in:
parent
40472ec6f9
commit
3529e01aba
3 changed files with 40 additions and 24 deletions
|
@ -28,6 +28,7 @@ def main():
|
|||
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)
|
||||
parser.add_argument('-a', '--always-a', action='store_true', help='start from A', default=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
DEBUG = args.debug
|
||||
|
@ -40,9 +41,17 @@ def main():
|
|||
player = get_player()
|
||||
player.register_key_binding('q', q_binding)
|
||||
|
||||
update_playlist(args.playlist, args.prefix)
|
||||
def restart(*a):
|
||||
update_playlist(args.playlist, args.prefix, shift=False)
|
||||
player.loadlist(args.playlist)
|
||||
player.pause = True
|
||||
player.register_key_binding('r', restart)
|
||||
|
||||
update_playlist(args.playlist, args.prefix, shift=not args.always_a)
|
||||
sub = SubtitleServer(player, args.playlist)
|
||||
player.loadlist(args.playlist)
|
||||
if args.always_a:
|
||||
player.pause = True
|
||||
|
||||
while True:
|
||||
try:
|
||||
|
|
BIN
cdoseaplay/static/title.png
Normal file
BIN
cdoseaplay/static/title.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
|
@ -11,11 +11,16 @@ import ox
|
|||
from . import mpv
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger('cdosea')
|
||||
STATIC_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'static')
|
||||
|
||||
|
||||
def mpv_log(loglevel, component, message):
|
||||
logger.info('[{}] {}: {}'.format(loglevel, component, message))
|
||||
|
||||
|
||||
def get_player(fullscreen=True):
|
||||
# 42 max
|
||||
player = mpv.MPV(
|
||||
|
@ -26,16 +31,18 @@ def get_player(fullscreen=True):
|
|||
player.fullscreen = fullscreen
|
||||
player.loop = 'inf'
|
||||
player.loop_file = 'no'
|
||||
|
||||
|
||||
return player
|
||||
|
||||
def update_playlist(playlist, prefix, position=None):
|
||||
|
||||
def update_playlist(playlist, prefix, position=None, shift=True):
|
||||
|
||||
files = []
|
||||
videos = {}
|
||||
if not prefix.endswith('/'):
|
||||
prefix += '/'
|
||||
|
||||
if not shift:
|
||||
files.append(os.path.join(STATIC_ROOT, 'title.png'))
|
||||
for letter in string.ascii_uppercase:
|
||||
videos[letter] = glob('%s%s*.mp4' % (prefix, letter.lower()))
|
||||
random.shuffle(videos[letter])
|
||||
|
@ -44,6 +51,7 @@ def update_playlist(playlist, prefix, position=None):
|
|||
for letter in string.ascii_uppercase:
|
||||
files.append(videos[letter][i])
|
||||
|
||||
if shift:
|
||||
if position is None:
|
||||
today = datetime.date.today()
|
||||
seconds_since_midnight = time.time() - time.mktime(today.timetuple())
|
||||
|
@ -70,4 +78,3 @@ def update_playlist(playlist, prefix, position=None):
|
|||
f.write('\n'.join(files))
|
||||
f.write('\n')
|
||||
return position, len(files)
|
||||
|
||||
|
|
Loading…
Reference in a new issue