| @@ -11,9 +11,10 @@ import json |
| 11 | import random |
11 | import random |
| 12 | import subprocess |
12 | import subprocess |
| 13 | import time |
13 | import time |
| |
14 | import argparse |
| 14 | |
15 | |
| 15 | from anilist import search_anime_by_title |
16 | from anilist import search_anime_by_title |
| 16 | from anilist import get_user_data, get_anilist_user_id, update_anime_progress, rate_anime |
17 | from anilist import get_user_data, get_anilist_user_id, update_anime_progress, rate_anime, search_anime_anilist, add_anime_to_watching_list |
| 17 | from select_link import load_links |
18 | from select_link import load_links |
| 18 | from start_video import start_video, send_command, get_percentage_watched, percentage_watched, get_mpv_playback_speed |
19 | from start_video import start_video, send_command, get_percentage_watched, percentage_watched, get_mpv_playback_speed |
| 19 | from select_anime import load_anime_data |
20 | from select_anime import load_anime_data |
| @@ -24,17 +25,6 @@ from track_anime import add_anime, update_anime, get_all_anime, delete_anime, fi |
| 24 | |
25 | |
| 25 | mark_episode_as_completed_at = 85 |
26 | mark_episode_as_completed_at = 85 |
| 26 | |
27 | |
| 27 | access_token = os.environ.get('ANILIST_ACCESS_TOKEN') |
| |
| 28 | user_id, user_name = get_anilist_user_id(access_token) |
| |
| 29 | # user_id = os.environ.get('ANILIST_USER_ID') |
| |
| 30 | |
| |
| 31 | if access_token == None: |
| |
| 32 | print("No Access_token provided.") |
| |
| 33 | exit(1) |
| |
| 34 | |
| |
| 35 | # print(access_token) |
| |
| 36 | # print(user_id) |
| |
| 37 | |
| |
| 38 | def get_contents_of(tmp_file_name): |
28 | def get_contents_of(tmp_file_name): |
| 39 | with open(f"scripts/tmp/{tmp_file_name}", "r") as temp_file: |
29 | with open(f"scripts/tmp/{tmp_file_name}", "r") as temp_file: |
| 40 | return temp_file.read() |
30 | return temp_file.read() |
| @@ -80,8 +70,8 @@ default_config = { |
| 80 | "history_file":"$HOME/.local/share/curd/curd_history.txt", |
70 | "history_file":"$HOME/.local/share/curd/curd_history.txt", |
| 81 | "subs_language":"english", |
71 | "subs_language":"english", |
| 82 | "sub_or_dub":"sub", |
72 | "sub_or_dub":"sub", |
| 83 | "next_episode_prompt":False, |
73 | "next_episode_prompt": False, |
| 84 | "score_on_completion":False, |
74 | "score_on_completion": True, |
| 85 | "save_mpv_speed": True, |
75 | "save_mpv_speed": True, |
| 86 | "discord_presence": True, |
76 | "discord_presence": True, |
| 87 | "presence_script_path":"curddiscordpresence.py" |
77 | "presence_script_path":"curddiscordpresence.py" |
| @@ -169,6 +159,27 @@ def load_config() -> dict: |
| 169 | # return config_file.read() |
159 | # return config_file.read() |
| 170 | |
160 | |
| 171 | # START OF SCRIPT |
161 | # START OF SCRIPT |
| |
162 | access_token = os.environ.get('ANILIST_ACCESS_TOKEN') |
| |
163 | |
| |
164 | parser = argparse.ArgumentParser(description="Print a greeting message.") |
| |
165 | # parser.add_argument("--name", type=str, required=True, help="Your name") |
| |
166 | parser.add_argument("-new", action='store_true', help="Add new anime to watching (optional)") |
| |
167 | args = parser.parse_args() |
| |
168 | |
| |
169 | if args.new: |
| |
170 | new_anime_name_ = input("Enter anime name: ") |
| |
171 | temp__ = search_anime_anilist(new_anime_name_, access_token) |
| |
172 | if temp__ : |
| |
173 | select_anime(temp__) |
| |
174 | add_anime_to_watching_list(read_tmp('id'), access_token) |
| |
175 | else: |
| |
176 | print("No anime found") |
| |
177 | |
| |
178 | user_id, user_name = get_anilist_user_id(access_token) |
| |
179 | |
| |
180 | if access_token == None: |
| |
181 | print("No Access_token provided.") |
| |
182 | exit(1) |
| 172 | |
183 | |
| 173 | user_config = load_config() # python dictionary containing all the configs as key value pairs |
184 | user_config = load_config() # python dictionary containing all the configs as key value pairs |
| 174 | anilist_user_data = download_anilist_data(access_token, user_id) |
185 | anilist_user_data = download_anilist_data(access_token, user_id) |