diff --git a/bemani/backend/popn/base.py b/bemani/backend/popn/base.py index 9fd0f87..01397ea 100644 --- a/bemani/backend/popn/base.py +++ b/bemani/backend/popn/base.py @@ -341,7 +341,9 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): ) -> None: # Generate scorecard profile = self.get_profile(userid) - song = self.data.local.music.get_song(self.game, self.music_version, songid, chart) + song = self.data.local.music.get_song( + self.game, self.music_version, songid, chart + ) card_medal = { self.PLAY_MEDAL_CIRCLE_FAILED: "Failed", diff --git a/bemani/backend/popn/common.py b/bemani/backend/popn/common.py index 8e837b9..ee5f94c 100644 --- a/bemani/backend/popn/common.py +++ b/bemani/backend/popn/common.py @@ -328,7 +328,7 @@ class PopnMusicModernBase(PopnMusicBase, ABC): # Top 500 Popular music for songid, _plays in self.data.local.music.get_hit_chart( - self.game, self.version, 500 + self.game, self.music_version, 500 ): popular_music = Node.void("popular_music") root.add_child(popular_music) @@ -575,7 +575,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC): return root rivalid = links[no].other_userid rivalprofile = profiles[rivalid] - scores = self.data.remote.music.get_scores(self.game, self.version, rivalid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, rivalid + ) # First, output general profile info. friend = Node.void("friend") @@ -673,7 +675,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC): return Node.void("player24") root = Node.void("player24") - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: # Skip any scores for chart types we don't support if score.chart not in [ @@ -829,7 +833,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC): root.add_child(Node.s8("result", 1)) # Scores - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: # Skip any scores for chart types we don't support if score.chart not in [ @@ -1036,13 +1042,13 @@ class PopnMusicModernBase(PopnMusicBase, ABC): last_played = [ x[0] for x in self.data.local.music.get_last_played( - self.game, self.version, userid, 10 + self.game, self.music_version, userid, 10 ) ] most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 20 + self.game, self.music_version, userid, 20 ) ] while len(last_played) < 10: @@ -1157,7 +1163,9 @@ class PopnMusicModernBase(PopnMusicBase, ABC): if game_config.get_bool("force_unlock_songs"): songs = { song.id - for song in self.data.local.music.get_all_songs(self.game, self.version) + for song in self.data.local.music.get_all_songs( + self.game, self.music_version + ) } for song in songs: item = Node.void("item") diff --git a/bemani/backend/popn/eclale.py b/bemani/backend/popn/eclale.py index 46a81fe..58a75e8 100644 --- a/bemani/backend/popn/eclale.py +++ b/bemani/backend/popn/eclale.py @@ -210,7 +210,7 @@ class PopnMusicEclale(PopnMusicBase): # Output the hit chart for songid, _plays in self.data.local.music.get_hit_chart( - self.game, self.version, 500 + self.game, self.music_version, 500 ): popular_music = Node.void("popular_music") root.add_child(popular_music) @@ -360,7 +360,9 @@ class PopnMusicEclale(PopnMusicBase): userid = self.data.remote.user.from_refid(self.game, self.version, refid) if userid is not None: - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) else: scores = [] @@ -451,7 +453,9 @@ class PopnMusicEclale(PopnMusicBase): return root rivalid = links[no].other_userid rivalprofile = profiles[rivalid] - scores = self.data.remote.music.get_scores(self.game, self.version, rivalid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, rivalid + ) # First, output general profile info. friend = Node.void("friend") @@ -573,7 +577,9 @@ class PopnMusicEclale(PopnMusicBase): root.add_child(Node.s8("result", 1)) # Scores - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: # Skip any scores for chart types we don't support if score.chart not in [ @@ -684,13 +690,13 @@ class PopnMusicEclale(PopnMusicBase): last_played = [ x[0] for x in self.data.local.music.get_last_played( - self.game, self.version, userid, 5 + self.game, self.music_version, userid, 5 ) ] most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 10 + self.game, self.music_version, userid, 10 ) ] while len(last_played) < 5: @@ -794,7 +800,9 @@ class PopnMusicEclale(PopnMusicBase): if game_config.get_bool("force_unlock_songs"): songs = { song.id - for song in self.data.local.music.get_all_songs(self.game, self.version) + for song in self.data.local.music.get_all_songs( + self.game, self.music_version + ) } for song in songs: item = Node.void("item") diff --git a/bemani/backend/popn/fantasia.py b/bemani/backend/popn/fantasia.py index 6113dd2..8e649a1 100644 --- a/bemani/backend/popn/fantasia.py +++ b/bemani/backend/popn/fantasia.py @@ -204,13 +204,13 @@ class PopnMusicFantasia(PopnMusicBase): last_played = [ x[0] for x in self.data.local.music.get_last_played( - self.game, self.version, userid, 3 + self.game, self.music_version, userid, 3 ) ] most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 20 + self.game, self.music_version, userid, 20 ) ] while len(last_played) < 3: @@ -222,7 +222,9 @@ class PopnMusicFantasia(PopnMusicBase): clear_medal = [0] * self.GAME_MAX_MUSIC_ID clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue @@ -329,7 +331,9 @@ class PopnMusicFantasia(PopnMusicBase): clear_medal = [0] * self.GAME_MAX_MUSIC_ID hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 4) * 17) + 7) / 8) - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue @@ -643,7 +647,9 @@ class PopnMusicFantasia(PopnMusicBase): for rival in links[:2]: rivalid = rival.other_userid rivalprofile = profiles[rivalid] - scores = self.data.remote.music.get_scores(self.game, self.version, rivalid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, rivalid + ) # First, output general profile info. friend = Node.void("friend") diff --git a/bemani/backend/popn/lapistoria.py b/bemani/backend/popn/lapistoria.py index 1427e5f..fa88703 100644 --- a/bemani/backend/popn/lapistoria.py +++ b/bemani/backend/popn/lapistoria.py @@ -334,7 +334,9 @@ class PopnMusicLapistoria(PopnMusicBase): return root rivalid = links[no].other_userid rivalprofile = profiles[rivalid] - scores = self.data.remote.music.get_scores(self.game, self.version, rivalid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, rivalid + ) achievements = self.data.local.user.get_achievements( self.game, self.version, rivalid ) @@ -658,13 +660,13 @@ class PopnMusicLapistoria(PopnMusicBase): last_played = [ x[0] for x in self.data.local.music.get_last_played( - self.game, self.version, userid, 5 + self.game, self.music_version, userid, 5 ) ] most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 10 + self.game, self.music_version, userid, 10 ) ] while len(last_played) < 5: @@ -675,7 +677,9 @@ class PopnMusicLapistoria(PopnMusicBase): account.add_child(Node.s16_array("my_best", most_played)) account.add_child(Node.s16_array("latest_music", last_played)) - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: # Skip any scores for chart types we don't support if score.chart not in [ @@ -822,7 +826,9 @@ class PopnMusicLapistoria(PopnMusicBase): if game_config.get_bool("force_unlock_songs"): songs = { song.id - for song in self.data.local.music.get_all_songs(self.game, self.version) + for song in self.data.local.music.get_all_songs( + self.game, self.music_version + ) } for song in songs: item = Node.void("item") @@ -1082,7 +1088,9 @@ class PopnMusicLapistoria(PopnMusicBase): root.add_child(Node.s32("option", profile.get_int("option", 0))) root.add_child(Node.s8("result", 1)) - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue diff --git a/bemani/backend/popn/sunnypark.py b/bemani/backend/popn/sunnypark.py index cf4057f..e7d566e 100644 --- a/bemani/backend/popn/sunnypark.py +++ b/bemani/backend/popn/sunnypark.py @@ -186,13 +186,13 @@ class PopnMusicSunnyPark(PopnMusicBase): last_played = [ x[0] for x in self.data.local.music.get_last_played( - self.game, self.version, userid, 3 + self.game, self.music_version, userid, 3 ) ] most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 20 + self.game, self.music_version, userid, 20 ) ] while len(last_played) < 3: @@ -204,7 +204,9 @@ class PopnMusicSunnyPark(PopnMusicBase): clear_medal = [0] * self.GAME_MAX_MUSIC_ID clear_medal_sub = [0] * self.GAME_MAX_MUSIC_ID - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue @@ -463,7 +465,9 @@ class PopnMusicSunnyPark(PopnMusicBase): clear_medal = [0] * self.GAME_MAX_MUSIC_ID - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue @@ -815,7 +819,9 @@ class PopnMusicSunnyPark(PopnMusicBase): for rival in links[:2]: rivalid = rival.other_userid rivalprofile = profiles[rivalid] - scores = self.data.remote.music.get_scores(self.game, self.version, rivalid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, rivalid + ) # First, output general profile info. friend = Node.void("friend") diff --git a/bemani/backend/popn/tunestreet.py b/bemani/backend/popn/tunestreet.py index 22608ad..13ab4ea 100644 --- a/bemani/backend/popn/tunestreet.py +++ b/bemani/backend/popn/tunestreet.py @@ -227,7 +227,9 @@ class PopnMusicTuneStreet(PopnMusicBase): # Format Scores hiscore_array = [0] * int((((self.GAME_MAX_MUSIC_ID * 7) * 17) + 7) / 8) - scores = self.data.remote.music.get_scores(self.game, self.version, userid) + scores = self.data.remote.music.get_scores( + self.game, self.music_version, userid + ) for score in scores: if score.id > self.GAME_MAX_MUSIC_ID: continue @@ -284,7 +286,7 @@ class PopnMusicTuneStreet(PopnMusicBase): most_played = [ x[0] for x in self.data.local.music.get_most_played( - self.game, self.version, userid, 20 + self.game, self.music_version, userid, 20 ) ] while len(most_played) < 20: diff --git a/bemani/frontend/popn/endpoints.py b/bemani/frontend/popn/endpoints.py index 745ad7f..b6d12ea 100644 --- a/bemani/frontend/popn/endpoints.py +++ b/bemani/frontend/popn/endpoints.py @@ -186,20 +186,20 @@ def viewtopscores(musicid: int) -> Response: difficulties = [0, 0, 0, 0] for version in versions: - for omniadd in [0, DBConstants.OMNIMIX_VERSION_BUMP]: - for chart in [0, 1, 2, 3]: - details = g.data.local.music.get_song( - GameConstants.POPN_MUSIC, version + omniadd, musicid, chart - ) - if details is not None: - if name is None: - name = details.name - if artist is None: - artist = details.artist - if genre is None: - genre = details.genre - if difficulties[chart] == 0: - difficulties[chart] = details.data.get_int("difficulty") + for omniadd in [0, DBConstants.OMNIMIX_VERSION_BUMP]: + for chart in [0, 1, 2, 3]: + details = g.data.local.music.get_song( + GameConstants.POPN_MUSIC, version + omniadd, musicid, chart + ) + if details is not None: + if name is None: + name = details.name + if artist is None: + artist = details.artist + if genre is None: + genre = details.genre + if difficulties[chart] == 0: + difficulties[chart] = details.data.get_int("difficulty") if name is None: # Not a real song! diff --git a/bemani/utils/read.py b/bemani/utils/read.py index df77550..98c82e6 100644 --- a/bemani/utils/read.py +++ b/bemani/utils/read.py @@ -398,9 +398,12 @@ class ImportPopn(ImportBase): "24": VersionConstants.POPN_MUSIC_USANEKO, "25": VersionConstants.POPN_MUSIC_PEACE, "26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES, - "omni-24": VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP, #Omnimix v2 only works for 24 - 26 - "omni-25": VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP , - "omni-26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP, + "omni-24": VersionConstants.POPN_MUSIC_USANEKO + + DBConstants.OMNIMIX_VERSION_BUMP, # Omnimix v2 only works for 24 - 26 + "omni-25": VersionConstants.POPN_MUSIC_PEACE + + DBConstants.OMNIMIX_VERSION_BUMP, + "omni-26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + + DBConstants.OMNIMIX_VERSION_BUMP, }.get(version, -1) if actual_version == VersionConstants.POPN_MUSIC_TUNE_STREET: @@ -419,85 +422,114 @@ class ImportPopn(ImportBase): super().__init__( config, GameConstants.POPN_MUSIC, actual_version, no_combine, update ) - - def scrape_xml(self, xmlfile: str, songs: List[Dict[str, Any]] = []) -> List[Dict[str, Any]]: - - with open(xmlfile, 'rb') as xmlhandle: - xmldata = xmlhandle.read().decode('shift_jisx0213') + + def scrape_xml( + self, xmlfile: Path, songs: List[Dict[str, Any]] = [] + ) -> List[Dict[str, Any]]: + with open(xmlfile, "rb") as xmlhandle: + xmldata = xmlhandle.read().decode("shift_jisx0213") root = ET.fromstring(xmldata) - for music_entry in root.findall('music'): + for music_entry in root.findall("music"): difficulties = [0, 0, 0, 0, 0, 0] - filenames = ['', '', '', '', '', ''] + filenames = ["", "", "", "", "", ""] diff_map = { - 'ep': 0, - 'np': 1, - 'hp': 2, - 'op': 3, - 'bp_n': 4, - 'bp_h': 5, + "ep": 0, + "np": 1, + "hp": 2, + "op": 3, + "bp_n": 4, + "bp_h": 5, } - charts = music_entry.find('charts') + charts = music_entry.find("charts") if charts is not None: - for chart in charts.findall('chart'): - chart_idx = diff_map.get(chart.attrib['idx']) - if chart.find('diff') is not None: - difficulties[chart_idx] = int(chart.find('diff').text) - filenames[chart_idx] = f'{chart.find("folder").text}/{chart.find("filename").text}' + for chart in charts.findall("chart"): + chart_idx = diff_map.get(chart.attrib["idx"]) + if chart.find("diff") is not None: + difficulties[chart_idx] = int(chart.find("diff").text) + filenames[ + chart_idx + ] = f'{chart.find("folder").text}/{chart.find("filename").text}' songinfo: Dict # Check if song metadata is in this entry - if music_entry.find('fw_title') is not None: + if music_entry.find("fw_title") is not None: songinfo = { - 'id': int(music_entry.attrib['id']), - 'title': music_entry.find('fw_title').text, - 'artist': music_entry.find('fw_artist').text, - 'genre': music_entry.find('fw_genre').text, - 'comment': music_entry.find('genre').text, - 'title_en': music_entry.find('title').text, - 'artist_en': music_entry.find('artist').text, - 'long_genre': '', - 'folder': music_entry.find('folder').text, - 'difficulty': { - 'standard': { - 'easy': difficulties[0], - 'normal': difficulties[1], - 'hyper': difficulties[2], - 'ex': difficulties[3], + "id": int(music_entry.attrib["id"]), + "title": music_entry.find("fw_title").text, + "artist": music_entry.find("fw_artist").text, + "genre": music_entry.find("fw_genre").text, + "comment": music_entry.find("genre").text, + "title_en": music_entry.find("title").text, + "artist_en": music_entry.find("artist").text, + "long_genre": "", + "folder": music_entry.find("folder").text, + "difficulty": { + "standard": { + "easy": difficulties[0], + "normal": difficulties[1], + "hyper": difficulties[2], + "ex": difficulties[3], + }, + "battle": { + "normal": difficulties[4], + "hyper": difficulties[5], }, - 'battle': { - 'normal': difficulties[4], - 'hyper': difficulties[5], - } }, - 'file': { - 'standard': { - 'easy': filenames[0], - 'normal': filenames[1], - 'hyper': filenames[2], - 'ex': filenames[3], + "file": { + "standard": { + "easy": filenames[0], + "normal": filenames[1], + "hyper": filenames[2], + "ex": filenames[3], }, - 'battle': { - 'normal': filenames[4], - 'hyper': filenames[5], + "battle": { + "normal": filenames[4], + "hyper": filenames[5], }, }, } # It's not here so find the entry at the current song id else: for song in songs: - if song['id'] == int(music_entry.attrib['id']): + if song["id"] == int(music_entry.attrib["id"]): if difficulties is not None: - for diff, i in zip(['easy', 'normal', 'hyper', 'ex'], range(4)): - song['difficulty']['standard'][diff] = difficulties[i] if difficulties[i] else song['difficulty']['standard'][diff] - song['file']['standard'][diff] = filenames[i] if filenames[i] else song['file']['standard'][diff] + for diff, i in zip( + ["easy", "normal", "hyper", "ex"], range(4) + ): + song["difficulty"]["standard"][diff] = ( + difficulties[i] + if difficulties[i] + else song["difficulty"]["standard"][diff] + ) + song["file"]["standard"][diff] = ( + filenames[i] + if filenames[i] + else song["file"]["standard"][diff] + ) - song['difficulty']['battle']['normal'] = difficulties[4] if difficulties[4] else song['difficulty']['battle']['normal'] - song['difficulty']['battle']['hyper'] = difficulties[5] if difficulties[5] else song['difficulty']['battle']['hyper'] - song['file']['battle']['normal'] = filenames[4] if filenames[4] else song['file']['battle']['normal'] - song['file']['battle']['hyper'] = filenames[5] if filenames[5] else song['file']['battle']['hyper'] + song["difficulty"]["battle"]["normal"] = ( + difficulties[4] + if difficulties[4] + else song["difficulty"]["battle"]["normal"] + ) + song["difficulty"]["battle"]["hyper"] = ( + difficulties[5] + if difficulties[5] + else song["difficulty"]["battle"]["hyper"] + ) + song["file"]["battle"]["normal"] = ( + filenames[4] + if filenames[4] + else song["file"]["battle"]["normal"] + ) + song["file"]["battle"]["hyper"] = ( + filenames[5] + if filenames[5] + else song["file"]["battle"]["hyper"] + ) else: - song['genre'] = music_entry.find('fw_genre').text - song['comment'] = music_entry.find('genre').text + song["genre"] = music_entry.find("fw_genre").text + song["comment"] = music_entry.find("genre").text break continue @@ -529,11 +561,11 @@ class ImportPopn(ImportBase): } for orig, rep in accent_lut.items(): - songinfo['title'] = songinfo['title'].replace(orig, rep) - songinfo['artist'] = songinfo['artist'].replace(orig, rep) - songinfo['title_en'] = songinfo['title_en'].replace(orig, rep) - songinfo['artist_en'] = songinfo['artist_en'].replace(orig, rep) - songinfo['genre'] = songinfo['genre'].replace(orig, rep) + songinfo["title"] = songinfo["title"].replace(orig, rep) + songinfo["artist"] = songinfo["artist"].replace(orig, rep) + songinfo["title_en"] = songinfo["title_en"].replace(orig, rep) + songinfo["artist_en"] = songinfo["artist_en"].replace(orig, rep) + songinfo["genre"] = songinfo["genre"].replace(orig, rep) songs.append(songinfo) return songs @@ -993,7 +1025,9 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_USANEKO or self.version == (VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP): + elif self.version == VersionConstants.POPN_MUSIC_USANEKO or self.version == ( + VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP + ): # Based on M39:J:A:A:2018101500 # Normal offset for music DB, size @@ -1083,7 +1117,9 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_PEACE or self.version == (VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP): + elif self.version == VersionConstants.POPN_MUSIC_PEACE or self.version == ( + VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP + ): # Based on M39:J:A:A:2020092800 # Normal offset for music DB, size @@ -1173,7 +1209,14 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES or self.version == (VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP): + elif ( + self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + or self.version + == ( + VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + + DBConstants.OMNIMIX_VERSION_BUMP + ) + ): # Based on M39:J:A:A:2022061300 # Normal offset for music DB, size @@ -4228,11 +4271,11 @@ if __name__ == "__main__": help="The access token to use with the remote BEMAPI server.", ) parser.add_argument( - '--folder', - dest='folder', - action='store', + "--folder", + dest="folder", + action="store", type=str, - help='The path were a folder of files are stored.', + help="The path were a folder of files are stored.", ) # Parse args, validate invariants. @@ -4261,14 +4304,16 @@ if __name__ == "__main__": if args.bin: songs = popn.scrape(args.bin) if args.xml: - songs = popn.scrape_xml(args.xml, songs) + songs = popn.scrape_xml(args.xml, songs) elif args.folder: - files = Path(args.folder).glob('*xml') - for file in files: - try: - songs = popn.scrape_xml(file, songs) - except: - raise Exception("Invalid XML (" + str(file) +")" ) + files = Path(args.folder).glob("*xml") + for filename in files: + try: + songs = popn.scrape_xml(filename, songs) + except Exception: + # We should really be just catching invalid XML but I didn't write this + # nor do I have omnimix so I can't really test what it should do. + raise Exception(f"Invalid XML ({filename})") elif args.server and args.token: songs = popn.lookup(args.server, args.token) else: