1
0
Fork 0

Merge pull request #47 from m-rossi/fix_archive_dir

Fix usage of ARCHIVE_DIR if an exisiting archive is updated
This commit is contained in:
Nick Sweeting 2017-11-02 14:52:55 -05:00 committed by GitHub
commit 30ce8c6a9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -254,7 +254,7 @@ def find_link(folder, links):
timestamp = folder.split('.')[0]
for link in links:
if link['timestamp'].startswith(timestamp):
if link['domain'] in os.listdir('./html/archive/' + folder):
if link['domain'] in os.listdir(os.path.join(ARCHIVE_DIR, 'html/archive', folder)):
return link # careful now, this isn't safe for most ppl
if link['domain'] in parse_url(folder):
return link
@ -263,7 +263,7 @@ def find_link(folder, links):
def parse_url(folder):
"""for a given archive folder, figure out what url it's for"""
link_json = os.path.join('./html/archive/' + folder, 'index.json')
link_json = os.path.join(ARCHIVE_DIR, 'html/archive', folder, 'index.json')
if os.path.exists(link_json):
with open(link_json, 'r') as f:
try:
@ -274,7 +274,7 @@ def parse_url(folder):
except ValueError:
print('File contains invalid JSON: {}!'.format(link_json))
archive_org_txt = os.path.join('./html/archive/' + folder, 'archive.org.txt')
archive_org_txt = os.path.join(ARCHIVE_DIR, 'html/archive' + folder, 'archive.org.txt')
if os.path.exists(archive_org_txt):
with open(archive_org_txt, 'r') as f:
original_link = f.read().strip().split('/http', 1)[-1]