Re: plugin neutron pour Oxyradio
| Added on 2009-05-29 13:54:11 |
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
49
50
51
52
53
#$ 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 oxyradio@conference.oxyradio.net ''' radio = get_oxyradio() current = radio[9] title = current.split('-')[0] artist = current.split('-')[1] message = 'Se joue actuellement : '+artist+' - '+title smsg(type, source, message) def oxy_adherer(type, source, param): msg('oxyradio@conference.oxyradio.net', 'pour adhérer à l\'association Oxyradio, rends-toi à l\'adresse suivante : http://www.oxyradio.net/adhesion.html') def oxy_ecouter(type, source, param): msg('oxyradio@conference.oxyradio.net', 'Écoute en OGG : http://www.oxyradio.net/listen/hd-ogg.pls - Ecoute en MP3 : http://www.oxyradio.net/listen/hd-mp3.pls') register_command_handler(send_current_song, '!current', 0, '', '', ['']) register_command_handler(oxy_adherer, '!adherer', 0, '', '', ['']) register_command_handler(oxy_ecouter, '!ecouter', 0, '', '', ['']) # tests if __name__ == '__main__': radio_info = get_oxyradio() current = radio_info[9] title = current.split('-')[0] artist = current.split('-')[1] print title, artist

