Adds two config options to the INI file, in the [hashtaglist] section:

tag_delimiter defines a character in the RSS feed delimiting tags

tag_force overrides existing tags in an RSS feed

example:

tag_delimiter=,
tag_force=tabletop,gaming,dnd
This commit is contained in:
klaatu 2019-02-27 00:07:59 +13:00
parent 04d5441be4
commit c40499ea7b

View file

@ -128,6 +128,16 @@ class Main:
}
severalwordsinhashtag = False
try:
delimiter=config.get('hashtaglist','tag_delimiter')
except:
delimiter=False
try:
tagforce=config.get('hashtaglist', 'tag_force')
except:
tagforce=False
# lets see if the rss feed has hashtag
if 'tags' in entry and options['addtags']:
hastags = True
@ -145,7 +155,7 @@ class Main:
tmphashtags = prehashtags.replace(element,
''.join(element.split()))
# replace characters stopping a word from being a hashtag
if severalwordsinhashtag:
if severalwordsinhashtag and not tagforce:
# remove ' from hashtag
tmphashtags = tmphashtags.replace("'", "")
# remove - from hashtag
@ -154,7 +164,15 @@ class Main:
tmphashtags = tmphashtags.replace(".", "")
# remove space from hashtag
finalhashtags = tmphashtags.replace(" ", "")
# swap delimiter with hash
finalhashtags = tmphashtags.replace(delimiter, " #")
rss['hashtags'].append('#{}'.format(finalhashtags))
elif tagforce:
tmphashtags = tuple(tagforce.split(delimiter))
for t in tmphashtags:
#rss['hashtags'].append(t)
#finalhashtags = tmphashtags.replace(",", " #")
rss['hashtags'].append('#{}'.format(t))
else:
nospace = ''.join(entry['tags'][i]['term'])
# remove space from hashtag