Esempio n. 1
0
    def POST(self, format):
        cgi.maxlen = settings.MAX_UP_FILE_SIZE
        if not format:
            format = '.json'

        input = web.input(file={})
        if input.file.file:
            if not is_mp3(input.file.file):
                return simplejson.dumps({
                    'code':
                    1,
                    'error':
                    'Check file format and try again'
                })
            try:
                info = get_mp3_info(input.file.file)
                info['FILENAME'] = input.file.filename
            except:
                return simplejson.dumps({
                    'code':
                    2,
                    'error':
                    'Error getting file information'
                })
            id = storage.save(info, input.file.file, db.master)
            search.update(id, info)
        return simplejson.dumps({'code': 0})
Esempio n. 2
0
	def POST(self):
		cgi.maxlen = settings.MAX_UP_FILE_SIZE

		input = web.input(file={})
		if input.file.file:
			if not is_mp3(input.file.file):
				raise web.seeother('/upload/error')
			try:
				info = get_mp3_info(input.file.file)
				info['FILENAME'] = input.file.filename
			except:
				raise web.seeother('/upload/error')
			id = storage.save(info, input.file.file, db.master)
			search.update(id, info)
		raise web.seeother('/')
Esempio n. 3
0
    def POST(self):
        cgi.maxlen = settings.MAX_UP_FILE_SIZE

        input = web.input(file={})
        if input.file.file:
            if not is_mp3(input.file.file):
                raise web.seeother('/upload/error')
            try:
                info = get_mp3_info(input.file.file)
                info['FILENAME'] = input.file.filename
            except:
                raise web.seeother('/upload/error')
            id = storage.save(info, input.file.file, db.master)
            search.update(id, info)
        raise web.seeother('/')
Esempio n. 4
0
	def POST(self, format):
		cgi.maxlen = settings.MAX_UP_FILE_SIZE
		if not format:
			format = '.json'

		input = web.input(file={})
		if input.file.file:
			if not is_mp3(input.file.file):
				return simplejson.dumps({'code':1, 'error':'Check file format and try again'})
			try:
				info = get_mp3_info(input.file.file)
				info['FILENAME'] = input.file.filename
			except:
				return simplejson.dumps({'code':2, 'error':'Error getting file information'})
			id = storage.save(info, input.file.file, db.master)
			search.update(id, info)
		return simplejson.dumps({'code':0})
Esempio n. 5
0
def handle_file(f):
	if is_mp3(f):
		r = do_file_upload(url, f)
		check_result(r,f)
	else:
		print 'Ignore:', f
Esempio n. 6
0
        vbr = 1

    try:
      if vbr:
        tpf = float([0,384,1152,1152][int(nh['lay'])])
        tpf = tpf / ([44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000][int(nh['sampling_frequency'])] << nh['lsf'])
    except IndexError,e:
		return {}    
  while 1:
    h = get_head(word)
    if not h: break
    off=off+1
    word = getword(fp, off)
    if off>tot: 
      return {}
    if is_mp3(h): break


  fp.seek(0, 2)
  eof = fp.tell()

  try:
    fp.seek(-128, 2)
  except IOError, reason:
    return {}
  

  if h['id']:
    h['mean_frame_size'] = (144000. * h['bitrate']) / h['fs']
  else:
    h['mean_frame_size'] = (72000. * h['bitrate']) / h['fs']
Esempio n. 7
0
def handle_file(f):
    if is_mp3(f):
        r = do_file_upload(url, f)
        check_result(r, f)
    else:
        print 'Ignore:', f
Esempio n. 8
0
            if vbr:
                tpf = float([0, 384, 1152, 1152][int(nh['lay'])])
                tpf = tpf / ([
                    44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000,
                    8000
                ][int(nh['sampling_frequency'])] << nh['lsf'])
        except IndexError, e:
            return {}
    while 1:
        h = get_head(word)
        if not h: break
        off = off + 1
        word = getword(fp, off)
        if off > tot:
            return {}
        if is_mp3(h): break

    fp.seek(0, 2)
    eof = fp.tell()

    try:
        fp.seek(-128, 2)
    except IOError, reason:
        return {}

    if h['id']:
        h['mean_frame_size'] = (144000. * h['bitrate']) / h['fs']
    else:
        h['mean_frame_size'] = (72000. * h['bitrate']) / h['fs']

    h['layer'] = h['mode']