rssVideos: Fix binge mode

This commit is contained in:
Geoffrey Frogeye 2022-01-08 12:36:04 +01:00
parent 8ae5c00f53
commit 75d7b9fc6d
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8

View file

@ -464,22 +464,22 @@ class RVDatabase:
return yt_dlp.YoutubeDL(self.ytdl_dry_opts)
def filter(self, args: configargparse.Namespace) -> typing.Iterable[RVElement]:
elements_src = self.elements.copy()
elements: typing.Iterable[RVElement]
# Inexpensive sort
if args.order == "new":
elements = reversed(self.elements)
elements = reversed(elements_src)
elif args.order == "title":
elements = sorted(self.elements, key=lambda el: el.title)
elements = sorted(elements_src, key=lambda el: el.title)
elif args.order == "creator":
elements = sorted(self.elements, key=lambda el: el.creator or "")
elements = sorted(elements_src, key=lambda el: el.creator or "")
elif args.order == "link":
elements = sorted(self.elements, key=lambda el: el.link)
elements = sorted(elements_src, key=lambda el: el.link)
elif args.order == "random":
elements_random = self.elements.copy()
random.shuffle(elements_random)
elements = elements_random
elements = elements_src
random.shuffle(elements)
else:
elements = self.elements
elements = elements_src
# Possibly expensive filtering
elements = filter(lambda el: el.matches_filter(args), elements)