Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitizing markdown and getting social media names #63

Merged
merged 10 commits into from
Apr 2, 2020
16 changes: 14 additions & 2 deletions blottertrax/description_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,20 @@ def get_reply(self, parsed_submission: ParsedSubmission) -> str:

life_span = '' if has_life_span is False else '({} to {})'.format(life_span_begin, life_span_end)
tags = ', '.join(map(lambda t: t['name'], artist['tag-list'][:5])) if has_tags else 'none'
socials = ', '.join(map(lambda u: '[{}]({})'.format(u['type'], u['target']),
artist['url-relation-list'])) if has_socials else 'none'
socials = map(lambda u: '[{}]({})'.format(u['type'], '\)'.join(u['target'].split(')'))),
artist['url-relation-list']) if has_socials else 'none'
if socials != 'none':
This conversation was marked as resolved.
Show resolved Hide resolved
social_network = ["twitter.com", "facebook.com", "instagram.com"]
for i in range(len(socials)):
cur_item = socials[i].split(']')
if cur_item[0] == '[social network':
for domain in social_network:
if domain in cur_item[1]:
cur_item[0] = '[' + domain.split('.')[0]
break
socials[i] = ']'.join(cur_item)
socials = ', '.join(socials)


return templates.musicbrainz_artist_info.strip().format(
artist['name'],
Expand Down