Exemple #1
0
def getChannels(stationID):
    try:
        import re
        import json

        channels = []

        url  = getStationRoot(stationID)
        html = utils.GetHTML(url)

        url = re.compile('gusto.listen.init\((.+?)\)').search(html).group(1).replace(' ', '').replace('"', '')
        url = url.split(',')
        src = url[2]
        stn = url[0]
        url = src + '/Stations/' + stn + '/Channels'
        
        html     = utils.GetHTML(url)
        response = json.loads(html)
       

        for item in response:
            try:
                name      = item['Name']
                channelID = item['ChannelId']
                image     = item['ImageFile']
                channels.append([name, image, channelID, src])

            except:
                pass
        
    except:
        pass

    return channels
Exemple #2
0
    def UpdateImage(self, url):
        self.Clear()

        #html  = utils.GetHTML(url)
        html = utils.GetHTML(url, useCache=True, timeout=86400 / 2)
        html = html.replace('\n', '')
        html = html.split('<p >')[-1]

        match = re.compile(
            '<p><a class="feature-title " href=".+?">(.+?)</a></p>.+?<img alt=".+?" src="(.+?)".+?<strong>(.+?)</strong>(.+?)</span>'
        ).findall(html)

        self.title = match[0][0]
        self.image = match[0][1]
        self.date = match[0][2]
        self.author = match[0][3]

        try:
            self.previous = re.compile('btn-archive-older"><a href="(.+?)">&lt'
                                       ).search(html).groups(1)[0]
        except:
            pass

        try:
            self.next = re.compile('btn-archive-newer"><a href="(.+?)">Newer'
                                   ).search(html).groups(1)[0]
        except Exception, e:
            pass
Exemple #3
0
def getLiveLinks(stationID):
    import re

    url   = getStationRoot(stationID)
    html  = utils.GetHTML(url)
    links = re.compile("audioUrl: '(.+?)'").findall(html)
    return links
Exemple #4
0
def channel(channelID, source):
    import json

    channelIDs = channelID.split(':')

    responses = {}
    image     = None

    for channelID in channelIDs:
        url  = source + '/Channels/' + channelID + '/Episodes'
        html = utils.GetHTML(url)

        response = json.loads(html)

        responses[channelID] = response

    for channelID in responses:
        response = responses[channelID]

        for item in response:
            try:    image = item['ImageFile']
            except: pass

    if image:
        thumb  = THUMBPATTERN  % image 
        fanart = FANARTPATTERN % image 
    else:
        thumb  = ICON 
        fanart = FANART 

    ordered = []

    download = GETTEXT(30042)

    for channelID in responses:
        response = responses[channelID]
        for item in response:
            name  = item['Name']
            desc  = item['Description']
            link  = item['MediaFiles'][0]['Filename']
            start = utils.parseDate(item['StartDate'])

            ordered.append([start, [name, desc, link]])

    ordered.sort()
    
    for item in ordered:
        name  = item[1][0]
        desc  = item[1][1]
        link  = item[1][2]
            
        menu = []

        menu.append((download, 'XBMC.RunPlugin(%s?mode=%d&url=%s&name=%s)' % (sys.argv[0], _DOWNLOAD, link, urllib.quote_plus(name))))
        
        addDirectoryItem(name, url=link, mode=_EPISODE, thumbnail=thumb, fanart=fanart, isFolder=False, isPlayable=True, menu=menu)
Exemple #5
0
def Section(url):
    url  = URL + '/explore/' + url
    html = utils.GetHTML(url, timeout=43200) #1/2 a day
    #html = html.replace('a href="/explore', '') 

    match = re.compile('<li>(.+?)</li>').findall(html)

    for item in match:
        items = re.compile('<a href="(.+?)">.+?<img alt=".+?" class="thumb" height="60" src="(.+?)" title="(.+?)"').findall(item)
        url   = items[0][0]
        image = items[0][1].replace('tiny_avatar', 'avatar')
        name  = items[0][2]
        AddCharacter(name, url, image)
Exemple #6
0
def getlocalityAPIChoice(stationID):
    import re
    url  = STATIONS[stationID][1] + 'api/1.0/station_preference/listen-live/'
    html = utils.GetHTML(url)
    html = html.replace('\\', '')
    html = html.split('<li class=')[1:]

    choices = []
    for item in html:
        items = re.compile('"(.+?)">.+?value="(.+?)".+?').findall(item)
        choices.append((items[0][1], items[0][0]))

    choices.sort()
    label, prefix = getlocalityFixedChoice(choices)

    if stationID == HEART:
        prefix = prefix.replace('radio', 'on-air') 

    return label, prefix
Exemple #7
0
def OPEN_URL(url,data,headers):
    import utils
    return utils.GetHTML(url,data,headers)
Exemple #8
0
def OPEN_URL(url):
    import utils
    return utils.GetHTML(url)
Exemple #9
0
class Display(xbmcgui.WindowXMLDialog):
    def __new__(cls, url, slideshow):
        return super(Display, cls).__new__(cls, 'main.xml',
                                           ADDON.getAddonInfo('path'))

    def __init__(self, url, slideshow):
        super(Display, self).__init__()
        self.timer = None
        self.url = url
        self.slideshow = slideshow
        self.transition = int(ADDON.getSetting('TRANSITION'))

    def onInit(self):
        self.Clear()

        if self.slideshow:
            url = utils.GetRandomURL(self.url)
        else:
            isCurrent = ADDON.getSetting('DISPLAY') == '0'

            if isCurrent:
                url = utils.GetCurrentURL(self.url)
            else:
                url = utils.GetRandomURL(self.url)

        self.UpdateImage(url)

    def Clear(self):
        self.title = ''
        self.image = None
        self.previous = None
        self.next = None
        self.author = ''
        self.date = ''

        if self.timer:
            self.timer.cancel()
            del self.timer
            self.timer = None

    def OnClose(self):
        self.Clear()
        self.close()

    def onAction(self, action):
        actionID = action.getId()
        buttonID = action.getButtonCode()

        if actionID in [
                ACTION_PARENT_DIR, ACTION_PREVIOUS_MENU, ACTION_BACK, ACTION_X
        ]:
            self.OnClose()

        if self.slideshow:
            return

        if actionID in [ACTION_LEFT, ACTION_UP]:
            if self.previous:
                self.UpdateImage(URL + self.previous)

        if actionID in [ACTION_RIGHT, ACTION_DOWN]:
            if self.next:
                self.UpdateImage(URL + self.next)

    def onClick(self, controlId):
        if controlId == CTRL_PREV_BTN:
            self.Previous()

        if controlId == CTRL_NEXT_BTN:
            self.Next()

    def Previous(self):
        if not self.previous:
            return False

        return self.UpdateImage(URL + self.previous)

    def Next(self):
        if not self.next:
            return False

        return self.UpdateImage(URL + self.next)

    def onTimer(self):
        if self.next:
            self.UpdateImage(URL + self.next)

        self.UpdateImage(utils.GetRandomURL(self.url))

    def UpdateImage(self, url):
        self.Clear()

        #html  = utils.GetHTML(url)
        html = utils.GetHTML(url, useCache=True, timeout=86400 / 2)
        html = html.replace('\n', '')
        html = html.split('<p >')[-1]

        match = re.compile(
            '<p><a class="feature-title " href=".+?">(.+?)</a></p>.+?<img alt=".+?" src="(.+?)".+?<strong>(.+?)</strong>(.+?)</span>'
        ).findall(html)

        self.title = match[0][0]
        self.image = match[0][1]
        self.date = match[0][2]
        self.author = match[0][3]

        try:
            self.previous = re.compile('btn-archive-older"><a href="(.+?)">&lt'
                                       ).search(html).groups(1)[0]
        except:
            pass

        try:
            self.next = re.compile('btn-archive-newer"><a href="(.+?)">Newer'
                                   ).search(html).groups(1)[0]
        except Exception, e:
            pass

        if self.image:
            self.setControlImage(CTRL_STRIP, self.image)

        #pre-fetch previous and next images
        if self.previous:
            self.setControlImage(
                CTRL_PREFETCH,
                self.getImage(utils.GetHTML(URL + self.previous)))
        if self.next:
            self.setControlImage(CTRL_PREFETCH,
                                 self.getImage(utils.GetHTML(URL + self.next)))

        self.UpdateControls()

        if self.slideshow:
            self.timer = Timer(self.transition, self.onTimer)
            self.timer.start()

        return True