def main(**args): if args["option_list"] is not None: cols = { "artists": QueryColumn(name="artist", table="library"), "albumartists": QueryColumn(name="albumartist", table="library"), "years": None, "bpm": QueryColumn(name="bpm", table="library"), "genres": QueryColumn(name="name", table="genres"), } for e in DB.column(cols[args["option_list"][0]]): print(e) if args["sync"] is not None: analyse.scan_path(args["sync"][0]) if args["playlist"]: creator = playlist.Creator() if args["bpm_min"] is not None or args["bpm_max"] is not None: if args["bpm_min"] is not None: creator = creator.with_bpm_lower_bound(args["bpm_min"][0]) if args["bpm_max"] is not None: creator = creator.with_bpm_upper_bound(args["bpm_max"][0]) else: if args["bpm_range"] is not None: creator = creator.with_bpm_bounds( args["bpm_range"][0], args["bpm_range"][1] ) if args["bpm_window"] is not None: creator = creator.with_bpm_bounds( args["bpm_window"][0] - args["bpm_window"][1], args["bpm_window"][0] + args["bpm_window"][1], ) if args["length_min"] is not None: creator = creator.with_length_lower_bound(args["length_min"][0]) if args["length_max"] is not None: creator = creator.with_length_upper_bound(args["length_max"][0]) if args["random"]: creator = creator.with_random() if args["artist_restrict"] is not None: creator = creator.with_artist_restrict(args["artist_restrict"]) if args["artist_exclude"] is not None: creator = creator.with_artist_exclude(args["artist_exclude"]) if args["genre_restrict"] is not None: creator = creator.with_genres_restrict(args["genre_restrict"]) if args["genre_exclude"] is not None: creator = creator.with_genres_exclude(args["genre_exclude"]) if args["time_length"] is not None: creator = creator.with_length(args["time_length"][0]) if args["root"] is not None: creator = creator.with_root(args["root"][0]) p = creator.generate_playlist() if not args["quiet"]: print(p) if args["out"] is not None: with open(args["out"][0], "w") as f: f.write(p.to_m3u())
"-w", "--bpm-window", help="BPM wanted with margin of error", nargs=2, type=int, metavar=("BPM", "MARGIN"), ) parser.add_argument( "-a", "--artist-restrict", help="Restrict to artists", action="extend", nargs="+", type=str, metavar="ARTIST", choices=DB.column(QueryColumn(name="artist", table="library")) + DB.column(QueryColumn(name="albumartist", table="library")), ) parser.add_argument( "-A", "--artist-exclude", help="Exclude artists", action="extend", nargs="+", type=str, metavar="ARTIST", choices=DB.column(QueryColumn(name="artist", table="library")) + DB.column(QueryColumn(name="albumartist", table="library")), ) parser.add_argument( "-g",