0

I want to include actors from films in my Tautulli newsletter for my Plex media collection. The newsletter template file is html and the language is mako so a mix of python, html and css.

This code returns the correct values

<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif;font-weight: 400;margin: 0;max-width: 325px;color: #ffffff;">

Actors: ${movie['actors']}

</p>

It appears like

Actors: [u'Amalia Williamson', u'Celina Martin', u'Joelle Farrow']

To be usable I'd need to remove the the unicode characters

 [u'

I have tried a couple of things and this was the most promising lead, however I couldn't get it to work.

Can anyone please amend the code so it will work please? Thank you!

  • Possible duplicate of [Remove unicode character from python string](https://stackoverflow.com/questions/46154561/remove-unicode-character-from-python-string) – C. Lightfoot Mar 22 '19 at 12:16
  • Please edit the answer to show how exactly you want the output to look like. – lenz Mar 22 '19 at 12:53
  • [This thread](https://stackoverflow.com/questions/761361/suppress-the-uprefix-indicating-unicode-in-python-strings) is maybe relevant to your problem too. – lenz Mar 22 '19 at 12:54
  • Thank you for the responses. For the above example I wanted the output to be Actors: Glynn Turman, Hailee Steinfeld, Jason The answer given by snakecharmerb worked perfectly! – Dave Matthews Mar 23 '19 at 10:33

1 Answers1

1

movie['actors'] appears to be a list, so rendering it will the repr of the list and its contents. Joining the invidual strings into a lrager string should do what you want.

>>> print u', '.join([u'Amalia Williamson', u'Celina Martin', u'Joelle Farrow'])
Amalia Williamson, Celina Martin, Joelle Farrow

In your template:

Actors: ${u', '.join(movie['actors'])}
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153