29 lines
815 B
Python
Executable File
29 lines
815 B
Python
Executable File
#!/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
|
|
|
|
|
|
def main(url, topics):
|
|
article = downloader(url)
|
|
header = Header(article, topics)
|
|
write_to_file(article, header.build_header())
|
|
|
|
|
|
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 = []
|
|
if url != '\n':
|
|
main(url, topics)
|