Commit b27e4c78e8
Unsigned
Layout: unified · split
curd.py +17 −2
| @@ -14,7 +14,7 @@ import time | |||
| 14 | from anilist import search_anime_by_title | 14 | from anilist import search_anime_by_title |
| 15 | from anilist import get_user_data | 15 | from anilist import get_user_data |
| 16 | from select_link import load_links | 16 | from select_link import load_links |
| 17 | from start_video import * | 17 | from start_video import start_video, send_command, get_percentage_watched |
| 18 | from select_anime import load_anime_data | 18 | from select_anime import load_anime_data |
| 19 | from select_anime import extract_anime_info | 19 | from select_anime import extract_anime_info |
| 20 | from select_anime import select_anime | 20 | from select_anime import select_anime |
| @@ -273,7 +273,15 @@ while True: | |||
| 273 | salt = random.randint(0,1500) | 273 | salt = random.randint(0,1500) |
| 274 | print("SALT IS:"+str(salt)) | 274 | print("SALT IS:"+str(salt)) |
| 275 | start_video(links[0][1], salt, mpv_args) | 275 | 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 | |||
| 277 | 285 | ||
| 278 | while True: | 286 | while True: |
| 279 | time.sleep(2) | 287 | time.sleep(2) |
| @@ -294,6 +302,13 @@ while True: | |||
| 294 | 302 | ||
| 295 | update_anime(user_config['history_file'], str(anime_id), str(get_contents_of("id")), str(watching_ep), str(playback_time), str(title)) | 303 | update_anime(user_config['history_file'], str(anime_id), str(get_contents_of("id")), str(watching_ep), str(playback_time), str(title)) |
| 296 | print("Playback time:", playback_time) | 304 | 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 | |||
| 297 | else: | 312 | else: |
| 298 | if data['error'] == "property unavailable": | 313 | if data['error'] == "property unavailable": |
| 299 | pass | 314 | pass |