human
Complete this python program:
def _search(progtext, qs=None, msg=None, failmsg=None):
assistant
#Here is the Python program you requested.

    """Perform memoized url fetch, display progtext.
    """
    loadmsg = ("Searching    for    '%s%s%s'" % (c.y, progtext, c.w))
    wdata = pafy.call_gdata('search', qs)
    def iter_songs():
        wdata2 = wdata
        while True:
            for song in get_tracks_from_json(wdata2):
                (yield song)
            if (not wdata2.get('nextPageToken')):
                break
            qs['pageToken'] = wdata2['nextPageToken']
            wdata2 = pafy.call_gdata('search', qs)
    length = min(wdata['pageInfo']['totalResults'], 500)
    slicer = util.IterSlicer(iter_songs(), length)
    paginatesongs(slicer, length=length, msg=msg, failmsg=failmsg, loadmsg=loadmsg)