Commit 7755d54716
Unsigned
Layout: unified · split
curd.py +59 −3
| @@ -25,6 +25,41 @@ import urllib.parse | |||
| 25 | 25 | ||
| 26 | discord_client_id = "1287457464148820089" | 26 | discord_client_id = "1287457464148820089" |
| 27 | 27 | ||
| 28 | |||
| 29 | # ----------------------------------------------- Jikan Functions ---------------------------------------- | ||
| 30 | |||
| 31 | def get_episode_data(anime_id: int, episode_no: int): | ||
| 32 | url = f"https://api.jikan.moe/v4/anime/{anime_id}/episodes/{episode_no}" | ||
| 33 | try: | ||
| 34 | response = requests.get(url) | ||
| 35 | response.raise_for_status() | ||
| 36 | json_data = json.loads(response.text) | ||
| 37 | return json_data['data'] | ||
| 38 | except requests.RequestException as e: | ||
| 39 | print(f"Error fetching data from Jikan (MyAnimeList) API: {e}") | ||
| 40 | return None | ||
| 41 | except Exception as e: | ||
| 42 | print(f"Error: ", e) | ||
| 43 | return None | ||
| 44 | |||
| 45 | # response.text : { | ||
| 46 | # "data": { | ||
| 47 | # "mal_id": 0, | ||
| 48 | # "url": "string", | ||
| 49 | # "title": "string", | ||
| 50 | # "title_japanese": "string", | ||
| 51 | # "title_romanji": "string", | ||
| 52 | # "duration": 0, | ||
| 53 | # "aired": "string", | ||
| 54 | # "filler": true, | ||
| 55 | # "recap": true, | ||
| 56 | # "synopsis": "string" | ||
| 57 | # } | ||
| 58 | # } | ||
| 59 | |||
| 60 | # response = get_episode_data(21, 5) | ||
| 61 | # print(response['title']) | ||
| 62 | # exit(0) | ||
| 28 | # ----------------------------------------------- AniSkip Functions ---------------------------------------- | 63 | # ----------------------------------------------- AniSkip Functions ---------------------------------------- |
| 29 | 64 | ||
| 30 | def get_aniskip_data(anime_id, episode): | 65 | def get_aniskip_data(anime_id, episode): |
| @@ -867,6 +902,8 @@ default_config = { | |||
| 867 | "next_episode_prompt": False, | 902 | "next_episode_prompt": False, |
| 868 | "skip_op": True, | 903 | "skip_op": True, |
| 869 | "skip_ed": True, | 904 | "skip_ed": True, |
| 905 | "skip_filler": True, | ||
| 906 | "skip_recap": True, | ||
| 870 | "score_on_completion": True, | 907 | "score_on_completion": True, |
| 871 | "save_mpv_speed": True, | 908 | "save_mpv_speed": True, |
| 872 | "discord_presence": False, | 909 | "discord_presence": False, |
| @@ -1404,8 +1441,26 @@ try: | |||
| 1404 | except KeyboardInterrupt: | 1441 | except KeyboardInterrupt: |
| 1405 | print("bye") | 1442 | print("bye") |
| 1406 | exit(0) | 1443 | exit(0) |
| 1407 | while True: | 1444 | while True: # loop for each episode |
| 1408 | try: | 1445 | try: |
| 1446 | |||
| 1447 | skip_filler = get_userconfig_value(user_config, "skip_filler") | ||
| 1448 | skip_recap = get_userconfig_value(user_config, "skip_recap") | ||
| 1449 | |||
| 1450 | if skip_filler == True or skip_recap == True: | ||
| 1451 | episode_data = get_episode_data(anime_mal_id, watching_ep) | ||
| 1452 | if episode_data: | ||
| 1453 | # print(episode_data) | ||
| 1454 | is_filler = episode_data['filler'] | ||
| 1455 | is_recap = episode_data['recap'] | ||
| 1456 | if skip_filler and is_filler or skip_recap and is_recap and not rewatching: | ||
| 1457 | print("starting next.") | ||
| 1458 | watched_percentage = 95 | ||
| 1459 | raise Exception("Filler or Recap Episode. Starting next episode.") | ||
| 1460 | |||
| 1461 | else: | ||
| 1462 | print("Error fetching episode details") | ||
| 1463 | |||
| 1409 | salt = random.randint(0,1500) | 1464 | salt = random.randint(0,1500) |
| 1410 | # print("SALT IS:"+str(salt)) | 1465 | # print("SALT IS:"+str(salt)) |
| 1411 | start_video(links[0][1], salt, mpv_args) | 1466 | start_video(links[0][1], salt, mpv_args) |
| @@ -1416,7 +1471,7 @@ while True: | |||
| 1416 | if skip_intervals == None: | 1471 | if skip_intervals == None: |
| 1417 | print("failed to get skip times") | 1472 | print("failed to get skip times") |
| 1418 | 1473 | ||
| 1419 | while True: | 1474 | while True: # loop while episode is being watched |
| 1420 | # Example usage | 1475 | # Example usage |
| 1421 | # anime_id = 28223 | 1476 | # anime_id = 28223 |
| 1422 | # episode = 10 | 1477 | # episode = 10 |
| @@ -1434,7 +1489,6 @@ while True: | |||
| 1434 | playback_time = round(int(data["data"]), 2) | 1489 | playback_time = round(int(data["data"]), 2) |
| 1435 | if get_userconfig_value(user_config, "discord_presence") == True: | 1490 | if get_userconfig_value(user_config, "discord_presence") == True: |
| 1436 | is_paused = get_mpv_paused_status(mpv_socket_path) | 1491 | is_paused = get_mpv_paused_status(mpv_socket_path) |
| 1437 | |||
| 1438 | 1492 | ||
| 1439 | # print("mpv_status", mpv_status) | 1493 | # print("mpv_status", mpv_status) |
| 1440 | # print("is_paused", is_paused) | 1494 | # print("is_paused", is_paused) |
| @@ -1532,6 +1586,8 @@ while True: | |||
| 1532 | 1586 | ||
| 1533 | print("bye") | 1587 | print("bye") |
| 1534 | exit(0) | 1588 | exit(0) |
| 1589 | except Exception as e: | ||
| 1590 | print(e) | ||
| 1535 | finally: | 1591 | finally: |
| 1536 | binge_watching=True | 1592 | binge_watching=True |
| 1537 | 1593 | ||