def test_only_different_mods(self): # if scorepost constructor fails, this test will not be accurate posts = [fp.get_scorepost_by_id("hvjgov", self.reddit)] posts_backup = posts.copy() out = fp.filter_scoreposts(posts, "temp.json") self.assertEqual(posts, out) self.assertEqual(posts, posts_backup)
def test_none_to_filter(self): # if scorepost constructor fails, this test will not be accurate posts = [fp.get_scorepost_by_id("7s1ii6", self.reddit)] posts_backup = posts.copy() out = fp.filter_scoreposts(posts, "temp.json") self.assertEqual(posts, out) self.assertEqual(posts, posts_backup)
def test_add_scorepost_to_list(self): post = fp.get_scorepost_by_id("hb2czq", self.reddit) expected = self.l.copy() expected.append({ 'player_link': "https://osu.ppy.sh/u/6447454", 'map': "https://osu.ppy.sh/b/1695382?m=0", 'mods': "HDNC" }) fp.append_json(fp.make_score_info(post), "temp.json") with open("temp.json", "r") as f: actual_skiplist = json.load(f) self.assertEqual(actual_skiplist, expected)
def single(post_id: str = None, post_to_reddit=False, scale=SCALE): reddit = fp.initialize() recording = None if post_id is None: post_id = input("Please input a post ID: ") post = fp.get_scorepost_by_id(post_id, reddit) recording = download.ReplayRecording(post) download.download_replays([recording]) download.download_beatmapsets([recording]) num_imported_maps = import_maps([recording]) print(f"Imported {num_imported_maps} maps") vid_id = make_video(recording, scale) print("Uploaded video with id", vid_id) if post_to_reddit: posted_comment = fp.post_vid_to_reddit(vid_id, post_id, reddit) print("Posted comment", posted_comment)
def manual(): reddit = fp.initialize() recording = None action = "add" while action != "exit": try: if action == "add": post_id = input("Please input a post ID: ") post = fp.get_scorepost_by_id(post_id, reddit) recording = download.ReplayRecording(post) elif action == "download": if input("Download replays? [y/n]: ") == "y": download.download_replays([recording]) if input("Download beatmaps? [y/n]: ") == "y": download.download_beatmapsets([recording]) elif action == "autoset": action = input( "Choose properties to autoset:\n\t[bc] - beatmap by comment\n\t[bu] - beatmap by url\n\t[mods]\n" ) if action == "bc": try: recording.play.set_beatmap(input("Comment text: ")) except AttributeError: print("Recording has no play to set attributes of") elif action == "bu": try: success = recording.play.set_beatmap_url( input("Beatmap URL: ")) if not success: print("URL did not match") except AttributeError: print("Recording has no play to set attributes of") elif action == "mods": try: recording.play.set_mods(input("Mods: ")) except AttributeError: print("Recording has no play to set attributes of") elif action == "set": prop = input("Property name to set: ") obj_to_set = recording try: for i in prop.split(".")[:-1]: obj_to_set = getattr(obj_to_set, i) prop_name = prop.split(".")[-1] print( f"Current value of property {prop_name}: {getattr(obj_to_set, prop_name)}" ) value = input("Property value to set: ") setattr(obj_to_set, prop_name, value) print(f"Set {prop_name} of {obj_to_set} to {value}") except AttributeError: print( f"Recording {obj_to_set} has no property named {prop}. See {dir(obj_to_set)}" ) elif action == "go": num_imported_maps = import_maps([recording]) print(f"Imported {num_imported_maps} maps") record(recording, autoscale=False) factor = int(input("Select compression ratio [0-25]")) upscale(recording, compression=factor) print("Upscaled file") recording.generate_video_attributes() print("Generated video attributes") vid_id = upload(recording) print("Uploaded video", vid_id) except KeyboardInterrupt: print("Back to main menu") print("Score:", recording) action = input( "Menu:\n\t[set] property of recording\n\t[autoset] properties\n\t[download] replays and beatmaps\n\t[add] post\n\t[go] record and upload scores\n\t[exit]\n" )
def test_make_score_info(self): score_info = fp.make_score_info( fp.get_scorepost_by_id("caue08", self.reddit)) self.assertEqual(self.l[0], score_info)