From 099e3322b1be826043875c1fa3e8359ec849570f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 3 Oct 2019 13:10:24 +0200 Subject: [PATCH] reroute hashtag to its _ prefixed version if it exists --- delojza.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/delojza.py b/delojza.py index 15736d2..9d94742 100755 --- a/delojza.py +++ b/delojza.py @@ -391,6 +391,15 @@ class DelojzaBot: .format(urls, message.chat.title, hashtags)) hashtags.insert(0, "PUBLIC") + for i in range(len(hashtags)): + current_path = hashtags[:i + 1] + if not os.path.isdir(os.path.join(self.out_dir, *current_path)): + test_path = current_path + test_path[-1] = "_" + test_path[-1] + if os.path.isdir(os.path.join(self.out_dir, *test_path)): + self.logger.debug(f"Rerouting {current_path[-1]} to _{test_path[-1]}") + hashtags[i] = test_path[-1] + self.last_hashtags[message.chat.id] = None self.logger.info("Downloading %s under '%s'" % (urls, "/".join(hashtags)))