1
0
mirror of https://github.com/obskyr/khinsider.git synced 2025-02-06 05:48:45 +01:00

Only display search error message if it's really an error.

This commit is contained in:
obskyr 2022-05-09 01:44:19 +02:00
parent a204bf860f
commit 34c630a74c

View File

@ -496,6 +496,8 @@ if __name__ == '__main__':
import argparse import argparse
SCRIPT_NAME = os.path.split(sys.argv[0])[-1] SCRIPT_NAME = os.path.split(sys.argv[0])[-1]
REPORT_STR = ("If it isn't too much to ask, please report to "
"https://github.com/obskyr/khinsider/issues.")
# Tiny details! # Tiny details!
class KindArgumentParser(argparse.ArgumentParser): class KindArgumentParser(argparse.ArgumentParser):
@ -587,7 +589,11 @@ if __name__ == '__main__':
try: try:
searchResults = search(searchTerm) searchResults = search(searchTerm)
except SearchError as e: except SearchError as e:
print("Couldn't search. {}".format(e.args[0]), file=sys.stderr) if re.match(r"^Found [0-9]+ matching albums.$", e.args[0]):
errorStr = "Couldn't search! {}".format(REPORT_STR)
else:
errorStr = "Couldn't search. {}".format(e.args[0])
print(errorStr, file=sys.stderr)
else: else:
if searchResults: if searchResults:
print("Soundtracks found (to download, " print("Soundtracks found (to download, "
@ -642,9 +648,7 @@ if __name__ == '__main__':
return 1 return 1
except Exception: except Exception:
print(file=sys.stderr) print(file=sys.stderr)
print("An unexpected error occurred! " print("An unexpected error occurred! " + REPORT_STR,
"If it isn't too much to ask, please report to "
"https://github.com/obskyr/khinsider/issues.",
file=sys.stderr) file=sys.stderr)
print("Attach the following error message:", file=sys.stderr) print("Attach the following error message:", file=sys.stderr)
print(file=sys.stderr) print(file=sys.stderr)