|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import os, argparse, sys, re
|
|
|
|
|
from mwclient import Site
|
|
|
|
|
from mwclient import (Site,
|
|
|
|
|
errors)
|
|
|
|
|
from jinja2 import Template
|
|
|
|
|
from functions import (print_colormsg,
|
|
|
|
|
reorder_imgs)
|
|
|
|
@ -97,15 +98,19 @@ for n, _file in enumerate(lsimgs):
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_file_path = os.path.join(args.dir, _file)
|
|
|
|
|
print(_file_path)
|
|
|
|
|
if not args.dry:
|
|
|
|
|
pageurl = f'https://{args.host}{args.path}index.php/File:{pagename}'
|
|
|
|
|
with open(_file_path, 'rb') as _f:
|
|
|
|
|
try:
|
|
|
|
|
site.upload(file=_file_path,
|
|
|
|
|
filename=pagename,
|
|
|
|
|
description=img_smw_prop_val,
|
|
|
|
|
ignore=True)
|
|
|
|
|
|
|
|
|
|
print(img_smw_prop_val)
|
|
|
|
|
print(f'https://{args.host}{args.path}index.php/File:{pagename}')
|
|
|
|
|
except errors.APIError as e:
|
|
|
|
|
print_colormsg(f'Error: {e.info}\n'
|
|
|
|
|
f'It will not be uploaded',
|
|
|
|
|
level='fail')
|
|
|
|
|
|
|
|
|
|
print(f'See image at {pageurl}')
|
|
|
|
|
|
|
|
|
|