Browse Source

new regex, to avoid overriding Image01.png with 01.png

master
manetta 3 years ago
parent
commit
678e40334e
  1. 10
      command-line/update.py
  2. 10
      web-interface/update.py

10
command-line/update.py

@ -81,8 +81,14 @@ def download_media(html, images, wiki):
time.sleep(3) # do not overload the server
# replace src link
image_path = f'/{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
html = re.sub(rf'src="/book/images/.*{ filename }"', f'src="{ image_path }"', html)
image_path = f'{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
matches = re.findall(rf'src="/book/images/.*?px-{ filename }"', html) # for debugging
if matches:
html = re.sub(rf'src="/book/images/.*?px-{ filename }"', f'src="{ image_path }"', html)
else:
matches = re.findall(rf'src="/book/images/.*?{ filename }"', html) # for debugging
html = re.sub(rf'src="/book/images/.*?{ filename }"', f'src="{ image_path }"', html)
# print(f'{filename}: {matches}\n------') # for debugging: each image should have the correct match!
return html

10
web-interface/update.py

@ -82,8 +82,14 @@ def download_media(html, images, wiki):
time.sleep(3) # do not overload the server
# replace src link
image_path = f'/{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
html = re.sub(rf'src="/book/images/.*{ filename }"', f'src="{ image_path }"', html)
image_path = f'{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
matches = re.findall(rf'src="/book/images/.*?px-{ filename }"', html) # for debugging
if matches:
html = re.sub(rf'src="/book/images/.*?px-{ filename }"', f'src="{ image_path }"', html)
else:
matches = re.findall(rf'src="/book/images/.*?{ filename }"', html) # for debugging
html = re.sub(rf'src="/book/images/.*?{ filename }"', f'src="{ image_path }"', html)
# print(f'{filename}: {matches}\n------') # for debugging: each image should have the correct match!
return html

Loading…
Cancel
Save