Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(5)  |  Derive(0)  |  Import(0)

        def query(track_info, server_url=default_server,
	  user=default_user, host=hostname, client_name=name,
          client_version=version):

    disc_id = track_info[0]
    num_tracks = track_info[1]

    query_str = (('%08lx %d ') % (disc_id, num_tracks))

    for i in track_info[2:]:
	query_str = query_str + ('%d ' % i)
	
    query_str = urllib.quote_plus(string.rstrip(query_str))

    url = "%s?cmd=cddb+query+%s&hello=%s+%s+%s+%s&proto=%i" % \
	  (server_url, query_str, user, host, client_name,
           client_version, proto)

    response = urllib.urlopen(url)

    # kaa.metadata unicode fix
    encoding = ''
    if response.headers.has_key('content-type'):
        for value in response.headers['content-type'].split(';'):
            if value.strip().lower().startswith('charset='):
                encoding = value[value.find('=')+1:].strip().lower()

    # Four elements in header: status, category, disc-id, title
    header = string.split(string.rstrip(response.readline()), ' ', 3)

    header[0] = string.atoi(header[0])

    if header[0] == 200:		# OK
        # kaa.metadata unicode fix
        try:
            title = unicode(header[3], encoding)
        except UnicodeDecodeError:
            title = unicode(header[3], errors='replace')
	result = { 'category': header[1], 'disc_id': header[2], 'title': title }

	return [ header[0], result ]

    elif header[0] == 211 or header[0] == 210: # multiple matches
	result = []

	for line in response.readlines():
	    line = string.rstrip(line)

	    if line == '.':		# end of matches
		break
					# otherwise:
					# split into 3 pieces, not 4
					# (thanks to bgp for the fix!)
	    match = string.split(line, ' ', 2)

            try:
                title = unicode(match[2], encoding)
            except UnicodeDecodeError:
                title = unicode(match[2], errors='replace')
            # kaa.metadata unicode fix
	    result.append({ 'category': unicode(match[0]), 'disc_id': match[1], 'title':
			    title })

	return [ header[0], result ]

    else:
	return [ header[0], None ]
        


src/d/e/deepin-music-player-HEAD/src/source/old.py   deepin-music-player(Download)
    def run(self):
        (status, info) = CDDB.query(self._disc_id,
                                    client_name="dmusic",
                                    client_version="1.0")
 

src/g/e/Gereqi-HEAD/gereqi/audio/Cdrom.py   Gereqi(Download)
 
        #query_status, query_info = CDDB.query(disc_id)
        query_info = CDDB.query(disc_id)[1]
        #read_status, read_info = CDDB.read(
        read_info = CDDB.read(query_info[0]['category'], 

src/k/a/kaa-metadata-0.7.8dev-r4569-20111003/src/disc/audio.py   kaa-metadata(Download)
        if kaa.metadata.USE_NETWORK:
            try:
                (query_stat, query_info) = CDDB.query(disc_id)
            except Exception, e:
                # Oops no connection

src/k/a/kaa-metadata-HEAD/src/disc/audio.py   kaa-metadata(Download)
        if kaa.metadata.USE_NETWORK:
            try:
                (query_stat, query_info) = CDDB.query(disc_id)
            except Exception, e:
                # Oops no connection

src/m/o/morituri-HEAD/morituri/common/program.py   morituri(Download)
        import CDDB
        try:
            code, md = CDDB.query(cddbdiscid)
            self.debug('CDDB query result: %r, %r', code, md)
            if code == 200: