Archived
1
0
Fork 0
This repository has been archived on 2024-06-28. You can view files and clone it, but cannot push or open issues or pull requests.
rss2wallabag/add.py

30 lines
664 B
Python
Raw Normal View History

2017-02-12 21:41:51 +01:00
import sys
import yaml
from urllib.parse import urlparse
2017-02-12 21:51:25 +01:00
with open("sites.yaml", 'r') as stream:
sites = yaml.safe_load(stream)
2017-02-12 21:41:51 +01:00
try:
name = sys.argv[1]
feedurl = input("URL: ")
parsed = urlparse(feedurl)
if not (parsed.scheme and parsed.netloc and parsed.path):
print("invalid URL")
exit()
tags = []
while True:
tag = input("Tag: ")
if tag == "":
break
tags.append(tag)
sites[name] = {"url": feedurl, "tags": tags}
except Exception as e:
print("invalid input")
print(e)
2017-02-12 21:51:25 +01:00
with open('sites.yaml', 'w') as outfile:
2017-02-12 21:41:51 +01:00
yaml.dump(sites, outfile, default_flow_style=False)