Mercurial > libervia-backend
comparison src/plugins/plugin_misc_radiocol.py @ 1411:8767c0bb7d48
plugin radiocol: radiocolSongAdded now gets a JID as argument, add _radiocolSongAdded working with unicode for bridge calls
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 17 Apr 2015 19:05:37 +0200 |
parents | 3265a2639182 |
children | 94901070478e |
comparison
equal
deleted
inserted
replaced
1410:e2e75c3c7c7b | 1411:8767c0bb7d48 |
---|---|
87 preload_elt['timestamp'] = str(time.time()) | 87 preload_elt['timestamp'] = str(time.time()) |
88 # attributes filename, title, artist, album, length have been copied | 88 # attributes filename, title, artist, album, length have been copied |
89 # XXX: the frontend should know the temporary directory where file is put | 89 # XXX: the frontend should know the temporary directory where file is put |
90 return preload_elt | 90 return preload_elt |
91 | 91 |
92 def _radiocolSongAdded(self, referee_s, song_path, profile): | |
93 return self.radiocolSongAdded(jid.JID(referee_s), song_path, profile) | |
94 | |
92 def radiocolSongAdded(self, referee, song_path, profile): | 95 def radiocolSongAdded(self, referee, song_path, profile): |
93 """This method is called by libervia when a song has been uploaded | 96 """This method is called by libervia when a song has been uploaded |
94 @param referee: JID of the referee in the room (room userhost + '/' + nick) | 97 @param referee (jid.JID): JID of the referee in the room (room userhost + '/' + nick) |
95 @song_path: absolute path of the song added | 98 @param song_path (unicode): absolute path of the song added |
96 @param profile_key: %(doc_profile_key)s | 99 @param profile_key (unicode): %(doc_profile_key)s |
97 @return: a Deferred instance | 100 @return: a Deferred instance |
98 """ | 101 """ |
99 # XXX: this is a Q&D way for the proof of concept. In the future, the song should | 102 # XXX: this is a Q&D way for the proof of concept. In the future, the song should |
100 # be streamed to the backend using XMPP file copy | 103 # be streamed to the backend using XMPP file copy |
101 # Here we cheat because we know we are on the same host, and we don't | 104 # Here we cheat because we know we are on the same host, and we don't |
123 'title': song.get("title", ["Unknown"])[0], | 126 'title': song.get("title", ["Unknown"])[0], |
124 'artist': song.get("artist", ["Unknown"])[0], | 127 'artist': song.get("artist", ["Unknown"])[0], |
125 'album': song.get("album", ["Unknown"])[0], | 128 'album': song.get("album", ["Unknown"])[0], |
126 'length': str(song.info.length) | 129 'length': str(song.info.length) |
127 } | 130 } |
128 radio_data = self.games[jid.JID(referee).userhostJID()] # FIXME: referee comes from Libervia's client side, it's unsecure | 131 radio_data = self.games[referee.userhostJID()] # FIXME: referee comes from Libervia's client side, it's unsecure |
129 radio_data['to_delete'][attrs['filename']] = song_path # FIXME: works only because of the same host trick, see the note under the docstring | 132 radio_data['to_delete'][attrs['filename']] = song_path # FIXME: works only because of the same host trick, see the note under the docstring |
130 return self.send(jid.JID(referee), ('', 'song_added'), attrs, profile=profile) | 133 return self.send(referee, ('', 'song_added'), attrs, profile=profile) |
131 | 134 |
132 def playNext(self, room_jid, profile): | 135 def playNext(self, room_jid, profile): |
133 """"Play next song in queue if exists, and put a timer | 136 """"Play next song in queue if exists, and put a timer |
134 which trigger after the song has been played to play next one""" | 137 which trigger after the song has been played to play next one""" |
135 # TODO: songs need to be erased once played or found invalids | 138 # TODO: songs need to be erased once played or found invalids |