Commit b27e4c78e8

b27e4c78e80fdd8be0d98c33db90400a7367b9a3

parent: a63ccd5936

Unsigned

Wraient <wraient.911@gmail.com> · 2024-09-03 20:56 UTC

find watched percentage

Layout: unified · split

curd.py +17 −2
@@ -14,7 +14,7 @@ import time
1414from anilist import search_anime_by_title
1515from anilist import get_user_data
1616from select_link import load_links
17from start_video import *
17from start_video import start_video, send_command, get_percentage_watched
1818from select_anime import load_anime_data
1919from select_anime import extract_anime_info
2020from select_anime import select_anime
@@ -273,7 +273,15 @@ while True:
273273 salt = random.randint(0,1500)
274274 print("SALT IS:"+str(salt))
275275 start_video(links[0][1], salt, mpv_args)
276 connect_mpv_command = """echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpvsocket"""+str(salt)
276
277 mpv_socket_path = "/tmp/mpvsocket"+str(salt)
278
279 connect_mpv_command = """echo '{ "command": ["get_property", "playback-time"] }' | socat - """+mpv_socket_path
280
281 mpv_pos_command = """echo '{ "command": ["get_property", "time-pos"] }' | socat - """+mpv_socket_path
282
283 mpv_duration_command = """echo '{ "command": ["get_property", "duration"] }' | socat - """+mpv_socket_path
284
277285
278286 while True:
279287 time.sleep(2)
@@ -294,6 +302,13 @@ while True:
294302
295303 update_anime(user_config['history_file'], str(anime_id), str(get_contents_of("id")), str(watching_ep), str(playback_time), str(title))
296304 print("Playback time:", playback_time)
305
306 watched_percentage = get_percentage_watched(mpv_socket_path)
307 print(watched_percentage)
308 if watched_percentage > 85:
309 print("Completed")
310 # video_duration = subprocess.run(mpv_duration_command, shell=True, capture_output=True, text=True)
311
297312 else:
298313 if data['error'] == "property unavailable":
299314 pass