def upload_data(system_name, game_info): dsvc = gd_auth.drive_login() if (len(sys.argv) > 3): parent_id = sys.argv[3] else: gd_ops.get_root_id(dsvc) upload_list = [] print("Enumerating Roms...") for root, dirs, files in os.walk("roms"): for f in files: fb, fe = os.path.splitext(f) game_id = find_entry(fb, game_info) if (game_id == None): print("Rom for %s not found." % game_info[game_id]['name']) continue else: #Get hash. game_info[game_id]['sha1'] = get_sha1sum(os.path.join(root, f)) #Add rom to our upload list. upload_list.append( [os.path.join(root, f), "cFE_DATA:%s" % game_id]) #Add icon to our upload list. for root2, dirs2, files2 in os.walk("icon"): for f2 in files2: if f2.startswith(game_info[game_id]['name']): rt, parent = os.path.split(root2) basef, ext = os.path.splitext(f2) if (not basef.endswith("_%s" % parent)): fixed_name = os.path.join( root2, "%s_%s%s" % (basef, parent, ext)) os.rename(os.path.join(root2, f2), fixed_name) else: fixed_name = os.path.join(root2, f2) upload_list.append( [fixed_name, "cFE_ICON:%s" % game_id]) break #Add any artwork to our upload list. for root3, dirs3, files3 in os.walk("artwork"): for f3 in files3: if f3.startswith(game_info[game_id]['name']): print("Found Artwork %s" % os.path.join(root3, f3)) rt, parent = os.path.split(root3) basef, ext = os.path.splitext(f3) if (not basef.endswith("_%s" % parent)): fixed_name = os.path.join( root3, "%s_%s%s" % (basef, parent, ext)) os.rename(os.path.join(root3, f3), fixed_name) else: fixed_name = os.path.join(root3, f3) upload_list.append( [fixed_name, "cFE_ARTW:%s" % game_id]) up_total = len(upload_list) up_counter = 0 for item in upload_list: #Check to make sure we aren't uploading a duplicate. baspth, name = os.path.split(item[0]) emu_file_obj = gd_ops.get_file_meta( dsvc, "title='%s' and fullText contains '%s'" % (name.replace("'", "\\'"), item[1])) up_counter += 1 if (emu_file_obj != []): print("[%d/%d] Skipping: %s" % (up_counter, up_total, name)) continue print("[%d/%d] Uploading: %s" % (up_counter, up_total, name)) gd_ops.upload_file(dsvc, name, item[1], parent_id, "", item[0])
game_info['rating'] = "" game_info['enabled'] = "Yes" game_info['sha1'] = "" for c in item.childNodes: #Skip Text Nodes because f**k them. if(c.nodeType == 3): continue tag_name = c.tagName itm = item.getElementsByTagName(tag_name) for a in itm: try: game_info[tag_name] = a.firstChild.nodeValue except: pass ROM_DB[game_info['game_name']] = game_info #Time to start going through all the roms. #Log in. dsvc = gd_auth.drive_login() if(len(sys.argv) < 3): parent_id = gd_ops.get_root_id(dsvc) else: parent_id = sys.argv[2] for root,dirs,files in os.walk("roms"): for f in files: proc_rom(dsvc,parent_id,os.path.join(root,f))
def upload_data(system_name, game_info): dsvc = gd_auth.drive_login() if len(sys.argv) > 3: parent_id = sys.argv[3] else: gd_ops.get_root_id(dsvc) upload_list = [] print("Enumerating Roms...") for root, dirs, files in os.walk("roms"): for f in files: fb, fe = os.path.splitext(f) game_id = find_entry(fb, game_info) if game_id == None: print("Rom for %s not found." % game_info[game_id]["name"]) continue else: # Get hash. game_info[game_id]["sha1"] = get_sha1sum(os.path.join(root, f)) # Add rom to our upload list. upload_list.append([os.path.join(root, f), "cFE_DATA:%s" % game_id]) # Add icon to our upload list. for root2, dirs2, files2 in os.walk("icon"): for f2 in files2: if f2.startswith(game_info[game_id]["name"]): rt, parent = os.path.split(root2) basef, ext = os.path.splitext(f2) if not basef.endswith("_%s" % parent): fixed_name = os.path.join(root2, "%s_%s%s" % (basef, parent, ext)) os.rename(os.path.join(root2, f2), fixed_name) else: fixed_name = os.path.join(root2, f2) upload_list.append([fixed_name, "cFE_ICON:%s" % game_id]) break # Add any artwork to our upload list. for root3, dirs3, files3 in os.walk("artwork"): for f3 in files3: if f3.startswith(game_info[game_id]["name"]): print("Found Artwork %s" % os.path.join(root3, f3)) rt, parent = os.path.split(root3) basef, ext = os.path.splitext(f3) if not basef.endswith("_%s" % parent): fixed_name = os.path.join(root3, "%s_%s%s" % (basef, parent, ext)) os.rename(os.path.join(root3, f3), fixed_name) else: fixed_name = os.path.join(root3, f3) upload_list.append([fixed_name, "cFE_ARTW:%s" % game_id]) up_total = len(upload_list) up_counter = 0 for item in upload_list: # Check to make sure we aren't uploading a duplicate. baspth, name = os.path.split(item[0]) emu_file_obj = gd_ops.get_file_meta( dsvc, "title='%s' and fullText contains '%s'" % (name.replace("'", "\\'"), item[1]) ) up_counter += 1 if emu_file_obj != []: print("[%d/%d] Skipping: %s" % (up_counter, up_total, name)) continue print("[%d/%d] Uploading: %s" % (up_counter, up_total, name)) gd_ops.upload_file(dsvc, name, item[1], parent_id, "", item[0])
game_info['game_region'] = "" game_info['rating'] = "" game_info['enabled'] = "Yes" game_info['sha1'] = "" for c in item.childNodes: #Skip Text Nodes because f**k them. if (c.nodeType == 3): continue tag_name = c.tagName itm = item.getElementsByTagName(tag_name) for a in itm: try: game_info[tag_name] = a.firstChild.nodeValue except: pass ROM_DB[game_info['game_name']] = game_info #Time to start going through all the roms. #Log in. dsvc = gd_auth.drive_login() if (len(sys.argv) < 3): parent_id = gd_ops.get_root_id(dsvc) else: parent_id = sys.argv[2] for root, dirs, files in os.walk("roms"): for f in files: proc_rom(dsvc, parent_id, os.path.join(root, f))