url2markdown/url2markdown/__main__.py

29 lines
815 B
Python
Raw Normal View History

2020-10-12 14:11:55 +02:00
#!/usr/bin/env python
from url2markdown.cli import cli
from url2markdown.downloader import downloader
from url2markdown.file import write_to_file
from url2markdown.header import Header
2020-10-12 22:26:21 +02:00
2020-10-12 14:11:55 +02:00
def main(url, topics):
article = downloader(url)
header = Header(article, topics)
2020-10-12 22:26:21 +02:00
write_to_file(article, header.build_header())
2020-10-12 14:11:55 +02:00
if __name__ == "__main__":
args = cli()
if args.url:
main(args.url, args.topics)
if args.file:
with args.file as input_file:
for line in input_file:
try:
stripped_line = line.strip()
url, topics = stripped_line.split(' ')
except ValueError:
url = line
topics = []
2020-11-09 12:31:48 +01:00
if url != '\n':
main(url, topics)