Example #1
0
def DoGetImages(artist):
    try:
        images = []
        total = GetTotal(artist)
        pages = GetRandomPage(total)

        for page in range(0, len(pages)):
            url = ROOT + artist + '/+images?page=%d' % pages[page]

            link = common.GetHTML(url)

            match = re.compile('<a href="/music/(.+?)"').findall(link)

            for img in match:
                try:
                    id = int(img.rsplit('/', 1)[1])
                    img = 'http://userserve-ak.last.fm/serve/500/' + str(
                        id) + '.jpg'
                    if img not in images:
                        images.append(img)
                except:
                    pass

            if len(images) == 0:
                return images

    except Exception, e:
        pass
Example #2
0
def GetURL(artist):
    try:
        reverse = ''
        split = artist.split('+')
        for item in split:
            reverse = item + reverse
        forward = artist.replace('+', '')

        #NB forward and reverse DO NOT contain any '+'

        url = 'http://www.allmusic.com/search/artists/' + artist

        print NAME + ' 1st URL requested: %s' % url
        link = common.GetHTML(url, referer=ROOT)

        match = re.compile(
            '<a href="/artist/(.+?)" data-tooltip.+?alt="(.+?)">').findall(
                link)

        for url, artist in match:
            artist = artist.replace(' ', '').upper()
            if (forward in artist) or (reverse in artist):
                return ROOT + url

        #all else fails, just return the first one
        return ROOT + match[0][0]

    except Exception, e:
        print str(e)
        pass
Example #3
0
def RequestLetter(letter):
    if not IsPlaying(GETTEXT(30030)):
        return

    if letter == '0-9':
        url = 'http://ramfm.org/requests/playlist0.php'
    else:
        url = 'http://ramfm.org/requests/playlist%s.php' % letter

    response = common.GetHTML(url)

    recent = GetRecent(response.split('Recently Requested...')[0])
    response = response.split('Search Artist by Last Name')[1]
    hide = ADDON.getSetting('HIDE').lower() == 'true'

    response = response.split('<img src="http://ramfm.org/artistpic/')

    for item in response:
        try:
            if 'javascript' in item:
                addAvailable(item, recent, hide)
            elif not hide:
                addUnavailable(item)
        except Exception, e:
            print str(e)
Example #4
0
def GetImages(artist):
    if artist == '':
        return []

    artist = artist.upper().replace(' & ', ' ').replace(',', '+').replace(
        '(', '').replace(')', '').replace(' ', '+')
    artist = artist.replace('++', '+')

    try:
        url = ROOT + 'api/getdata.php?type=2&s=' + artist
        images = []

        #print NAME + ' 1st URL requested: %s' % url
        link = common.GetHTML(url)

        max = -1
        url = None

        match = re.compile(
            '<div class="item-name"><a href="/(.+?)".+?<span class="pop">(.+?)</span>'
        ).findall(link)
        for link, qty in match:
            qty = int(qty)
            if max < qty:
                max = qty
                url = link

        if not url:
            return images

        url = ROOT + url

        #print NAME + ' 2nd URL requested: %s' % url
        link = common.GetHTML(url)

        match = re.compile(
            'href="/fanart/(.+?).(?:jpg|png|jpeg|JPG)"').findall(link)

        for img in match:
            if img + '.jpg' in link:
                images.append(ROOT + 'fanart/' + img + '.jpg')
            elif img + '.JPG' in link:
                images.append(ROOT + 'fanart/' + img + '.JPG')
            elif img + '.jpeg' in link:
                images.append(ROOT + 'fanart/' + img + '.jpeg')
    except Exception, e:
        pass
Example #5
0
def GetHTML(url=URL, artist=None):
    if artist:
        url += '?' + artist

    html = common.GetHTML(url)
    html = html.replace('&quot', '')

    return html
Example #6
0
    def UpdateImage(self, url):
        self.Clear()

        html = common.GetHTML(url)
        html = html.replace('\n', '')
        html = html.split('<p >')[-1]
        match = re.compile(
            '(.+?)</p>.+?<img alt=".+?" src="(.+?)".+?<strong>(.+?)</strong>(.+?)</span>'
        ).findall(html)

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

        if 'revious' in html:
            self.previous = re.compile(
                '<span class="archiveText"><a href="(.+?)">&lt').search(
                    html).groups(1)[0]

        if 'ext &gt' in html:
            self.next = re.compile(
                '<span class="archiveText"><a href=".+?">&lt.+?<a href="(.+?)"'
            ).search(html).groups(1)[0]

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

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

        self.UpdateControls()

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

        return True
Example #7
0
def Section(url):
    url = URL + '/explore/' + url
    html = common.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)
Example #8
0
def GetTotal(artist):
    #url   = ROOT + artist +'/+images
    url = ROOT + artist + '/+images?page=1'
    total = 1

    try:
        html = common.GetHTML(url)
        if html == '':
            return 0

        match = re.compile('\?page=(\d+)"').findall(html)
        for item in match:
            n = int(item)
            if total < n:
                total = n
    except:
        pass

    return total
Example #9
0
def RequestLetter(letter):
    if not IsPlaying(GETTEXT(30030)):
        return

    if letter == '0-9':
        url = 'http://ramfm.org/momentum/cyan/playlist0.php'
    else:
        url = 'http://ramfm.org/momentum/cyan/playlist%s.php' % letter

    response = common.GetHTML(url)

    hide = ADDON.getSetting('HIDE').lower() == 'true'

    items = response.split('<!-- start')[1:]
    for item in items:
        item = item.replace(' (& ', ' (& ')
        mode = MODE_FREE
        if '<i>song recently played</i>' in item:
            mode = MODE_IGNORE if hide else MODE_SONG
        if '<i>artist recently played</i>' in item:
            mode = MODE_IGNORE if hide else MODE_ARTIST

        if mode == MODE_FREE:
            match = re.compile(
                '<a href="javascript:request\((.+?)\)" title="(.+?)">.+?<img src="http://ramfm.org/artistpic/(.+?)".+?alt="(.+?)">'
            ).findall(item)[0]
            request = match[0]
            title = match[1]
            image = match[2]
            artist = match[3]
            addAvailable(title, artist, image, request)

        if mode == MODE_ARTIST or mode == MODE_SONG:
            item = item.replace('&nbsp;', ' ')
            match = re.compile(
                'title="(.+?)".+?<p><img src="http://ramfm.org/artistpic/(.+?)".+?alt="(.+?)">(.+?)\(<i>'
            ).findall(item)[0]
            reason = match[0]
            title = match[3].split('  ')[2]
            image = match[1]
            artist = match[2]
            addUnavailable(title, artist, image, reason)
def GetImages(artist):
    if artist == '':
        return []

    artist = artist.upper().replace(' & ',' ').replace(',','+').replace('(','').replace(')','').replace(' ','+')
    artist = artist.replace('++', '+')

    try:
        url = SEARCH + artist#.replace('+', ' ')

        images = []

        #print NAME + ' 1st URL requested: %s' % url           
        link = common.GetHTML(url)

        match = re.compile('<id>(.+?)</id>').findall(link)

        for id in match:
            img = ROOT + API + '/download/' + id  + '/fullsize'
            images.append(img)

    except Exception, e:
        pass
Example #11
0
def GetImages(artist):
    if artist == '':
        return []

    artist = artist.upper().replace(' & ', ' ').replace(',', '+').replace(
        '(', '').replace(')', '').replace(' ', '+')
    artist = artist.replace('++', '+')

    images = []

    try:
        url = GetURL(artist)

        print NAME + ' 2nd URL requested: %s' % url

        if url != '':
            link = common.GetHTML(url, referer=ROOT)
            link = link.replace('\n', '')

            #image1 = re.compile('<meta name="image" content="(.+?).jpg').search(link).group(1)
            #images.append(image1+'.jpg')

            gallery = link.split('Photo Gallery', 1)[1]
            gallery = gallery.split('<span class', 1)[0]
            gallery = gallery.replace('_jpg', '*j*p*g')

            match = re.compile('<img src="(.+?).jpg').findall(gallery)
            for img in match:
                #if 'cps-static.rovicorp.com/3' in img:
                if 'rovi' in img:
                    img = img.replace('*j*p*g', '_jpg')
                    img = img.replace('170', '500')
                    images.append(img + '.jpg')

    except Exception, e:
        print str(e)
        pass
Example #12
0
def DoGetImages(artist):
    try:
        url = SEARCH + artist

        images = []

        #print NAME + ' 1st URL requested: %s' % url
        link = common.GetHTML(url)
        link = link.replace(',', '\n')

        matchJPG = re.compile('http(.+?).jpg').findall(link)
        #matchPNG = re.compile('http(.+?).png').findall(link)

        for img in matchJPG:
            img = 'http' + img + '.jpg'
            images.append(img)

        #PNG don't work in XBMC slideshow
        #for img in matchPNG:
        #    img = 'http' + img + '.png'
        #    images.append(img)

    except Exception, e:
        pass