diff --git a/autoupload.py b/autoupload.py index 9eb0d6a..04965eb 100644 --- a/autoupload.py +++ b/autoupload.py @@ -36,18 +36,19 @@ def asciiart (): 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("-f", "--freeleech", help="Enables freeleech.", action="store_true") parser.add_argument("-t", "--tags", help="Add additional tags to the upload.", nargs='?') parser.add_argument('-n', '--debug', help='Enable debug mode.', action='store_true') parser.add_argument("-d", "--dryrun", help="Dryrun will carry out all actions other than the actual upload to JPS.", action="store_true") parser.add_argument("-im", "--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("-rt", "--releasetype", help='Set the release type. (Album, Single, EP)', nargs='?') parser.add_argument("-ti", "--title", help='Set the title. (Romaji\English)', nargs='?') parser.add_argument("-eti", "--editiontitle", help='Set the edition title', nargs='?') parser.add_argument("-ey", "--editionyear", help='Set the torrent edition year (YYYYMMDD or YYYY).', nargs='?') - parser.add_argument("-ms", "--mediasource", help='Set the media source.', nargs='?') + parser.add_argument("-ms", "--mediasource", help='Set the media source. (CD, Web, Vinyl)', nargs='?') + parser.add_argument("-tdes", "--torrentdescription", help='Add a torrent description', nargs='?') return parser.parse_args() # Acquire the authkey used for torrent files from upload.php @@ -483,35 +484,54 @@ def gatherdata(directory): # POST values can be found by inspecting JPS HTML releasedata['submit'] = 'true' - # List of accepted upload types + # # List of accepted upload types + # accepted_types = ['Album', 'Single', 'EP'] + # # 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 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 + # else: + # break + # # SM uses numbers for it's types + # if releasedata['type'] == "Album": + # releasedata['type'] = 0 + # elif releasedata['type'] == "Single": + # releasedata['type'] = 2 + # else: # EP type + # releasedata['type'] = 1 accepted_types = ['Album', 'Single', 'EP'] - # 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 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 - else: - break - # SM uses numbers for it's types - if releasedata['type'] == "Album": - releasedata['type'] = 0 - elif releasedata['type'] == "Single": - releasedata['type'] = 2 - else: # EP type - releasedata['type'] = 1 + if releasetype: + releasedata['type'] = releasetype + else: + while(True): + input_releasetype = input("\n" + "_" * 100 + "\nEnter a number to choose the release type. \n1=Album\n2=Single\n3=EP\n") + if input_releasetype == "1": + releasedata["type"] = "Album" + break + elif input_releasetype == "2": + releasedata["type"] = "Single" + break + elif input_releasetype == "3": + releasedata["type"] = "EP" + break + print("Invalid choice.") + else: + releasedata['type'] = releasetype releasedata['title'] = tags['ALBUM'][0] releasedata['idols[]'] = unique_album_artists @@ -542,7 +562,7 @@ def gatherdata(directory): if title: input_english_title = title else: - input_english_title = input("\n" + "_" * 100 + "\nKorean/Japanese Detected. Please enter the romaji/english title:\n") + input_english_title = input("\n" + "_" * 100 + "\nPlease 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. @@ -555,14 +575,14 @@ def gatherdata(directory): 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 = input("\n" + "_" * 100 + "\nPlease enter the romaji/english artist name. Separate multiple main artists with \",\".\n") input_english_artist = [x.strip() for x in input_english_artist.split(',')] releasedata['idols[]'] = input_english_artist 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") + input_english_contributing_artist = input("\n" + "_" * 100 + "\nPlease enter the romaji/english artist name. Separate multiple contributing artists with \",\". Press enter to skip.\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 @@ -735,7 +755,7 @@ if __name__ == "__main__": cfg = json.load(f) # TODO consider calling args[] directly, we will then not need this line - dryrun = freeleech = tags = directory = debug = imageURL = artists = contributingartists = releasetype = title = editiontitle = editionyear = mediasource = audio_info = None + dryrun = torrentdescription = freeleech = tags = directory = debug = imageURL = artists = contributingartists = releasetype = title = editiontitle = editionyear = mediasource = audio_info = None directory = args.directory additional_tags = args.tags @@ -746,8 +766,10 @@ if __name__ == "__main__": if args.debug: debug = True - if args.freeleech: - freeleech = True + # if args.freeleech: + # freeleech = True + if torrentdescription: + torrentdescription = args.torrentdescription if args.imageURL: imageURL = args.imageURL diff --git a/copycommand.txt b/copycommand.txt new file mode 100644 index 0000000..89297a5 --- /dev/null +++ b/copycommand.txt @@ -0,0 +1 @@ +python autoupload.py --releasetype "Single" --artists "" -ti "title" --tags "" -dir "C:\full path of the upload" -imageURL "some cover image url" \ No newline at end of file