Re: plugin neutron pour Oxyradio

louizlouiz
Added on 2009-05-29 13:54:11
plugin neutron pour Oxyradio - Show - Edit - Download
Re: plugin neutron pour Oxyradio - Show - Edit - Download - Differences
#$ 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