|
@@ -31,9 +31,10 @@ except: |
|
|
print(filedir) |
|
|
print(filedir) |
|
|
public_path = filedir + '/public' |
|
|
public_path = filedir + '/public' |
|
|
assets_path = public_path + '/assets' |
|
|
assets_path = public_path + '/assets' |
|
|
|
|
|
feeds_path = public_path + '/feeds' |
|
|
|
|
|
|
|
|
# e.g. https://example.com/some-string |
|
|
# e.g. https://example.com/some-string |
|
|
base_url = config['base_url'] |
|
|
|
|
|
|
|
|
asset_url = config['asset_url'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -154,13 +155,13 @@ def process_feed(feed_url, output_filename): |
|
|
old_url = img['data-src'] |
|
|
old_url = img['data-src'] |
|
|
if not old_url.startswith('data:'): |
|
|
if not old_url.startswith('data:'): |
|
|
new_filename = filename_from_url(old_url) |
|
|
new_filename = filename_from_url(old_url) |
|
|
img['data-src'] = base_url + '/' + entry_dir + '/' + new_filename |
|
|
|
|
|
|
|
|
img['data-src'] = asset_url + '/' + entry_dir + '/' + new_filename |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
if img.get('src'): |
|
|
if img.get('src'): |
|
|
old_url = img['src'] |
|
|
old_url = img['src'] |
|
|
if not old_url.startswith('data:'): |
|
|
if not old_url.startswith('data:'): |
|
|
new_filename = filename_from_url(old_url) |
|
|
new_filename = filename_from_url(old_url) |
|
|
img['src'] = base_url + '/' + entry_dir + '/' + new_filename |
|
|
|
|
|
|
|
|
img['src'] = asset_url + '/' + entry_dir + '/' + new_filename |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
if img.get('data-srcset'): |
|
|
if img.get('data-srcset'): |
|
|
srcset = img['data-srcset'].split(', ') |
|
|
srcset = img['data-srcset'].split(', ') |
|
@@ -170,7 +171,7 @@ def process_feed(feed_url, output_filename): |
|
|
src_res = src.split(' ')[1] |
|
|
src_res = src.split(' ')[1] |
|
|
new_filename = filename_from_url(old_url) |
|
|
new_filename = filename_from_url(old_url) |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
download_image(old_url, entry_dir, new_filename) |
|
|
new_url = base_url + '/' + entry_dir + '/' + new_filename |
|
|
|
|
|
|
|
|
new_url = asset_url + '/' + entry_dir + '/' + new_filename |
|
|
src = ' '.join([new_url, src_res]) |
|
|
src = ' '.join([new_url, src_res]) |
|
|
new_srcset.append(src) |
|
|
new_srcset.append(src) |
|
|
img['data-srcset'] = ', '.join(new_srcset) |
|
|
img['data-srcset'] = ', '.join(new_srcset) |
|
@@ -200,7 +201,10 @@ def process_feed(feed_url, output_filename): |
|
|
e.append(content_tag) |
|
|
e.append(content_tag) |
|
|
f_content.close |
|
|
f_content.close |
|
|
|
|
|
|
|
|
f = open(public_path + '/' + output_filename, 'w') |
|
|
|
|
|
|
|
|
# create directory if not present |
|
|
|
|
|
os.makedirs(feeds_path, exist_ok=True) |
|
|
|
|
|
|
|
|
|
|
|
f = open(feeds_path + '/' + output_filename, 'w') |
|
|
f.write(str(feed_soup.prettify())) |
|
|
f.write(str(feed_soup.prettify())) |
|
|
f.close() |
|
|
f.close() |
|
|
|
|
|
|
|
|