Browse Source

added more arguments that can be used

master
sharky555 3 years ago
parent
commit
353e78beae
2 changed files with 50 additions and 16 deletions
  1. +47
    -15
      autoupload.py
  2. +3
    -1
      json_data/dictionary.json

+ 47
- 15
autoupload.py View File

@@ -35,12 +35,16 @@ def asciiart ():
# Get arguments using argparse # Get arguments using argparse
def getargs(): def getargs():
parser = argparse.ArgumentParser() 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("-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() return parser.parse_args()


# Acquire the authkey used for torrent files from upload.php # Acquire the authkey used for torrent files from upload.php
@@ -462,16 +466,21 @@ def gatherdata(directory):


# List of accepted upload types # List of accepted upload types
accepted_types = ['Album', 'Single', 'EP'] 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 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: if releasedata['type'] not in accepted_types:
while True: 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: if releasedata['type'] not in accepted_types:
continue continue
@@ -511,7 +520,10 @@ def gatherdata(directory):
print("Title/Artist Language:\n") print("Title/Artist Language:\n")
print(f"{releasedata['title']} < English = {en}") print(f"{releasedata['title']} < English = {en}")
if en == False: 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 # Create new key called title_jp and assign the old title to it
releasedata['title_jp'] = releasedata['title'] releasedata['title_jp'] = releasedata['title']
# Replace title with the user input. # Replace title with the user input.
@@ -521,11 +533,17 @@ def gatherdata(directory):
if debug: if debug:
print(f"{releasedata['idols[]']} < English = {en}") print(f"{releasedata['idols[]']} < English = {en}")
if en == False: 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(',')] input_english_artist = [x.strip() for x in input_english_artist.split(',')]
releasedata['idols[]'] = input_english_artist 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 != "": if input_english_contributing_artist != "":
input_english_contributing_artist = [x.strip() for x in input_english_contributing_artist.split(',')] input_english_contributing_artist = [x.strip() for x in input_english_contributing_artist.split(',')]
releasedata['contrib_artists[]'] = input_english_contributing_artist releasedata['contrib_artists[]'] = input_english_contributing_artist
@@ -659,7 +677,7 @@ if __name__ == "__main__":
args = getargs() args = getargs()


# TODO consider calling args[] directly, we will then not need this line # 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 directory = args.directory
additional_tags = args.tags additional_tags = args.tags
@@ -675,7 +693,21 @@ if __name__ == "__main__":


if args.imageURL: if args.imageURL:
imageURL = 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. # Load login credentials from JSON and use them to create a login session.
with open(f'json_data/config.json') as f: with open(f'json_data/config.json') as f:
cfg = json.load(f) cfg = json.load(f)


+ 3
- 1
json_data/dictionary.json View File

@@ -237,6 +237,8 @@
"緑黄色社会": null, "緑黄色社会": null,
"あるゆえ": null, "あるゆえ": null,
"宮下 遊": null, "宮下 遊": null,
"夢乃ゆき": null
"夢乃ゆき": null,
"女王蜂": null,
"夜の本気ダンス": null
} }
} }

Loading…
Cancel
Save