plugin neutron pour Oxyradio
| Added on 2009-05-29 03:23:26 |
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#$ neutron_plugin 01 # -*- coding: utf-8 -*- # # Copyright © 2009 louiz' <louizatakk@fedoraproject.org> # # Plugin récupérant la current song passant sur oxyradio.net # et aussi d'autres infos dont on se fout totalement import BeautifulSoup import urllib2 def get_oxyradio(): ''' returns a dictionnary containing many informations about the radio ''' url = 'http://oxyradio.net:8000/status.xsl' page = urllib2.urlopen(url).read() soup = BeautifulSoup.BeautifulSoup(page) info = soup('td', {'class': 'streamdata'}) radio_info = [elem.string for elem in info] return radio_info def send_current_song(type, source, param): ''' get artist and title, and send it to the room ''' radio = get_oxyradio() current = radio[9] title = current.split('-')[0] artist = current.split('-')[1] message = 'Se joue actuellement : '+artist+' - '+title smsg(type, source, message) register_command_handler(send_current_song, '!current', 0, '', '', ['']) # tests if __name__ == '__main__': radio_info = get_oxyradio() # y'a peut-être d'autres trucs qu'on peut vouloir récupérer # y'a plein de trucs dans radio_info, même si on s'en fout, de # la plupart. Ce qui tourne actuellement est juste le 9eme élément current = radio_info[9] title = current.split('-')[0] artist = current.split('-')[1] print title, artist

