Exemplo n.º 1
0
    def get(self, album, extra):
        """Return art URL from iTunes Store given an album title.
        """
        if not (album.albumartist and album.album):
            return
        search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
        try:
            # Isolate bugs in the iTunes library while searching.
            try:
                results = itunes.search_album(search_string)
            except Exception as exc:
                self._log.debug(u'iTunes search failed: {0}', exc)
                return

            # Get the first match.
            if results:
                itunes_album = results[0]
            else:
                self._log.debug(u'iTunes search for {:r} got no results',
                                search_string)
                return

            if itunes_album.get_artwork()['100']:
                small_url = itunes_album.get_artwork()['100']
                big_url = small_url.replace('100x100', '1200x1200')
                yield self._candidate(url=big_url, match=Candidate.MATCH_EXACT)
            else:
                self._log.debug(u'album has no artwork in iTunes Store')
        except IndexError:
            self._log.debug(u'album not found in iTunes Store')
Exemplo n.º 2
0
def itunes_art(album):
    """Return art URL from iTunes Store given an album title.
    """
    search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
    try:
        itunes_album = itunes.search_album(search_string)[0]
        if itunes_album.get_artwork()['100']:
            small_url = itunes_album.get_artwork()['100']
            big_url = small_url.replace('100x100', '1200x1200')
            return big_url
        else:
            log.debug(u'fetchart: album has no artwork in iTunes Store')
    except IndexError:
        log.debug(u'fetchart: album not found in iTunes Store')
Exemplo n.º 3
0
def fetch_itunes_album_art(album_artist, album, filename):
    try:
        import itunes
    except ImportError:
        print('Couldn\'t load the "itunes" module! Skipping art retrieval.')
        return

    albums = itunes.search_album('%s %s' % (album_artist, album))
    if not len(albums):
        return
    _, low_res = albums[0].get_artwork().popitem()
    high_res = low_res[:low_res.rindex('/') + 1] + '100000x100000-999.jpg'
    urllib.request.urlretrieve(high_res, filename)
    return filename
Exemplo n.º 4
0
def itunes_art(album):
    """Return art URL from iTunes Store given an album title.
    """
    search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
    try:
        itunes_album = itunes.search_album(search_string)[0]
        if itunes_album.get_artwork()['100']:
            small_url = itunes_album.get_artwork()['100']
            big_url = small_url.replace('100x100', '1200x1200')
            yield big_url
        else:
            log.debug(u'fetchart: album has no artwork in iTunes Store')
    except IndexError:
        log.debug(u'fetchart: album not found in iTunes Store')
Exemplo n.º 5
0
 def getCoverUrl(self, album_title):
     try:
         album = itunes.search_album(album_title)[0]
         aa=album.get_artwork()
         bb=aa['100'].replace('100x100','225x225')
         fname=bb[bb.rfind("/")+1:len(bb)]
     except Exception:
         #logger.info("NO COVER AVAILABLE")
         return "default.jpg"            
     if ( os.path.isfile(cover_dir+fname) ==False) :
         urllib.urlretrieve (bb, cover_dir+fname)
     return fname
     
     
     pass
Exemplo n.º 6
0
def find_item(params):
    '''

    :param params: a dictionary
    :return: a tuple (name_of_stuff, links_of_stuff)
    '''
    # initiate a string for query
    global global_price
    query = ""
    result = []
    par = []  # designed to store the parameters
    for k, v in params.items():
        if v not in ["movie", "music"]:
            # just need query parameters
            par.append(v)
        else: par = [v]
    # create query
    query = " ".join(par)
    #print("query:{}".format(query))

    # Match the stuff that the user want
    if "movie" in list(params.keys()):

        result = itunes.search_movie(query=query)

    elif "app" in list(params.keys()):

        result = itunes.search_app(query=query)

    elif "music" in list(params.keys()):

        result = itunes.search_album(query=query)

    if result:

        display_result = random.choices(result)[0]
        # Because the results are too many, then we just return the random one

        # refresh the price of the newest inquire result:
        global_price = display_result.price
       # print("get_item_price:{}".format(display_result.price))

        return display_result.name, display_result.url


    else:
        return None
Exemplo n.º 7
0
    def get(self, album):
        """Return art URL from iTunes Store given an album title.
        """
        search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
        try:
            # Isolate bugs in the iTunes library while searching.
            try:
                itunes_album = itunes.search_album(search_string)[0]
            except Exception as exc:
                self._log.debug('iTunes search failed: {0}', exc)
                return

            if itunes_album.get_artwork()['100']:
                small_url = itunes_album.get_artwork()['100']
                big_url = small_url.replace('100x100', '1200x1200')
                yield big_url
            else:
                self._log.debug(u'album has no artwork in iTunes Store')
        except IndexError:
            self._log.debug(u'album not found in iTunes Store')
Exemplo n.º 8
0
def itunes_art(album):
    """Return art URL from iTunes Store given an album title.
    """
    search_string = (album.albumartist + ' ' + album.album).encode('utf-8')
    try:
        # Isolate bugs in the iTunes library while searching.
        try:
            itunes_album = itunes.search_album(search_string)[0]
        except Exception as exc:
            log.debug('fetchart: iTunes search failed: {0}', exc)
            return

        if itunes_album.get_artwork()['100']:
            small_url = itunes_album.get_artwork()['100']
            big_url = small_url.replace('100x100', '1200x1200')
            yield big_url
        else:
            log.debug(u'fetchart: album has no artwork in iTunes Store')
    except IndexError:
        log.debug(u'fetchart: album not found in iTunes Store')
Exemplo n.º 9
0
def test_search_album():
    assert_equal(
        itunes.search_album('u2 achtung baby')[0].get_type(), COLLECTION_KIND)
Exemplo n.º 10
0
def test_search_album():
    assert_equal(itunes.search_album('u2 achtung baby')[0].get_id(), U2_ACHTUNGBABY_ID)
Exemplo n.º 11
0
 def _search(self, artist, album):
     super(ItunesPlugin, self)._search(artist, album)
     return search_album(artist + ' ' + album, 5)
Exemplo n.º 12
0
def test_search_album():
    assert_equal(itunes.search_album('u2 achtung baby')[0].get_id(), U2_ACHTUNGBABY_ID)
Exemplo n.º 13
0
def test_search_album():
    assert itunes.search_album('u2 achtung baby')[0].id == U2_ACHTUNGBABY_ID
Exemplo n.º 14
0
def test_search_album():
    assert itunes.search_album('u2 achtung baby')[0].id == U2_ACHTUNGBABY_ID
Exemplo n.º 15
0
def test_search_album():
    assert_equal(itunes.search_album('u2 achtung baby')[0].get_type(), COLLECTION_KIND)