2023-05-16 16:33:36 -04:00
|
|
|
from simple_term_menu import TerminalMenu
|
|
|
|
from database import Database
|
2023-05-16 17:25:05 -04:00
|
|
|
from time import sleep
|
|
|
|
import os, subprocess
|
2023-05-16 16:33:36 -04:00
|
|
|
|
2023-05-16 17:25:05 -04:00
|
|
|
def _play(url: str, database: Database):
|
2023-05-16 16:33:36 -04:00
|
|
|
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()
|
2023-05-16 17:25:05 -04:00
|
|
|
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)
|
|
|
|
|