示例#1
0
def getAllPlaylists():

	local = check_boolean(request, params.LOCAL)
	sortingMethod = check_integer(request, params.SORT)
	if sortingMethod == None:
		sortingMethod = check_string(request, params.SORT)
	sortingMethod = translate_sorting_method(sortingMethod)

	trackSortingMethod = check_integer(request, params.TRACK_SORT)
	if trackSortingMethod == None:
		trackSortingMethod = check_string(request, params.TRACK_SORT)
	trackSortingMethod = translate_sorting_method(trackSortingMethod, 1)

	filters = check_int_array(request, params.FILTER)
	if len(filters) == 0:
		filters.append(0) #0 means no filtering

	initialPath = check_string(request, params.PATH)

	if not check_path(initialPath):
		initialPath = None
	
	if initialPath == None:
		initialPath = get_defaults()["defaults"]["default_path"]

	if not os.path.isdir(initialPath):
		return send_error(error_codes.INVALID_PATH, "Invalid path")

	respone = explorer.getAllPlaylists(initialPath, sortingMethod, trackSortingMethod, filters, local)
	
	if not 'error' in respone:
		respone['code'] = error_codes.SUCCESFULL_QUERY

	return jsonify(respone)
示例#2
0
def getAllTracks():

	simple = check_boolean(request, params.SIMPLE)
	local = check_boolean(request, params.LOCAL)
	initialPath = check_string(request, params.PATH)

	sortingMethod = check_integer(request, params.SORT)
	if sortingMethod == None:
		sortingMethod = check_string(request, params.SORT)
	sortingMethod = translate_sorting_method(sortingMethod, 1)

	if not check_path(initialPath):
		initialPath = None

	if initialPath == None:
		initialPath = get_defaults()["defaults"]["default_path"]

	if not os.path.isdir(initialPath):
		return send_error(error_codes.INVALID_PATH, "Invalid path")

	respone = explorer.getAllTracks(initialPath, sortingMethod, simple, local)
	
	if not 'error' in respone:
		respone['code'] = error_codes.SUCCESFULL_QUERY

	return jsonify(respone)
示例#3
0
def getDirectory():

	path = check_string(request, params.PATH)
	if path == None:
		path = get_defaults()['defaults']['default_path']

	metadata = check_boolean(request, params.METADATA)

	sortingMethod = check_integer(request, params.SORT)
	if sortingMethod == None:
		sortingMethod = check_string(request, params.SORT)
	sortingMethod = translate_sorting_method(sortingMethod, 0)

	if check_path(path):
		respone = explorer.getPathContent(path, metadata, sorting = sortingMethod)
		if respone == None:
			return send_error(error_codes.INVALID_PATH, "Invalid path")
	else:
		return send_error(error_codes.INVALID_PATH, "Invalid path")

	respone['code'] = error_codes.SUCCESFULL_QUERY
	return jsonify(respone)