diff --git a/feed b/feed index 642a96b..7665b80 100755 --- a/feed +++ b/feed @@ -149,32 +149,50 @@ def get_duration(url): return int(float(value)) +HELP = ''' +Collect audio informations from multiple sources (XML feeds). +Audios are (in that order): + 1. Collected from feeds; (grouped by article if --group is used) + 2. Filtered; everything that does not match with requirements is excluded + 3. Sorted; even randomly + 4. Sliced; take HOWMANY elements, skipping START elements + 5. (if --copy) Copied +Usage: ''' + + def get_parser(): - p = ArgumentParser('Get music from a (well-specified) xml feed') + p = ArgumentParser(HELP) src = p.add_argument_group('sources', 'How to deal with sources') src.add_argument('--source-weights', help='Select only one "source" based on this weights') + src.add_argument('--group', default=False, action='store_true', + help='Group audios that belong to the same article') - filters = p.add_argument_group('filters', 'Select only items that match these conditions') + filters = p.add_argument_group('filters', 'Select only items that match ' + 'these conditions') filters.add_argument('--max-len', default=0, type=int, - help='Exclude any audio that is longer than MAXLEN seconds') + help='Exclude any audio that is longer ' + 'than MAX_LEN seconds') filters.add_argument('--random', default=False, action='store_true', help='Pick randomly') filters.add_argument('--min-len', default=0, type=int, - help='Exclude any audio that is shorter than MIN_LEN seconds') + help='Exclude any audio that is shorter ' + 'than MIN_LEN seconds') + p.add_argument('--start', default=0, type=int, help='0-indexed start number. ' 'By default, play from most recent') - p.add_argument('--howmany', default=1, type=int, help='If not specified, only 1 will be played') - p.add_argument('--slotsize', help='Seconds between each audio', type=int) - p.add_argument('--group', help='Group articles', default=False, - action='store_true') - p.add_argument('--copy', help='Copy files to $TMPDIR', default=False, - action='store_true') - p.add_argument('--debug', help='Debug messages', default=False, - action='store_true') + p.add_argument('--slotsize', type=int, + help='Seconds between each audio. Still unsupported') + + general = p.add_argument_group('general', 'General options') + general.add_argument('--copy', help='Copy files to $TMPDIR', default=False, + action='store_true') + general.add_argument('--debug', help='Debug messages', default=False, + action='store_true') + p.add_argument('urls', metavar='URL', nargs='+') return p @@ -225,8 +243,10 @@ def main(): if not args.group: # get audio urls, removing those that are too long audios += [audio for audio in get_urls(tree) if - (args.max_len == 0 or audio.duration <= args.max_len) and - (args.min_len == 0 or audio.duration >= args.min_len) + (args.max_len == 0 or + audio.duration <= args.max_len) and + (args.min_len == 0 or + audio.duration >= args.min_len) ] else: groups = get_grouped_urls(tree)