reroute hashtag to its _ prefixed version if it exists

This commit is contained in:
Tomáš Mládek 2019-10-03 13:10:24 +02:00
parent 2e416d3412
commit 099e3322b1

View file

@ -391,6 +391,15 @@ class DelojzaBot:
.format(urls, message.chat.title, hashtags)) .format(urls, message.chat.title, hashtags))
hashtags.insert(0, "PUBLIC") 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.last_hashtags[message.chat.id] = None
self.logger.info("Downloading %s under '%s'" % (urls, "/".join(hashtags))) self.logger.info("Downloading %s under '%s'" % (urls, "/".join(hashtags)))