FIX filtering for files, too
This commit is contained in:
parent
229b946a32
commit
086c1f9aa6
1 changed files with 39 additions and 36 deletions
75
feed
75
feed
|
@ -330,47 +330,50 @@ def main():
|
||||||
|
|
||||||
audios = []
|
audios = []
|
||||||
for url in sources:
|
for url in sources:
|
||||||
if url.startswith('http:') or url.startswith('https:') \
|
if not args.group:
|
||||||
or os.path.isfile(url):
|
if os.path.isdir(url):
|
||||||
# download the feed
|
audiodir = get_audio_from_dir(url)
|
||||||
tree = get_tree(url)
|
|
||||||
# filtering
|
|
||||||
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) and
|
|
||||||
(args.min_age.total_seconds() == 0 or
|
|
||||||
audio.age >= args.min_age) and
|
|
||||||
(args.max_age.total_seconds() == 0 or
|
|
||||||
audio.age <= args.max_age)
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
groups = get_grouped_urls(tree)
|
|
||||||
audios += [groups[g] for g in groups.keys()
|
|
||||||
if
|
|
||||||
(args.max_len == 0 or
|
|
||||||
groups[g].duration <= args.max_len) and
|
|
||||||
(args.min_len == 0 or
|
|
||||||
groups[g].duration >= args.max_len) and
|
|
||||||
(args.min_age.total_seconds() == 0 or
|
|
||||||
groups[g].age >= args.min_age) and
|
|
||||||
(args.max_age.total_seconds() == 0 or
|
|
||||||
groups[g].age <= args.max_age)
|
|
||||||
]
|
|
||||||
elif os.path.isdir(url):
|
|
||||||
audiodir = get_audio_from_dir(url)
|
|
||||||
if not args.group:
|
|
||||||
audios += audiodir
|
audios += audiodir
|
||||||
|
elif url.startswith('http:') or url.startswith('https:') \
|
||||||
|
or os.path.isfile(url):
|
||||||
|
audios += get_urls(get_tree(url))
|
||||||
else:
|
else:
|
||||||
|
logging.info('unsupported url `%s`', url)
|
||||||
|
audios = [audio for audio in audios if
|
||||||
|
(args.max_len == 0 or
|
||||||
|
audio.duration <= args.max_len) and
|
||||||
|
(args.min_len == 0 or
|
||||||
|
audio.duration >= args.min_len) and
|
||||||
|
(args.min_age.total_seconds() == 0 or
|
||||||
|
audio.age >= args.min_age) and
|
||||||
|
(args.max_age.total_seconds() == 0 or
|
||||||
|
audio.age <= args.max_age)
|
||||||
|
]
|
||||||
|
else: # group
|
||||||
|
if os.path.isdir(url):
|
||||||
|
audiodir = get_audio_from_dir(url)
|
||||||
|
agroups = []
|
||||||
for a in audiodir:
|
for a in audiodir:
|
||||||
ag = AudioGroup(os.path.basename(a.url))
|
ag = AudioGroup(os.path.basename(a.url))
|
||||||
ag.append(a)
|
ag.append(a)
|
||||||
audios.append(ag)
|
agroups.append(ag)
|
||||||
else:
|
elif url.startswith('http:') or url.startswith('https:') \
|
||||||
logging.info('unsupported url `%s`', url)
|
or os.path.isfile(url):
|
||||||
|
groups = get_grouped_urls(get_tree(url))
|
||||||
|
agroups = groups.values()
|
||||||
|
else:
|
||||||
|
logging.info('unsupported url `%s`', url)
|
||||||
|
audios += [g for g in agroups
|
||||||
|
if
|
||||||
|
(args.max_len == 0 or
|
||||||
|
g.duration <= args.max_len) and
|
||||||
|
(args.min_len == 0 or
|
||||||
|
g.duration >= args.max_len) and
|
||||||
|
(args.min_age.total_seconds() == 0 or
|
||||||
|
g.age >= args.min_age) and
|
||||||
|
(args.max_age.total_seconds() == 0 or
|
||||||
|
g.age <= args.max_age)
|
||||||
|
]
|
||||||
|
|
||||||
# sort
|
# sort
|
||||||
if args.sort_by == 'random':
|
if args.sort_by == 'random':
|
||||||
|
|
Loading…
Reference in a new issue