Browse Source

--trust-location

boyska 2 years ago
parent
commit
92813b05ee
1 changed files with 9 additions and 1 deletions
  1. 9 1
      ics2mdwn.py

+ 9 - 1
ics2mdwn.py

@@ -25,6 +25,7 @@ def get_parser():
         default="data/schedule.yml",
         type=Path,
     )
+    p.add_argument('--trust-location', type=str, nargs='*', default=[])
     p.add_argument("--night-threshold", metavar="HOUR", default=5, type=int)
     p.add_argument("--mode", choices=["hugo"], default="hugo")
     return p
@@ -54,6 +55,7 @@ class Converter:
         self.rooms = []
         self.talks = {}
         self.talk_room = {}  # map talk uid to room name
+        self.talk_location = {} # same, but see --trust-location
         self.changed_files = []
 
     def _fname_to_room(self, fpath: str) -> str:
@@ -75,6 +77,12 @@ class Converter:
                     uid = ev.decoded("uid").decode("ascii")
                     self.talks[uid] = ev
                     self.talk_room[uid] = room
+                    self.talk_location[uid] = room
+                    if fpath in self.args.trust_location:
+                        try:
+                            self.talk_location[uid] = ev.decoded('location').decode('utf8')
+                        except:
+                            pass
 
     def run(self):
         self.rooms = [self._fname_to_room(fpath) for fpath in self.args.files]
@@ -105,7 +113,7 @@ class HugoConverter(Converter):
                         format="conference",
                         start=talk.decoded("DTSTART"),
                         end=talk.decoded("DTEND"),
-                        location=self.talk_room[uid],
+                        location=self.talk_location[uid],
                         duration=int(
                             (
                                 talk.decoded("DTEND") - talk.decoded("DTSTART")