Skip to content

Instantly share code, notes, and snippets.

@treeherder
Last active December 2, 2020 20:44
Show Gist options
  • Save treeherder/f909dcab32dc20643c77a71716a65746 to your computer and use it in GitHub Desktop.
Save treeherder/f909dcab32dc20643c77a71716a65746 to your computer and use it in GitHub Desktop.
first draft of a tool for working on steam workshop mods without having to sort through them by hand.
import glob, argparse, re
from collections import Counter
from pathlib import Path
class Mod_Checker:
def __init__(self):
arg_par = argparse.ArgumentParser(description='Print the names and corresponding file paths for mods in your workshop folder.')
arg_par.add_argument('path', metavar='P', type=str,
help='The filepath of the desired workshop folder.')
arg_par.add_argument('--name', dest='term', type=str, help='Search mods by name or partial match.')
arg_par.add_argument('--server', dest='dest_path', type=str, help='The directory where the dayz server runs.')
self.args = arg_par.parse_args()
realpath = Path(self.args.path)
self.metafiles = realpath.glob('**/meta.cpp')
self.list_of_mods = []
def search_mod_names_and_IDs(self):
for metafile in self.metafiles:
with open(str.format('{0}', metafile)) as metacpp:
lines = metacpp.readlines()
workshop_ID = lines[1].split(';')[0].split('=')[-1]
workshop_name = lines[2].split(';')[0].split('=')[-1]
mod_listing = {'name':workshop_name, 'id':workshop_ID}
self.list_of_mods.append(mod_listing)
def query_list(self):
self.search_mod_names_and_IDs()
all_installed_mods = {item['name']:item['id'] for item in self.list_of_mods}
if self.args.term:
for mod_metas in all_installed_mods.items():
if self.args.term.lower() in mod_metas[0].lower():
print(mod_metas)
m = Mod_Checker()
m.query_list()
# E:/SteamLibrary/steamapps/workshop/content/221100/
#change path to point from SteamLibrary directory level
#todo: create pipeline for checking upadates and moving / renaming files to the game server directory
#allow selection of mod from list returned by term search?
# flag for copying files
# copy keys
# daemon mode?
# -->
#find workshop files by searching the extant mod folders in the server directory
@treeherder
Copy link
Author

C:\Users\Jane\Documents\dayz_server\deerisle>python find_mods.py "E:\SteamLibrary\steamapps\workshop\content\221100" --name sunnyvale
(' "Sunnyvale_Helicopters"', ' 2061631929')
(' "Sunnyvale_Fix"', ' 2142595672')
(' "Sunnyvale_Original"', ' 2167664405')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment