Example #1
2
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter("div"):
            if "shadow" != channel.get("class"):
                continue
            url = u"" + channel.find("a").get("href")
            radio = Radio(url[(url.rfind("/") + 1) :].replace(".pls", ""))
            radio.title = u"" + channel.getprevious().text
            radio.description = u""

            current_data = u""
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            stream = Stream(stream_id)
            stream.title = radio.title
            stream.url = url
            radio.streams.append(stream)

            radios.append(radio)

        return radios
Example #2
1
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        radioName,network=radio.id.split('.',1)

        self._fetch_radio_list(network)

        if not radioName in self.RADIOS[network]:
            return None

        radio_dict = self.RADIOS[network][radioName]
        radio.title = radio_dict['name']
        radio.description = radio_dict['description']

        artist, title = self.get_current(network,radioName)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        name=self._get_stream_name(network,self.config['quality'].get())
        stream = Stream(name)
        stream.title = u'%s %skbps' %\
                (self.NETWORKS[network]['streams'][name]['fmt'],
                 self.NETWORKS[network]['streams'][name]['rate'])
        stream.url = 'http://listen.%s/%s/%s.pls'%\
                (self.NETWORKS[network]['domain'],name,radioName)
        radio.streams.append(stream)
        return radio
Example #3
0
 def get_current_emission(self):
     current = Emission(0)
     current.artist = unicode(
         self.document.xpath('//playlist/now/entry/artist')[0].text)
     current.title = unicode(
         self.document.xpath('//playlist/now/entry/song')[0].text)
     return current
Example #4
0
    def get_radio(self, radio):
        self._fetch_radio_list()

        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self.RADIOS:
            return None

        radio_dict = self.RADIOS[radio.id]
        radio.title = radio_dict["name"]
        radio.description = radio_dict["description"]

        artist, title = self.get_current(radio.id)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        for stream_id, format in enumerate(self.FORMATS):
            stream = Stream(stream_id)
            stream.title = u"%s %skbps" % format
            stream.url = self._get_playlist_url(radio.id, format)
            radio.streams.append(stream)
        return radio
Example #5
0
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        radioName, network = radio.id.split('.', 1)

        self._fetch_radio_list(network)

        if not radioName in self.RADIOS[network]:
            return None

        radio_dict = self.RADIOS[network][radioName]
        radio.title = radio_dict['name']
        radio.description = radio_dict['description']

        artist, title = self.get_current(network, radioName)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        name = self._get_stream_name(network, self.config['quality'].get())
        stream = Stream(name)
        stream.title = u'%s %skbps' %\
                (self.NETWORKS[network]['streams'][name]['fmt'],
                 self.NETWORKS[network]['streams'][name]['rate'])
        stream.url = 'http://listen.%s/%s/%s.pls'%\
                (self.NETWORKS[network]['domain'],name,radioName)
        radio.streams.append(stream)
        return radio
Example #6
0
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter('div'):
            if ("shadow" != channel.get('class')):
                continue
            url = u'' + channel.find('a').get('href')
            radio = Radio(url[(url.rfind('/') + 1):].replace('.pls', ''))
            radio.title = u'' + channel.getprevious().text
            radio.description = u""

            current_data = u""
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            stream = Stream(stream_id)
            stream.title = radio.title
            stream.url = url
            radio.streams.append(stream)

            radios.append(radio)

        return radios
Example #7
0
    def get_radio(self, radio):
        self._fetch_radio_list()

        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self.RADIOS:
            return None

        radio_dict = self.RADIOS[radio.id]
        radio.title = radio_dict['name']
        radio.description = radio_dict['description']

        artist, title = self.get_current(radio.id)
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        radio.streams = []
        for stream_id, format in enumerate(self.FORMATS):
            stream = Stream(stream_id)
            stream.title = u'%s %skbps' % format
            stream.url = self._get_playlist_url(radio.id, format)
            radio.streams.append(stream)
        return radio
Example #8
0
    def _fetch_radio_list(self):
        radios = []

        document = self.browser.location(self.ALLINFO)
        for channel in document.iter('channel'):
            radio = Radio(channel.get('id'))
            radio.title = channel.findtext('title')
            radio.description = channel.findtext('description')

            current_data = channel.findtext('lastPlaying')
            current = Emission(0)
            current.artist, current.title = self._parse_current(current_data)
            radio.current = current

            radio.streams = []
            stream_id = 0
            for subtag in channel:
                if subtag.tag.endswith('pls'):
                    stream = Stream(stream_id)
                    stream.title = '%s/%s' % (subtag.tag.replace('pls', ''), subtag.get('format'))
                    stream.url = subtag.text
                    radio.streams.append(stream)
                    stream_id += 1

            radios.append(radio)

        return radios
Example #9
0
 def get_current_emission(self):
     current = Emission(0)
     two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ')
     # Consider that if String(' - ') appears it'll be in title rather in the artist name
     if len(two_or_more) > 2:
       current.artist = two_or_more.pop(0)
       current.title = ' - '.join(two_or_more)
     else:
       current.artist, current.title = two_or_more
     return current
Example #10
0
 def get_current_emission(self):
     current = Emission(0)
     two_or_more = unicode(
         self.document.xpath('//p')[0].text).split('/////')[0].split(' - ')
     # Consider that if String(' - ') appears it'll be in title rather in the artist name
     if len(two_or_more) > 2:
         current.artist = two_or_more.pop(0)
         current.title = ' - '.join(two_or_more)
     else:
         current.artist, current.title = two_or_more
     return current
Example #11
0
 def fill_radio(self, radio, fields):
     if 'current' in fields:
         artist = title = None
         if radio.id in self._PLAYERJS_RADIOS:
             artist, title = self.browser.get_current_playerjs(radio.id)
             if title.endswith(u'par %s' % artist):
                 artist = None
         if radio.id in self._DIRECTJSON_RADIOS:
             dartist, dtitle = self.browser.get_current_direct(radio.id)
             if dartist:
                 artist = dartist
             if dtitle:
                 if title:
                     title = u"%s [%s]" % (dtitle, title)
                 else:
                     title = dtitle
         elif radio.id in self._LARGEDIRECTJSON_RADIOS:
             dartist, dtitle = self.browser.get_current_direct_large(
                 radio.id)
             if dartist:
                 artist = dartist
             if dtitle:
                 title = dtitle
         if radio.id in self._RSS_RADIOS:
             title = self.browser.get_current_rss(radio.id)
         if title:
             if not radio.current or radio.current is NotLoaded:
                 radio.current = Emission(0)
             radio.current.title = title
             radio.current.artist = artist
     return radio
Example #12
0
 def fill_radio(self, radio, fields):
     if 'current' in fields:
         if not radio.current:
             radio.current = Emission(0)
         radio.current.artist, radio.current.title = self.get_current(
             radio.id)
     return radio
Example #13
0
 def fill_radio(self, radio, fields):
     if 'current' in fields:
         radioName, network = radio.id.split('.', 1)
         radio.current = Emission(0)
         radio.current.artist, radio.current.title = self.get_current(
             network, radioName)
         return radio
Example #14
0
    def get_radio(self, radio):
        if not isinstance(radio, Radio):
            radio = Radio(radio)

        if not radio.id in self._RADIOS:
            return None

        title, description, url = self._RADIOS[radio.id]
        radio.title = title
        radio.description = description

        artist, title = self.get_current()
        current = Emission(0)
        current.artist = artist
        current.title = title
        radio.current = current

        stream = Stream(0)
        stream.title = u'128kbits/s'
        stream.url = url
        radio.streams = [stream]
        return radio
Example #15
0
 def get_current_emission(self):
     self.document.xpath('//p')[0].text
     current = Emission(0)
     current.artist, current.title = self.document.xpath(
         '//p')[0].text.split('/////')[0].split(' - ')
     return current
Example #16
0
 def get_current_emission(self):
     current = Emission(0)
     current.artist = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text)
     current.title = unicode(self.document.xpath('//playlist/now/entry/song')[0].text)
     return current