From 2494a0856856fb1c6078d088c132761496fb46f9 Mon Sep 17 00:00:00 2001 From: Michael Rodin Date: Fri, 28 Jul 2023 21:18:10 +0200 Subject: [PATCH] first commit --- .gitignore | 4 ++++ main.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 .gitignore create mode 100755 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cb5c1f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/** + +!/main.py +!/.gitignore diff --git a/main.py b/main.py new file mode 100755 index 0000000..3db4c3d --- /dev/null +++ b/main.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +import regex,json + +playlists={"format":"Piped","version":1,"playlists":[]} + +eingabe="" +while not eingabe == "q": + eingabe=input("('q' to quit)\nEnter the name of your playlist: ") + if eingabe == "q": + break + + linkfile=open('links.txt', 'r') + links=[] + for link in linkfile.readlines(): + link=link.rstrip() + if not regex.match('^http(s)?:\/\/(www\.youtube\.com\/watch\?v=|youtu\.be\/)[-\w]{10,}', link): + print(f"SKIP: {link}") + continue + print(link) + links.append(link) + playlist={"name":eingabe,"type":"playlist","visibility":"private","videos":links} + playlists["playlists"].append(playlist) + print(f"Added: {eingabe}") + linkfile.close() + +playfile=open("playlists.json","w") +playfile.write(str(json.dumps(playlists))) +playfile.close