Select some random items or albums and print the results.
(lib: Library, opts: optparse.Values, args: list[str])
| 31 | |
| 32 | |
| 33 | def random_func(lib: Library, opts: optparse.Values, args: list[str]): |
| 34 | """Select some random items or albums and print the results.""" |
| 35 | # Fetch all the objects matching the query into a list. |
| 36 | objs = lib.albums(args) if opts.album else lib.items(args) |
| 37 | |
| 38 | # Print a random subset. |
| 39 | for obj in random_objs( |
| 40 | objs=objs, |
| 41 | equal_chance_field=opts.field, |
| 42 | number=opts.number, |
| 43 | time_minutes=opts.time, |
| 44 | equal_chance=opts.equal_chance, |
| 45 | ): |
| 46 | print_(format(obj)) |
| 47 | |
| 48 | |
| 49 | random_cmd = Subcommand("random", help="choose a random track or album") |
nothing calls this directly
no test coverage detected