diff --git a/config_master.py.template b/config_master.py.template index ac01c5c..33b619d 100644 --- a/config_master.py.template +++ b/config_master.py.template @@ -4,6 +4,10 @@ Configuration settings for overwrought_master.py. `mc_ver` is used literally when searching for an appropriate verison of a mod to download. Should not include the minor version. `modpack_name` is used for vanity purposes when naming the modpack. +`password` is the password used for uploading to the remote server. +`remote_addr` is the address of the remote Overwrought server. """ mc_ver = "1.12" modpack_name = "motherlode1" +password = r"""PASSWORD""" +remote_addr = "https://stream.steelbea.me/overwrought" diff --git a/overwrought_master.py b/overwrought_master.py index 7067860..3f21ad2 100644 --- a/overwrought_master.py +++ b/overwrought_master.py @@ -4,7 +4,6 @@ A script for updating mods in a minecraft modpack. """ import os import re -import json import sqlite3 from datetime import datetime @@ -241,6 +240,36 @@ def generate_summary(): file.write(html) +def post_pack(): + """ + Uploads the modpack to the remote server. + """ + data = {'password': config_master.password} + + mods = get_all_mods() + res = requests.get(config_master.remote_addr + '/get') + res.raise_for_status() + mods_remote = res.json() + mods = [mod for mod in mods if mod.filename not in mods_remote] + files = {} + for mod in mods: + files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb') + files[config_master.modpack_name + '.html'] = open( + config_master.modpack_name, 'rb') + + res = requests.post( + url=config_master.remote_addr + '/post', + data=data, + files=files + ) + res.raise_for_status() + + for file in files.values(): + file.close() + + print('Success!') + + if __name__ == "__main__": import argparse @@ -250,7 +279,7 @@ if __name__ == "__main__": ) parser.add_argument( "action", - choices=["add", "add_all", "update", "update_all", "summary"], + choices=["add", "add_all", "update", "update_all", "summary", "post"], help="What action to perform.", ) parser.add_argument( @@ -284,3 +313,5 @@ if __name__ == "__main__": update_mod_all(args.delete) elif args.action == "summary": generate_summary() + elif args.action == "post": + post_pack()