mirror of
https://github.com/SinTan1729/TvTimeToTrakt.git
synced 2025-04-19 17:40:01 -05:00
Extract menu selection to own function
This commit is contained in:
parent
ed627ad22a
commit
6f5f22f449
1 changed files with 15 additions and 10 deletions
|
@ -773,8 +773,7 @@ def process_movies():
|
||||||
f"({rows_count}/{rows_total}) - Already imported, skipping '{movie_name}'."
|
f"({rows_count}/{rows_total}) - Already imported, skipping '{movie_name}'."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def menu_selection() -> int:
|
||||||
def start():
|
|
||||||
# Display a menu selection
|
# Display a menu selection
|
||||||
print(">> What do you want to do?")
|
print(">> What do you want to do?")
|
||||||
print(" 1) Import Watch History for TV Shows from TV Time")
|
print(" 1) Import Watch History for TV Shows from TV Time")
|
||||||
|
@ -784,34 +783,40 @@ def start():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
menu_selection = input("Enter your menu selection: ")
|
selection = input("Enter your menu selection: ")
|
||||||
menu_selection = 3 if not menu_selection else int(menu_selection)
|
selection = 3 if not selection else int(selection)
|
||||||
break
|
break
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logging.warning("Invalid input. Please enter a numerical number.")
|
logging.warning("Invalid input. Please enter a numerical number.")
|
||||||
# Check if the input is valid
|
# Check if the input is valid
|
||||||
if not 1 <= menu_selection <= 4:
|
if not 1 <= selection <= 4:
|
||||||
logging.warning("Sorry - that's an unknown menu selection")
|
logging.warning("Sorry - that's an unknown menu selection")
|
||||||
exit()
|
exit()
|
||||||
# Exit if the 4th option was chosen
|
# Exit if the 4th option was chosen
|
||||||
if menu_selection == 4:
|
if selection == 4:
|
||||||
logging.info("Exiting as per user's selection.")
|
logging.info("Exiting as per user's selection.")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
return selection
|
||||||
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
selection = menu_selection()
|
||||||
# Create the initial authentication with Trakt, before starting the process
|
# Create the initial authentication with Trakt, before starting the process
|
||||||
if init_trakt_auth():
|
if init_trakt_auth():
|
||||||
# Start the process which is required
|
# Start the process which is required
|
||||||
if menu_selection == 1:
|
if selection == 1:
|
||||||
# Invoke the method which will import episodes which have been watched
|
# Invoke the method which will import episodes which have been watched
|
||||||
# from TV Time into Trakt
|
# from TV Time into Trakt
|
||||||
logging.info("Processing watched shows.")
|
logging.info("Processing watched shows.")
|
||||||
process_watched_shows()
|
process_watched_shows()
|
||||||
# TODO: Add support for followed shows
|
# TODO: Add support for followed shows
|
||||||
elif menu_selection == 2:
|
elif selection == 2:
|
||||||
# Invoke the method which will import movies which have been watched
|
# Invoke the method which will import movies which have been watched
|
||||||
# from TV Time into Trakt
|
# from TV Time into Trakt
|
||||||
logging.info("Processing movies.")
|
logging.info("Processing movies.")
|
||||||
process_movies()
|
process_movies()
|
||||||
elif menu_selection == 3:
|
elif selection == 3:
|
||||||
# Invoke both the episodes and movies import methods
|
# Invoke both the episodes and movies import methods
|
||||||
logging.info("Processing both watched shows and movies.")
|
logging.info("Processing both watched shows and movies.")
|
||||||
process_watched_shows()
|
process_watched_shows()
|
||||||
|
|
Loading…
Reference in a new issue