def __init__(self) -> None:
        print_app_info()

        self.browser: object = make_browser(headless=False)

        self.browser.get(get_defaults("url", "login"))

        self.scrape_data_amount: int = get_inputs(self.browser)

        self.filters: dict = get_filters(self.browser)

        self.result_links: list = get_links(
            self.browser, self.scrape_data_amount)

        self.scraped_details: dict = get_data(
            self.browser, self.result_links, self.scrape_data_amount)

        self.scraped_details["filters"] = self.filters

        quit_browser(self.browser)

        file_name = "./ScrapedData/ScrapedData_{}".format(
            time.strftime("%d_%b_%Y_%H_%M", time.localtime()))

        make_json(self.scraped_details, f"{file_name}.json")

        make_json_to_csv(
            f"{file_name}.json",
            f"{file_name}.csv"
        )

        print_app_end()
예제 #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 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)
예제 #4
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)
예제 #5
0
def defaults():
	return jsonify(get_defaults())