aboutsummaryrefslogtreecommitdiffstats
path: root/convert.py
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2024-03-01 05:48:07 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2025-06-15 01:30:22 +0200
commit3d1c10e7ddff73bb9061126dfce58895c31abaa8 (patch)
tree90dd23e24952a106d6fda273925d0c63004b2b36 /convert.py
parentc10f47a5296f92879f83225b0f0d1d7b3b3c3a09 (diff)
downloadhaunt-blog-3d1c10e7ddff73bb9061126dfce58895c31abaa8.tar.gz
haunt-blog-3d1c10e7ddff73bb9061126dfce58895c31abaa8.tar.bz2
haunt-blog-3d1c10e7ddff73bb9061126dfce58895c31abaa8.zip
Start adding blog post authors and licenses.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'convert.py')
-rwxr-xr-xconvert.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/convert.py b/convert.py
index a2eeb20..f5f4e62 100755
--- a/convert.py
+++ b/convert.py
@@ -145,6 +145,21 @@ def get_metadata(html_file_path):
return ', '.join(results)
+ def get_author(soup):
+ results = []
+ author_vcard = soup.article.find_all('span', class_='author vcard')
+ assert(len(author_vcard) == 1)
+ link = author_vcard[0].find_all('a')
+ assert(len(link) == 1)
+ return link[0].string
+
+ # Returns SPDX license declaration.
+ def get_licenses(soup):
+ if get_author(soup) == 'GNUtoo':
+ return 'CC-BY-3.0 OR CC-BY-4.0'
+ else:
+ return None
+
def get_title(soup):
title = soup.title.string
title = title.replace(os.linesep, '')
@@ -164,10 +179,17 @@ def get_metadata(html_file_path):
# assert(title_metadata != None)
# metadata += "title: {}".format(title_metadata)
+ authors_metadata = _get_metadata(html_file_path, get_author)
+ metadata += "title: {}".format(authors_metadata) + os.linesep
+
tags_metadata = _get_metadata(html_file_path, get_tags)
if tags_metadata:
print("tags: {}".format(tags_metadata))
+ licenses_metadata = _get_metadata(html_file_path, get_licenses)
+ if licenses_metadata:
+ print("licenses: {}".format(licenses_metadata))
+
metadata += "---" + os.linesep
return metadata