diff --git a/autoupload.py b/autoupload.py index 1cb773f..44f07ce 100644 --- a/autoupload.py +++ b/autoupload.py @@ -35,12 +35,16 @@ def asciiart (): # Get arguments using argparse def getargs(): parser = argparse.ArgumentParser() - parser.add_argument('-dir', '--directory', help='Initiate upload on directory', nargs='?', required=True) - parser.add_argument("-f", "--freeleech", help="Enables freeleech", action="store_true") - parser.add_argument("-t", "--tags", help="Add additional tags to the upload", nargs='?') - parser.add_argument('-d', '--debug', help='Enable debug mode', action='store_true') + parser.add_argument('-dir', '--directory', help='Initiate upload on directory.', nargs='?', required=True) + parser.add_argument("-f", "--freeleech", help="Enables freeleech.", action="store_true") + parser.add_argument("-t", "--tags", help="Add additional tags to the upload.", nargs='?') + parser.add_argument('-d', '--debug', help='Enable debug mode.', action='store_true') parser.add_argument("-dry", "--dryrun", help="Dryrun will carry out all actions other than the actual upload to JPS.", action="store_true") - parser.add_argument("-i", "--imageURL", help='Set the torrent cover URL', nargs='?') + parser.add_argument("-i", "--imageURL", help='Set the torrent cover URL.', nargs='?') + parser.add_argument("-a", "--artists", help='Set the artists. (Romaji\English)', nargs='?') + parser.add_argument("-ca", "--contributingartists", help='Set the contributing artists. (Romaji\English)', nargs='?') + parser.add_argument("-rt", "--releasetype", help='Set the release type.', nargs='?') + parser.add_argument("-ti", "--title", help='Set the title. (Romaji\English)', nargs='?') return parser.parse_args() # Acquire the authkey used for torrent files from upload.php @@ -462,16 +466,21 @@ def gatherdata(directory): # List of accepted upload types accepted_types = ['Album', 'Single', 'EP'] - # If type errors then we ask for user input - try: - releasedata['type'] = translate(tags['GROUPING'][0], "release_types")[0] - except TypeError: - releasedata['type'] = input("\n" + "_" * 100 + "\nGrouping is empty or has received an error, please enter manually (Album/Single/EP)\n") + # Get type from args if present + if releasetype: + releasedata['type'] = releasetype + else: + # If type errors then we ask for user input + try: + releasedata['type'] = translate(tags['GROUPING'][0], "release_types")[0] + except TypeError: + releasedata['type'] = input("\n" + "_" * 100 + "\nGrouping is empty or has received an error, please enter manually (Album/Single/EP)\n") + # If type is still not in accepted_types we ask for user input again and do not break loop until correct if releasedata['type'] not in accepted_types: while True: - releasedata['type'] = input("\n" + "_" * 100 + "\nGrouping tag did not return an album type, please enter manually (Album/Single/EP)\n") + releasedata['type'] = input("\n" + "_" * 100 + "\nGrouping tag or release type argument did not return an album type, please enter manually (Album/Single/EP)\n") if releasedata['type'] not in accepted_types: continue @@ -511,7 +520,10 @@ def gatherdata(directory): print("Title/Artist Language:\n") print(f"{releasedata['title']} < English = {en}") if en == False: - input_english_title = input("\n" + "_" * 100 + "\nKorean/Japanese Detected. Please enter the romaji/english title:\n") + if title: + input_english_title = title + else: + input_english_title = input("\n" + "_" * 100 + "\nKorean/Japanese Detected. Please enter the romaji/english title:\n") # Create new key called title_jp and assign the old title to it releasedata['title_jp'] = releasedata['title'] # Replace title with the user input. @@ -521,11 +533,17 @@ def gatherdata(directory): if debug: print(f"{releasedata['idols[]']} < English = {en}") if en == False: - input_english_artist = input("\n" + "_" * 100 + "\nKorean/Japanese Detected. Separate multiple main artists with \",\". Please enter the romaji/english artist name:\n") + if artists: + input_english_artist = artists + else: + input_english_artist = input("\n" + "_" * 100 + "\nKorean/Japanese Detected. Separate multiple main artists with \",\". Please enter the romaji/english artist name:\n") input_english_artist = [x.strip() for x in input_english_artist.split(',')] releasedata['idols[]'] = input_english_artist - input_english_contributing_artist = input("\n" + "_" * 100 + "\nSeparate multiple contributing artists with \",\". Press enter to skip. Please enter the romaji/english artist name:\n") + if contributingartists: + input_english_contributing_artist = contributingartists + else: + input_english_contributing_artist = input("\n" + "_" * 100 + "\nSeparate multiple contributing artists with \",\". Press enter to skip. Please enter the romaji/english artist name:\n") if input_english_contributing_artist != "": input_english_contributing_artist = [x.strip() for x in input_english_contributing_artist.split(',')] releasedata['contrib_artists[]'] = input_english_contributing_artist @@ -659,7 +677,7 @@ if __name__ == "__main__": args = getargs() # TODO consider calling args[] directly, we will then not need this line - dryrun = freeleech = tags = directory = debug = imageURL = None + dryrun = freeleech = tags = directory = debug = imageURL = artists = contributingartists = releasetype = title = None directory = args.directory additional_tags = args.tags @@ -675,7 +693,21 @@ if __name__ == "__main__": if args.imageURL: imageURL = args.imageURL + + if args.releasetype: + releasetype = args.releasetype + + if args.title: + title = args.title + + if args.artists: + artists = args.artists + + if args.contributingartists: + contributingartists = args.contributingartists + + # Load login credentials from JSON and use them to create a login session. with open(f'json_data/config.json') as f: cfg = json.load(f) diff --git a/json_data/dictionary.json b/json_data/dictionary.json index ab6e1d9..3f08008 100644 --- a/json_data/dictionary.json +++ b/json_data/dictionary.json @@ -237,6 +237,8 @@ "緑黄色社会": null, "あるゆえ": null, "宮下 遊": null, - "夢乃ゆき": null + "夢乃ゆき": null, + "女王蜂": null, + "夜の本気ダンス": null } } \ No newline at end of file