def convertSample(file_name): info = file_info(file_name).replace(file_name + ': ', '') if regexMatch('Audio file with', info): info = info.replace('Audio file with ', '') else: aac_match = regexMatch("ISO Media, Apple iTunes (.*)", info) if aac_match: encoding = aac_match.group(1) print("!! Error: Unsupported Apple audio encoding:", encoding) rm(file_name) return None print("!! Error: Downloaded 'audio' file", "'"+file_name+"'", "with attributes:") print(" ", info) return None mp3_match = regexMatch("ID3 version (.*) contains:(.*)", info) if mp3_match: id3_version, encoding = mp3_match.groups() new_file_name = file_name.replace('.unknown', '.mp3') elif False: new_file_name = '' else: print("!! Error: Unrecognized audio container:", info) return None mv(file_name, new_file_name) flac_file_name = file_name.replace('.unknown', '.flac') sox(new_file_name, flac_file_name) rm(new_file_name) return flac_file_name
def songBeatStrength(songRow): try: return float(regexMatch("This song has a beat strength of (\d{1,2}\.\d{1,2})", songRow.find_all('td')[4] .find_all('a')[0] .img.attrs['title'] ).group(1) ) except: return None
def songEnergy(songRow): try: return float(regexMatch("This song has an energy level of (\d{1,2}\.\d{1,2})", songRow.find_all('td')[4] .find_all('a')[1] .img.attrs['title'] ).group(1) ) except: return None
def buildAllEmotes(names): emotes = [] for name in names: if regexMatch(r"^[a-zA-Z0-9]+$", name.text): url = name.find_previous_sibling("div").find("img")["src"] if (args.verbose > 1): print(f"Downloading {name.text} from {url}") emotes.append({"name": name.text, "content": requestContent(url)}) return emotes