25 lines
682 B
Python
Executable File
25 lines
682 B
Python
Executable File
#!/usr/bin/env python3
|
|
from argparse import ArgumentParser
|
|
from idb import fetch_article, translate_markdown
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
def save(file, content):
|
|
with open(file, 'w') as f:
|
|
f.write(content)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = ArgumentParser()
|
|
parser.add_argument('-url', '--url', type=str, required=True, help='article link')
|
|
parser.add_argument('--output', nargs=2, metavar=('FILE_RU', 'FILE_EN'),
|
|
help="output files")
|
|
args = parser.parse_args()
|
|
|
|
a = fetch_article(args.url)
|
|
translation = translate_markdown(a.md)
|
|
|
|
save(args.output[0], a.md)
|
|
save(args.output[1], translation)
|