Beispiel #1
0
def Search():
    kb = xbmc.Keyboard('', 'Search BBC Podcasts', False)
    kb.doModal()
    if not kb.isConfirmed():
        return

    search = kb.getText()
    if search == '':
        return

    #http://www.bbc.co.uk/podcasts/search.jsonp?q=m&callback=podcastCallback
    #url = 'http://www.bbc.co.uk/podcasts/quick_search/' + search
    url = 'http://www.bbc.co.uk/podcasts/search.jsonp?q=' + search

    try:
        search = geturllib.GetURL(url, 3600)  # 1 hr
        search = search.split('(', 1)[1]
        search = search.rsplit(')', 1)[0]

        jsn = json.loads(search)

        for item in jsn:
            fullTitle = item['fullTitle']
            shortTitle = item['shortTitle']
            description = item['podDescription']
            artwork = 'http://static.bbci.co.uk/podcasts/artwork/' + shortTitle + '.jpg'
            addSearchResult(fullTitle, shortTitle, artwork, description)
    except:
        pass
Beispiel #2
0
def requestLetter(mode, letter):
    if mode == _POP:
        url = '80s-Bands-and-Artists.html?bandletter=%s' % letter
    elif mode == _METAL:
        url = '80s-Metal-Bands.html?bandletter=%s' % letter
    else:
        return

    response = geturllib.GetURL(URL + url, 24 * 3600) # 24 hr

    r     = 'var artistarray = (.+?);'
    match = re.compile(r).findall(response)

    jsn = json.loads(match[0])

    artists = []
    match   = []

    if letter == '0':
        for i in range(0, 9):
            match.append(str(i))
    else:
        match.append(letter)       

    for item in jsn:
        if item[0] in match:
            if item not in artists:
                artists.append(item)
    
    for artist in artists:
        addArtist(artist)
Beispiel #3
0
def requestArtistWithMode(artist, mode):
    if mode == _POP:
        url = URL + 'Explore-the-80s.html?band=%s' % artist
    elif mode == _METAL:
        url = URL + 'Explore-80s-Metal.html?band=%s' % artist
    else:
        return False

    response = str(geturllib.GetURL(url, 24 * 3600)) # 24 hr
    respone  = response.replace('\r', '').replace('\n', '').replace('\t', '')

    try:
        response = response.split('var videoarray = ')[1]
        response = response.split('var artistarray = ')[0]

        jsn = json.loads(response.strip()[:-1])

        for item in jsn:
            try:
                id   = item['ID']
                song = item['Song']
                addVideo(song, id)
            except:
                pass
    except:
        return False
    
    return True
Beispiel #4
0
def Search():
    kb = xbmc.Keyboard('', 'Search BBC Podcasts', False)
    kb.doModal()
    if not kb.isConfirmed():
        return

    search = kb.getText()
    if search == '':
        return

    url = 'http://www.bbc.co.uk/podcasts/search.json?q=' + search

    try:
        search = geturllib.GetURL(url, 3600)  # 1 hr

        jsn = json.loads(search)

        for item in jsn:
            try:
                title = item['title']
                url = item['link'] + '.rss'
                description = item['description'].replace(
                    '<span class="pc-quickfind-match">',
                    '').replace('</span>', '')
                thumb = fixImage(item['image'], '256x256')
                fanart = fixImage(item['image'], '1280x720')
                addSearchResult(title, url, thumb, fanart, description)
                print artwork
            except:
                pass

    except:
        pass
Beispiel #5
0
def GetHTML(url, useCache = True, referer=None):
    if useCache:
        html = geturllib.GetURL(url, 1800, referer=referer)
    else:
        html = geturllib.GetURLNoCache(url, referer=referer)

    html  = html.replace('\n', '')
    return html
Beispiel #6
0
def GetHTML(url, useCache=True, timeout=604800):  #1 week
    if useCache:
        html, cached = geturllib.GetURL(url, timeout)
    else:
        html = geturllib.GetURLNoCache(url)

    html = html.replace('\n', '')
    return html
Beispiel #7
0
def getHTML(url, useCache = True):
    if useCache:
        html, cached = geturllib.GetURL(url, 86400)
    else:
        html = geturllib.GetURLNoCache(url)

    html  = html.replace('\n', '')
    return html
Beispiel #8
0
def requestLetter(url, letter):
    response = geturllib.GetURL(url, 60 * 60 * 24)  # 1 day

    r = 'vid=(.+?)</a>'
    match = re.compile(r).findall(response)

    for item in match:
        if item[0].upper() == letter:
            addItem(url, item)
Beispiel #9
0
def GetFullHTML(url, useCache=True, timeout=604800):  #1 week
    agent = ' Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
    if useCache:
        html, cached = geturllib.GetURL(url, timeout, agent=agent)
    else:
        html = geturllib.GetURLNoCache(url, agent=agent)

    html = html.replace('\n', '')
    return html
Beispiel #10
0
def _getProgramsAPI(channels, lineup, startTime, endTime, cacheOnly):
    if (not lineup) or len(lineup) < 1:
        return [{'error': 'Invalid Tribune Lineup'}]

    chnIDs = ''
    for key in channels:
        chnIDs += channels[key].tribuneID + ','

    if (not chnIDs) or len(chnIDs) < 1:
        return [{'error': 'Invalid Tribune Channel'}]

    #chnIDs = chnIDs[:-1] #remove final comma

    plus1 = '+' in chnIDs
    chnIDs = chnIDs.replace('+', '')
    offset = HOUR if plus1 else ZERO

    URL = 'http://data.tmsapi.com/v1/lineups/'

    startTime = _convertTimeToAPI(startTime - offset)
    endTime = _convertTimeToAPI(endTime)

    #detail = 'Basic'
    detail = 'Detailed'
    #detail = 'DetailedNoImage'

    #imageSize = 'Sm'
    #imageSize = 'Md'
    imageSize = 'Lg'
    #imageSize = 'Ms'

    #aspect = '2x3'
    #aspect = '3x4'
    aspect = '4x3'
    #aspect = '16x9'

    url = '%s%s/grid?stationId=%s&startDateTime=%s&endDateTime=%s&size=%s&imageSize=%s&imageAspectTV=%s&imageText=false&api_key=%s' % (
        URL, lineup, chnIDs, startTime, endTime, detail, imageSize, aspect,
        API)

    #print "Requested URL %s" % url

    try:
        response = geturllib.GetURL(url, SECSINDAY, cacheOnly)
    except:
        return [{'error': 'No Response'}]

    if len(response) < 1:
        return []

    try:
        return json.loads(response)
    except:
        return [{'error': 'Invalid Response'}]

    return [{'error': 'Invalid Response'}]
Beispiel #11
0
def GetOPML():
    global Year
    opml = ElementTree.fromstring(geturllib.GetURL(URL, 3600))  # 1 hr

    try:
        head = opml.find('head')
        date = head.findtext('dateModified').split(' ')
        Year = int(date[3])
    except:
        pass

    return opml
Beispiel #12
0
def LoadShow(url, genre, keyname):
    xml = ElementTree.fromstring(geturllib.GetURL(url, 3600))  # 1 hr

    channel = xml.find('channel')
    title = channel.findtext('title')
    imageT = channel.find('image')
    image = imageT.findtext('url')

    for item in channel.findall('item'):
        name = item.findtext('title')
        desc = item.findtext('description')
        url = item.findtext('link')
        content = item.find(".//{http://search.yahoo.com/mrss/}content")
        duration = find(lambda item: item[0] == 'duration', content.items())
        addPodcast(name, url, genre, keyname, title, duration, image, desc)
Beispiel #13
0
def LoadSearchResult(url):
    url = 'http://www.bbc.co.uk/podcasts/series/' + url

    try:
        response = geturllib.GetURL(url, 3600)  # 1 hr
        rss = 'http://downloads' + re.compile('downloads(.+?)rss.xml').findall(
            response)[0] + 'rss.xml'
        #keyname  = re.findall("var keyname = '(.+?)'", response)[0]
        keyname = re.findall('class="pc-desktop pc-keyname-(.+?)">',
                             response)[0]
        genres = re.findall('ul class="pc-results-box-genres">(.+?)</ul>',
                            response)[0]
        genres = re.findall('<li>(.+?)</li>', genres)
        genre = ''
        for g in genres:
            genre = genre + CleanString(g) + ', '
        if len(genre) > 2:
            genre = genre[:-2]
        LoadShow(rss, genre, keyname)
    except:
        pass