from simple_term_menu import TerminalMenu from database import Database from time import sleep import os, subprocess def _play(url: str, database: Database): start_pos = 0 viewing_data = database.get_viewing_data(url) if (viewing_data != None): menu = TerminalMenu([f"go back to {str(viewing_data.get('last_pos'))}", "restart from 0:00"]) response = menu.show() if (response == None): return (1); elif (response == 0): start_pos = viewing_data.get("last_pos") vlc_instance = vlc.Instance() player = vlc_instance.media_player_new() media = vlc_instance.media_new(url) player.set_media(media) player.play() sleep(1) player.video_set_mouse_input(True) player.set_position(start_pos / player.get_length()) player.set_fullscreen(True) while True: print("duration:", player.get_time(),":",player.get_length()) def play(url: str, database: Database): with open(os.devnull, 'wb') as devnull: subprocess.check_call(['vlc', url], stdout=devnull, stderr=subprocess.STDOUT)