Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Added a retry mechanism for user inputs and improved the prompt when …
Browse files Browse the repository at this point in the history
…an input format is incorrect.
  • Loading branch information
sqkkyzx committed Feb 29, 2024
1 parent 995edda commit f945d5e
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/plex_localization_zhcn.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions plex_localization_zhcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ def select_library(self, index=None):

echo = [f"{library[0]}> {library[2]} <{library[3]}>" for library in libraries.values()]

index = index if index else int(input("\n" + "\n".join(echo) + "\n请选择库:"))
if index:
pass
else:
while True:
try:
index = int(input("\n" + "\n".join(echo) + "\n请选择库:"))
break
except ValueError:
print("格式不正确,需要输入整数数字。")

action_key, action_type = index, libraries[index][1]

Expand Down Expand Up @@ -211,9 +219,16 @@ def operate_item(self, rating_key):

def loop_all(self, library_id: int = None, thread_count: int = None):
"""选择媒体库并遍历其中的每一个媒体。"""
if not thread_count:
thread_count = input("\n请输入运行的线程数(输入整数数字,默认为2):")
thread_count = int(thread_count if thread_count else 2)

if thread_count:
pass
else:
while True:
try:
thread_count = int(input("\n请输入运行的线程数(输入整数数字,默认为2):"))
break
except ValueError:
print("格式不正确,需要输入整数数字。")

if library_id == 999:
libraries = self.list_libraries().values()
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pypinyin>=0.50.0
requests>=2.31.0

0 comments on commit f945d5e

Please sign in to comment.