diff options
author | mathieui <mathieui@mathieui.net> | 2013-03-11 02:04:20 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-03-11 02:04:20 +0100 |
commit | 71c35eb279b2271b89896dcff551ba762f66b3a5 (patch) | |
tree | 280bc7e66b453310851dcb4e9793e9f4083561eb /src/common.py | |
parent | eb2e5825bceec1171f0e154cb72f5870576a94f2 (diff) | |
download | poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.gz poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.bz2 poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.tar.xz poezio-71c35eb279b2271b89896dcff551ba762f66b3a5.zip |
Implement XEP-0118 (Fix #1840)
- Add new theming options
- Show the tune in the roster (both in contact line and infowin)
- add an option to show tunes as info messages
Diffstat (limited to 'src/common.py')
-rw-r--r-- | src/common.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/common.py b/src/common.py index 1a3027e7..5b62732c 100644 --- a/src/common.py +++ b/src/common.py @@ -278,6 +278,43 @@ def parse_secs_to_str(duration=0): result = '0s' return result +def format_tune_string(infos): + """ + Contruct a string from a dict created from an "User tune" event. + + :param dict infos: The informations + :return: The formatted string + :rtype: :py:class:`str` + """ + elems = [] + track = infos.get('track') + if track: + elems.append(track) + title = infos.get('title') + if title: + elems.append(title) + else: + elems.append('Unknown title') + elems.append('-') + artist = infos.get('artist') + if artist: + elems.append(artist) + else: + elems.append('Unknown artist') + + rating = infos.get('rating') + if rating: + elems.append('[ ' + rating + '/10' + ' ]') + length = infos.get('length') + if length: + length = int(length) + secs = length % 60 + mins = length // 60 + secs = str(secs).zfill(2) + mins = str(mins).zfill(2) + elems.append('[' + mins + ':' + secs + ']') + return ' '.join(elems) + def safeJID(*args, **kwargs): """ Construct a :py:class:`sleekxmpp.JID` object from a string. |