예제 #1
0
파일: web.py 프로젝트: Oroggs/musiclib
def apply_musicbrainz_cover_to_album(id):
	id = int(id)
	album = Album.query.filter(Album.id == id).first()
	if album is None:
		return jsonify({'status': False})
	mid = request.json['mid']
	add_file_task({'type': 'album_musicbrainz_cover', 'album_id': id, 'mid': mid})
	return jsonify({'status': True})
예제 #2
0
파일: web.py 프로젝트: Oroggs/musiclib
def album_match_acoustid(id):
	id = int(id)
	album = Album.query.filter(Album.id == id).first()
	if album is None:
		return jsonify({'status': False})
	songs = Song.query.filter(Song.album_id == id).order_by(Song.track).all()
	album.tracks = songs
	add_file_task({'type': 'album_acoustid', 'album_id': id}, album)
	return jsonify({'status': True})
예제 #3
0
파일: web.py 프로젝트: Oroggs/musiclib
def album_cuetools_verify(id):
	id = int(id)
	album = Album.query.filter(Album.id == id).first()
	if album is None:
		return jsonify({'status': False})
	if album.format != 'flac':
		return jsonify({'status': False})
	songs = Song.query.filter(Song.album_id == id).order_by(Song.track).all()
	album.tracks = songs
	add_file_task({'type': 'album_cuetools', 'album_id': id}, album)
	return jsonify({'status': True})
예제 #4
0
파일: web.py 프로젝트: Oroggs/musiclib
def album_upload_remote():
	url = request.json['url']
	u = urlparse(url)
	if u.scheme not in ['http', 'https']:
		return jsonify({'status': False, 'msg': 'Invalid URL scheme'})
	if '127.0.0.1' in u.netloc:
		return jsonify({'status': False, 'msg': 'URL can\'t be local'})
	fn = u.path[u.path.rfind('/') + 1:] or 'index.html'
	if get_ext(fn) not in config.TRUSTED_EXTENSIONS:
		return jsonify({'status': False, 'msg': 'Invalid extension'})
	nfn = str(int(time.time() * 1000)) + '%06x' % random.randint(0, 2 ** 24 - 1) + purify_filename(fn)
	fp = config.TEMP_PATH.rstrip('\\').rstrip('/') + '/upload/' + nfn
	add_file_task({'type': 'new_album_remote', 'path': url, 'filename': fn, 'npath': fp})
	return jsonify({'status': True, 'msg': 'Added to queue'})
예제 #5
0
파일: web.py 프로젝트: Oroggs/musiclib
def album_upload():
	if 'file' not in request.files:
		return jsonify({'status': False, 'msg': 'File not found'})
	file = request.files['file']
	if file.filename == '':
		return jsonify({'status': False, 'msg': 'Filename cannot be empty'})
	if get_ext(file.filename) not in config.TRUSTED_EXTENSIONS:
		return jsonify({'status': False, 'msg': 'Invalid extension'})
	ofn = file.filename
	fn = str(int(time.time() * 1000)) + '%06x' % random.randint(0, 2 ** 24 - 1) + purify_filename(ofn)
	fp = config.TEMP_PATH.rstrip('\\').rstrip('/') + '/upload/' + fn
	file.save(fp)
	add_file_task({'type': 'new_album', 'path': fp, 'filename': ofn})
	return jsonify({'status': True, 'msg': 'Added to queue'})
예제 #6
0
파일: web.py 프로젝트: Oroggs/musiclib
def album_upload_files(id, tp):
	id = int(id)
	album = Album.query.filter(Album.id == id).first()
	if album is None:
		return jsonify({'status': False, 'msg': 'Invalid album id'})
	if tp not in ['scan', 'log', 'other', 'cover']:
		return jsonify({'status': False, 'msg': 'Upload type error'})
	if 'file' not in request.files:
		return jsonify({'status': False, 'msg': 'File not found'})
	file = request.files['file']
	if file.filename == '':
		return jsonify({'status': False, 'msg': 'Filename cannot be empty'})
	if get_ext(file.filename) not in config.TRUSTED_EXTENSIONS:
		return jsonify({'status': False, 'msg': 'Invalid extension'})
	ofn = file.filename
	fn = str(int(time.time() * 1000)) + '%06x' % random.randint(0, 2 ** 24 - 1) + purify_filename(ofn)
	fp = config.TEMP_PATH.rstrip('\\').rstrip('/') + '/upload/' + fn
	file.save(fp)
	add_file_task({'type': 'album_' + tp, 'album_id': id, 'path': fp, 'filename': ofn})
	return jsonify({'status': True, 'msg': 'Added to queue'})