From 7b2096e0eb94ecf1b7da6984f302a4f60b7ec3c1 Mon Sep 17 00:00:00 2001 From: Benex254 Date: Sun, 11 Aug 2024 11:22:43 +0300 Subject: [PATCH] feat(utils): add animeprovider util that assigns a random quality string if not present --- fastanime/libs/anime_provider/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fastanime/libs/anime_provider/utils.py b/fastanime/libs/anime_provider/utils.py index e98b1d5..7bb00ca 100644 --- a/fastanime/libs/anime_provider/utils.py +++ b/fastanime/libs/anime_provider/utils.py @@ -1,4 +1,5 @@ import re +from itertools import cycle # Dictionary to map hex values to characters hex_to_char = { @@ -34,6 +35,15 @@ hex_to_char = { } +def give_random_quality(links: list[dict]): + qualities = cycle(["1080", "720", "360"]) + + return [ + {"link": link["link"], "quality": quality} + for link, quality in zip(links, qualities) + ] + + def decode_hex_string(hex_string): """some of the sources encrypt the urls into hex codes this function decrypts the urls