29 lines
839 B
Python
29 lines
839 B
Python
|
#!/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
|