Commit 808a08fa67
Unsigned
Layout: unified · split
curd.py +12 −9
| @@ -219,6 +219,7 @@ anime_watch_history = get_all_anime(user_config['history_file']) | ||
| 219 | 219 | # anime_watch_history[] |
| 220 | 220 | anime_history = find_anime(anime_watch_history, anilist_id=media_id, allanime_id=get_contents_of("id")) |
| 221 | 221 | episode_completed = False |
| 222 | rewatching = False | |
| 222 | 223 | if anime_history: # if it exists in local history |
| 223 | 224 | # print(f"came in history {str(progress)}") |
| 224 | 225 | if int(anime_history['episode']) != progress+1: # if the upstream progress is ahead |
| @@ -234,14 +235,11 @@ if anime_history: # if it exists in local history | ||
| 234 | 235 | |
| 235 | 236 | watching_ep = int(anime_history['episode']) |
| 236 | 237 | else: # if there is no history |
| 237 | # print("no history found") | |
| 238 | ||
| 239 | # print("First time watch") | |
| 240 | ||
| 241 | 238 | if progress == last_episode: |
| 242 | 239 | user_input = input("Do you want to start this anime from beginning? (y/n):") |
| 243 | 240 | if user_input.lower() == "yes" or user_input.lower() == "y" or user_input.lower() == "": |
| 244 | 241 | progress = 0 |
| 242 | rewatching = True | |
| 245 | 243 | else: |
| 246 | 244 | print("Starting last episode of anime") |
| 247 | 245 | progress = last_episode - 1 |
| @@ -353,7 +351,7 @@ while True: | ||
| 353 | 351 | # print("have a great") |
| 354 | 352 | # exit(0) |
| 355 | 353 | except KeyboardInterrupt: |
| 356 | if watched_percentage > mark_episode_as_completed_at: | |
| 354 | if watched_percentage > mark_episode_as_completed_at and not rewatching: | |
| 357 | 355 | update_anime_progress(access_token, int(media_id), int(watching_ep)) |
| 358 | 356 | watching_ep = int(watching_ep)+1 |
| 359 | 357 | update_anime(user_config['history_file'], str(media_id), str(get_contents_of("id")), str(watching_ep), "0", str(duration), str(title)) |
| @@ -367,19 +365,24 @@ while True: | ||
| 367 | 365 | current_ep = int(read_tmp("ep_no")) |
| 368 | 366 | |
| 369 | 367 | if current_ep == last_episode: |
| 368 | if binge_watching == True and not rewatching and user_config['score_on_completion'] == True: # Completed anime | |
| 369 | anime_rating_by_user = input("Rate this anime:\n") | |
| 370 | update_anime_progress(access_token, int(media_id), int(watching_ep)) | |
| 371 | rate_anime(access_token, media_id, anime_rating_by_user) | |
| 370 | 372 | print("completed anime.") |
| 371 | 373 | # TODO: Add way to rate the anime |
| 372 | 374 | delete_anime(user_config['history_file'], media_id, get_contents_of("id")) |
| 373 | 375 | exit(0) |
| 374 | 376 | |
| 375 | 377 | else: |
| 376 | print(f"Next episode is here, goshujin sama progress: {current_ep} {type(current_ep)}") | |
| 378 | print(f"Starting next episode: {current_ep}") | |
| 377 | 379 | # write_to_tmp("ep_no", str(int(current_ep)+1)) |
| 378 | 380 | |
| 379 | if watched_percentage > mark_episode_as_completed_at: # BINGE WATCHING | |
| 381 | if watched_percentage > mark_episode_as_completed_at: # IF BINGE WATCHING | |
| 380 | 382 | last_episode = int(read_tmp("episode_list").split()[-1]) |
| 381 | update_anime_progress(access_token, int(media_id), int(watching_ep)) | |
| 382 | ||
| 383 | if not rewatching: | |
| 384 | update_anime_progress(access_token, int(media_id), int(watching_ep)) | |
| 385 | else: | |
| 383 | 386 | watching_ep = int(watching_ep)+1 |
| 384 | 387 | write_to_tmp("ep_no", str(watching_ep)) |
| 385 | 388 | update_anime(user_config['history_file'], str(media_id), str(get_contents_of("id")), str(watching_ep), "0", str(duration), str(title)) |