MCPcopy
hub / github.com/jaakkopasanen/AutoEq / graph_data_url_payloads

Method graph_data_url_payloads

dbtools/rtings_crawler.py:53–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51
52 @staticmethod
53 def graph_data_url_payloads():
54 product_graph_data_url_payloads = []
55 for version in ['1-5', '1-4', '1-2']:
56 html = requests.get(f'https://www.rtings.com/headphones/{version}/graph').text
57 document = BeautifulSoup(html, 'html.parser')
58 test_bench = json.loads(document.find(class_='graph_tool_page').get('data-props'))['test_bench']
59 for product in test_bench['comparable_products']:
60 if product["fullname"] in [payload['source_name'] for payload in product_graph_data_url_payloads]:
61 # The versions are iterated from newest to oldest, if product with the same name already exists,
62 # that means it was included in the results of the newer test methodology and so this one can
63 # be skipped
64 continue
65 # IDs of all the tests done for the current headphone
66 tids = set([test_result['test']['original_id'] for test_result in product['review']['test_results']])
67 valid_test_ids = []
68 # Look for test IDs that correspond to left channel raw frequency response
69 matching_raw_fr_l_ids = [
70 tid for tid in tids if tid in ['4011', '7917', '21564', '1344', '2060', '3182']]
71 if matching_raw_fr_l_ids:
72 valid_test_ids.append(matching_raw_fr_l_ids[0])
73 # Look for test IDs that correspond to right channel raw frequency response
74 matching_raw_fr_r_ids = [
75 tid for tid in tids if tid in ['4012', '7918', '21565', '1343', '2061', '3183']]
76 if matching_raw_fr_r_ids:
77 valid_test_ids.append(matching_raw_fr_r_ids[0])
78 if not valid_test_ids:
79 # This must be one of the tests that don't have raw FR, but instead has bass, mid and treble, skip
80 continue
81 product_graph_data_url_payloads.append({
82 'source_name': product['fullname'],
83 'payloads': [{
84 'named_version': 'public',
85 'product_id': product['id'],
86 'test_original_id': test_id
87 } for test_id in valid_test_ids]
88 })
89 return product_graph_data_url_payloads
90
91 @staticmethod
92 def graph_data_url(payload):

Callers 1

crawlMethod · 0.95

Calls 1

findMethod · 0.45

Tested by

no test coverage detected