26 lines
702 B
Python
Executable File
26 lines
702 B
Python
Executable File
#!/usr/bin/env python3
|
|
from argparse import ArgumentParser
|
|
from idb.wordpress import fetch
|
|
from idb.translator import translate
|
|
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()
|
|
|
|
article = fetch(args.url)
|
|
translation = translate(article.md)
|
|
|
|
save(args.output[0], article.md)
|
|
save(args.output[1], translation)
|