sort by duration
This commit is contained in:
parent
6d84552a2c
commit
5930f1cdba
1 changed files with 6 additions and 4 deletions
10
feed
10
feed
|
@ -241,16 +241,16 @@ def get_parser():
|
||||||
|
|
||||||
filters = p.add_argument_group('filters', 'Select only items that match '
|
filters = p.add_argument_group('filters', 'Select only items that match '
|
||||||
'these conditions')
|
'these conditions')
|
||||||
|
filters.add_argument('--min-len', default=0, type=DurationType,
|
||||||
|
help='Exclude any audio that is shorter '
|
||||||
|
'than MIN_LEN seconds')
|
||||||
filters.add_argument('--max-len', default=0, type=DurationType,
|
filters.add_argument('--max-len', default=0, type=DurationType,
|
||||||
help='Exclude any audio that is longer '
|
help='Exclude any audio that is longer '
|
||||||
'than MAX_LEN seconds')
|
'than MAX_LEN seconds')
|
||||||
filters.add_argument('--sort-by', default='no', type=str,
|
filters.add_argument('--sort-by', default='no', type=str,
|
||||||
choices=('random', 'date'))
|
choices=('random', 'date', 'duration'))
|
||||||
filters.add_argument('--reverse', default=False,
|
filters.add_argument('--reverse', default=False,
|
||||||
action='store_true', help='Reverse list order')
|
action='store_true', help='Reverse list order')
|
||||||
filters.add_argument('--min-len', default=0, type=DurationType,
|
|
||||||
help='Exclude any audio that is shorter '
|
|
||||||
'than MIN_LEN seconds')
|
|
||||||
|
|
||||||
filters.add_argument('--min-age', default=datetime.timedelta(),
|
filters.add_argument('--min-age', default=datetime.timedelta(),
|
||||||
type=TimeDeltaType,
|
type=TimeDeltaType,
|
||||||
|
@ -363,6 +363,8 @@ def main():
|
||||||
random.shuffle(audios)
|
random.shuffle(audios)
|
||||||
elif args.sort_by == 'date':
|
elif args.sort_by == 'date':
|
||||||
audios.sort(key=lambda x: x.age)
|
audios.sort(key=lambda x: x.age)
|
||||||
|
elif args.sort_by == 'duration':
|
||||||
|
audios.sort(key=lambda x: x.duration)
|
||||||
|
|
||||||
if args.reverse:
|
if args.reverse:
|
||||||
audios.reverse()
|
audios.reverse()
|
||||||
|
|
Loading…
Reference in a new issue