'Get a specified number of results for a query'

def _get_n_results(self, query, n):

    entries = []
    for pagenum in itertools.count(0):
        result_url = (u'http://video.search.yahoo.com/search/?p=%s&fr=screen&o=js&gs=0&b=%d' % (compat_urllib_parse.quote_plus(query), (pagenum * 30)))
        info = self._download_json(result_url, query, note=(u'Downloading    results    page    ' + str((pagenum + 1))))
        m = info[u'm']
        results = info[u'results']
        for (i, r) in enumerate(results):
            if (((pagenum * 30) + i) >= n):
                break
            mobj = re.search(u'(?P<url>screen\\.yahoo\\.com/.*?-\\d*?\\.html)"', r)
            e = self.url_result((u'http://' + mobj.group(u'url')), u'Yahoo')
            entries.append(e)
        if ((((pagenum * 30) + i) >= n) or (m[u'last'] >= (m[u'total'] - 1))):
            break
    return {u'_type': u'playlist', u'id': query, u'entries': entries}
