Returns either a Song or Artist result from search_genius_web
350229
def _get_item_from_search_response(self, response, type_):
        
        sections = sorted(response['sections'],
                          key=lambda sect: sect['type'] == type_,
                          reverse=True)
        for section in sections:
            hits = [hit for hit in section['hits'] if hit['type'] == type_]
            if hits:
                return hits[0]['result']
1311439
def get_artist_by_mbid(self, mbid):
        """"""

        params = {"mbid": mbid}

        doc = _Request(self, "artist.getInfo", params).execute(True)

        return Artist(_extract(doc, "name"), self)
428354
def get_audiomack_data(url):
    

    data = {}
    request = requests.get(url)

    mp3_url = request.text.split('class="player-icon download-song" title="Download" href="')[1].split('"')[0]
    artist = request.text.split('<span class="artist">')[1].split('</span>')[0].strip()
    title = request.text.split('<span class="artist">')[1].split('</span>')[1].split('</h1>')[0].strip()
    artwork_url = request.text.split('<a class="lightbox-trigger" href="')[1].split('" data')[0].strip()

    data['mp3_url'] = mp3_url
    data['title'] = title
    data['artist'] = artist
    data['artwork_url'] = artwork_url
    data['year'] = None

    return data
785014
def searchString( self, instring, maxMatches=_MAX_INT ):
        
        return ParseResults([ t for t,s,e in self.scanString( instring, maxMatches ) ])
142524
def search(query, results=10, suggestion=False):
  '''
  
  '''

  search_params = {
    'list': 'search',
    'srprop': '',
    'srlimit': results,
    'limit': results,
    'srsearch': query
  }
  if suggestion:
    search_params['srinfo'] = 'suggestion'

  raw_results = _wiki_request(search_params)

  if 'error' in raw_results:
    if raw_results['error']['info'] in ('HTTP request timed out.', 'Pool queue is full'):
      raise HTTPTimeoutError(query)
    else:
      raise WikipediaException(raw_results['error']['info'])

  search_results = (d['title'] for d in raw_results['query']['search'])

  if suggestion:
    if raw_results['query'].get('searchinfo'):
      return list(search_results), raw_results['query']['searchinfo']['suggestion']
    else:
      return list(search_results), None

  return list(search_results)
444188
def _result_is_match(self, result, title, artist=None):
        
        result_title = self._clean_str(result['title'])
        title_is_match = result_title == self._clean_str(title)
        if not artist:
            return title_is_match
        result_artist = self._clean_str(result['primary_artist']['name'])
        return title_is_match and result_artist == self._clean_str(artist)
440058
def get_metadata(file_name, client_id, client_secret):
    

    song_name = improve_name(file_name)  # Remove useless words from title
    client_credentials_manager = SpotifyClientCredentials(client_id, client_secret)

    spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
    results = spotify.search(song_name, limit=1)

    results = results['tracks']['items'][0]  # Find top result
    album = results['album']['name']  # Parse json dictionary
    artist = results['album']['artists'][0]['name']
    song_title = results['name']
    album_art = results['album']['images'][0]['url']

    return artist, album, song_title, album_art
1093661
def get_now_playing(self):
        

        params = self._get_params()
        params["limit"] = "1"

        doc = self._request(self.ws_prefix + ".getRecentTracks", False, params)

        tracks = doc.getElementsByTagName("track")

        if len(tracks) == 0:
            return None

        e = tracks[0]

        if not e.hasAttribute("nowplaying"):
            return None

        artist = _extract(e, "artist")
        title = _extract(e, "name")

        return Track(artist, title, self.network, self.name)
131873
def getAlbumsForArtist(artist,featuring=nil,extras=nil,start=nil,count=nil)
      method = 'getAlbumsForArtist'
      type = Album
      args = {:artist=>artist}
      args[:featuring] = featuring if featuring
      args[:extras] = extras if extras
      args[:start] = start if start
      args[:count] = count if count
      return_object type,method,args
    end
851536
def get_similar(artist_id, options={})
      api_response = @api_client.make_api_request(:GET, "artist/similar", {:artistId => artist_id}, options)
      @api_client.artist_digestor.list_from_xml_doc(api_response.item_xml("artists"))
    end
752866
def _search_result(self, name, tipo, obsres, resultid):
        """"""

        instrument = obsres.instrument

        conf = obsres.configuration.uuid

        drp = self.drps.query_by_name(instrument)
        label = drp.product_label(tipo)

        # search results of these OBs
        for prod in self.prod_table[instrument]:
            pid = prod['id']
            if pid == resultid:
                # this is a valid product
                # We have found the result, no more checks
                # Make a copy
                rprod = dict(prod)

                if 'content' in prod:
                    path = prod['content']
                else:
                    # Build path
                    path = build_product_path(drp, self.rootdir, conf, name, tipo, obsres)
                _logger.debug("path is %s", path)
                rprod['content'] = self.product_loader(tipo, name, path)
                return StoredProduct(**rprod)
        else:
            msg = 'result with id %s not found' % (resultid, )
            raise NoResultFound(msg)
454447
def getSearchUrl(self, album, artist):
    
    # build request url
    params = collections.OrderedDict()
    params["method"] = "album.getinfo"
    params["api_key"] = __class__.API_KEY
    params["album"] = album
    params["artist"] = artist

    return __class__.assembleUrl(__class__.BASE_URL, params)
210140
def get_album(self):
        """"""

        doc = self._request(self.ws_prefix + ".getInfo", True)

        albums = doc.getElementsByTagName("album")

        if len(albums) == 0:
            return

        node = doc.getElementsByTagName("album")[0]
        return Album(_extract(node, "artist"), _extract(node, "title"), self.network)
1283043
def song(self):
        """"""
        if self._song is None:
            self._song = Song(self._song_data)

        return self._song
834821
def search(self, song_title, limit=1):
        
        url = "http://music.163.com/api/search/pc"
        headers = {'Cookie': 'appver=1.5.2',
                   'Referer': 'http://music.163.com'}
        payload = {'s': song_title,
                   'limit': limit,
                   'type': 1}

        r = requests.post(url, params=payload, headers=headers)
        data = json.loads(r.text)

        if data['code'] == 200:
            return data['result']['songs'][0]
        else:
            return None
393622
def get_artists(self, *args, **kwargs):
        
        args = tuple(['artists'] + list(args))
        return self.get_music_library_information(*args, **kwargs)
477292
def select_one_song(songs):
        

        if len(songs) == 1:
            select_i = 0
        else:
            table = PrettyTable(['Sequence', 'Song Name', 'Artist Name'])
            for i, song in enumerate(songs, 1):
                table.add_row([i, song['name'], song['ar'][0]['name']])
            click.echo(table)

            select_i = click.prompt('Select one song', type=int, default=1)
            while select_i < 1 or select_i > len(songs):
                select_i = click.prompt('Error Select! Select Again', type=int)

        song_id, song_name = songs[select_i-1]['id'], songs[select_i-1]['name']
        song = Song(song_id, song_name)
        return song