Add redis pumper 🍆

This commit is contained in:
2021-11-06 17:21:59 +01:00
parent 9815bf080d
commit bb7062397e
5 changed files with 139 additions and 3 deletions
+21
View File
@@ -0,0 +1,21 @@
import json
from aiotube import Playlist
import redis
import sys
if len(sys.argv) < 2:
raise Exception("Expected path to file as argument")
config_path = sys.argv[1]
config = json.load(open("config.json", "r", encoding="utf-8"))
redis_prefix = config["redis_prefix"]
redis_client = redis.from_url(config["redis_url"])
file = open(config_path, "r")
for line in file:
playlist = Playlist(line)
for vid in playlist.videos():
yt_url = vid.url
redis_client.sadd(f"{redis_prefix}:playlist", yt_url)
print(yt_url)