Esempio n. 1
0
    def startElement(self, name, attributes):
        if name == "station":
            self.entry = RadioStation()
            self.entry.type = "Board"
            self.entry.id = attributes.get("id")
            self.entry.server_name = attributes.get("name")
            self.entry.genre = attributes.get("tags")
            if (self.entry.genre == None):
                self.entry.genre = ""
            self.entry.genre = ",".join(self.entry.genre.split(" "))
            self.entry.listen_url = attributes.get("url")
            self.entry.language = attributes.get("language")
            self.entry.country = attributes.get("country")
            self.entry.votes = attributes.get("votes")
            self.entry.negativevotes = attributes.get("negativevotes")
            self.entry.homepage = attributes.get("homepage")
            self.entry.icon_src = attributes.get("favicon")
            try:
                self.entry.clickcount = attributes.get("clickcount")
            except:
                self.entry.clickcount = 0
            self.entries.append(self.entry)

            if self.entry.country.title() not in self.countries:
                self.countries.append(self.entry.country.title())
            if self.entry.language.title() not in self.languages:
                self.languages.append(self.entry.language.title())
Esempio n. 2
0
    def load_stations_list(self):
        """Load radio station list"""
        with open('radio.json') as f:
            sts = json.load(f)

        self.stations = []
        for s in sts:
            self.stations.append(RadioStation(s))
 def startElement(self, name, attributes):
     self.currentEntry = name
     if name == "entry":
         self.entry = RadioStation()
         self.entry.type = "Icecast"
 def record_play_button_handler(self, button, uri):
     station = RadioStation()
     station.server_name = self.stream_name
     station.listen_url = "http://127.0.0.1:" + self.relay_port
     station.type = "local"
     self.play_cb(station)
Esempio n. 5
0
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

from radio_station import RadioStation

__author__ = "HP Envy"
__date__ = "$Nov 19, 2014 4:16:15 PM$"

if __name__ == "__main__":
    radio_station = RadioStation(12)
    radio_station.run()
#radio_station.__init__(radio_station, 8)
import logging
from logging.handlers import TimedRotatingFileHandler
from rootio.extensions import db

telephony_server = Flask("ResponseServer")
telephony_server.debug = True
telephony_server.config[
    'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost/rootio'

if __name__ == "__main__":
    #setup logging
    app_logger = logging.getLogger('station_runner')
    hdlr = TimedRotatingFileHandler('/var/log/rootio/stations.log',
                                    when='midnight',
                                    interval=1)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    app_logger.addHandler(hdlr)
    app_logger.setLevel(logging.DEBUG)

    db = SQLAlchemy(telephony_server)
    stations = db.session.query(Station).all()
    for station in stations:
        radio_station = RadioStation(station.id, app_logger)
        app_logger.info('launching station : {0}'.format(station.id))
        t = threading.Thread(target=radio_station.run, args=())
        t.start()

    print "================ service started at {0} ==============".format(
        datetime.utcnow())