first commit

This commit is contained in:
Michael Rodin 2023-07-28 21:18:10 +02:00
commit 2494a08568
2 changed files with 32 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/**
!/main.py
!/.gitignore

28
main.py Executable file
View file

@ -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