Browse Source

categories

boyska 2 years ago
parent
commit
f7938c3025
1 changed files with 23 additions and 19 deletions
  1. 23 19
      ics2mdwn.py

+ 23 - 19
ics2mdwn.py

@@ -103,27 +103,31 @@ class HugoConverter(Converter):
             fname = "%s.md" % uid
             fpath = self.args.out_md_dir / fname
             self.changed_files.append(fpath)
+            frontmatter = (
+                dict(
+                    key=uid,
+                    title=talk.decoded("SUMMARY").decode("utf8"),
+                    format="conference",
+                    start=talk.decoded("DTSTART"),
+                    end=talk.decoded("DTEND"),
+                    location=self.talk_location[uid],
+                    duration=int(
+                        (
+                            talk.decoded("DTEND") - talk.decoded("DTSTART")
+                        ).total_seconds()
+                        // 60
+                    ),
+                ),
+            )
+            if "CATEGORIES" in talk:
+                frontmatter["tags"] = [str(t) for t in talk.get("CATEGORIES").cats]
+            else:
+                frontmatter["tags"] = []
+            if 'base' in frontmatter['tags']:
+                frontmatter['level'] = 'Principiante'
             with open(str(fpath), "w") as buf:
-                # preamble
                 buf.write("---\n")
-                yaml.safe_dump(
-                    dict(
-                        key=uid,
-                        title=talk.decoded("SUMMARY").decode("utf8"),
-                        format="conference",
-                        start=talk.decoded("DTSTART"),
-                        end=talk.decoded("DTEND"),
-                        location=self.talk_location[uid],
-                        duration=int(
-                            (
-                                talk.decoded("DTEND") - talk.decoded("DTSTART")
-                            ).total_seconds()
-                            // 60
-                        ),
-                        tags=[],
-                    ),
-                    buf,
-                )
+                yaml.safe_dump(frontmatter, buf)
                 buf.write("---\n\n")
                 # body
                 if "DESCRIPTION" in talk: