def testGetLabel(self): musicbrainzngs.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16") self.assertEqual("http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16", _common.opener.get_url()) # one include musicbrainzngs.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16", "releases") self.assertEqual("http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16?inc=releases", _common.opener.get_url())
def testGetLabel(self): musicbrainzngs.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16") self.assertEqual( "http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16", _common.opener.get_url()) # one include musicbrainzngs.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16", "releases") self.assertEqual( "http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16?inc=releases", _common.opener.get_url())
def record_label_foundation_year(record_label_musicbrainz_id) -> 'year': """Extracts the year a record label was founded Returns: str -- """ if record_label_musicbrainz_id is not None: label = musicbrainzngs.get_label_by_id( record_label_musicbrainz_id['value']) try: start_activity_year = label['label']['life-span']['begin'] except KeyError: logging.getLogger('root.features').warning( f"Label {record_label_musicbrainz_id} does not have known fundation date" ) return None if re.match(r"^\d{4}$", start_activity_year): return {'value': start_activity_year} elif re.match(r"^\d{4}-\d{2}$", start_activity_year): return {'value': start_activity_year.split('-')[0]} elif re.match(r"^\d{4}-\d{2}-\d{2}$", start_activity_year): return {'value': start_activity_year.split('-')[0]} else: logging.getLogger('root.features').warning( f"Record label fundation year {start_activity_year} does not match pattern" )
def main(): m.set_useragent("application", "0.01", "http://example.com") print(m.get_artist_by_id("952a4205-023d-4235-897c-6fdb6f58dfaa", [])) print(m.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16")) print(m.get_release_by_id("e94757ff-2655-4690-b369-4012beba6114")) print(m.get_release_group_by_id("9377d65d-ffd5-35d6-b64d-43f86ef9188d")) print(m.get_recording_by_id("cb4d4d70-930c-4d1a-a157-776de18be66a")) print(m.get_work_by_id("7e48685c-72dd-3a8b-9274-4777efb2aa75")) print(m.get_releases_by_discid("BG.iuI50.qn1DOBAWIk8fUYoeHM-")) print(m.get_recordings_by_puid("070359fc-8219-e62b-7bfd-5a01e742b490")) print(m.get_recordings_by_isrc("GBAYE9300106")) m.auth("", "") m.submit_barcodes( {"e94757ff-2655-4690-b369-4012beba6114": "9421021463277"}) m.submit_tags(recording_tags={ "cb4d4d70-930c-4d1a-a157-776de18be66a": ["these", "are", "my", "tags"] }) m.submit_tags( artist_tags={"952a4205-023d-4235-897c-6fdb6f58dfaa": ["NZ", "twee"]}) m.submit_ratings( recording_ratings={"cb4d4d70-930c-4d1a-a157-776de18be66a": 20}) m.submit_echoprints( {"e97f805a-ab48-4c52-855e-07049142113d": "anechoprint1234567"})
def testGetLabel(self): label_id = "aab2e720-bdd2-4565-afc2-460743585f16" musicbrainzngs.get_label_by_id(label_id) self.assertEqual("http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16", self.opener.get_url()) # one include musicbrainzngs.get_label_by_id(label_id, "releases") self.assertEqual("http://musicbrainz.org/ws/2/label/aab2e720-bdd2-4565-afc2-460743585f16?inc=releases", self.opener.get_url()) # with valid filters musicbrainzngs.get_label_by_id(label_id, ["releases"], release_type=["ep", "single"], release_status=["official"]) self.assertTrue("type=ep%7Csingle" in self.opener.get_url()) self.assertTrue("status=official" in self.opener.get_url())
def record_label_area(record_label_musicbrainz_id) -> 'area_musicbrainz_id': """Extracts the area the actual record label is based in Arguments: record_label_musicbrainz_id {str} -- Returns: str -- The id of the area in musicbrainz """ if record_label_musicbrainz_id is not None: label = musicbrainzngs.get_label_by_id( record_label_musicbrainz_id['value']) try: label_area_id = label['label']['area']['id'] return {'value': label_area_id} except KeyError: logging.getLogger('root.features').warning( f"Record label {record_label_musicbrainz_id} has not area attribute" ) return None
def server_query(id, includes=[]): return mb.get_label_by_id(id, includes=includes)['label']
set_useragent('kp_lister', '0.0.1', contact='*****@*****.**') with open("mbids_contemporary_music.txt", "r") as f: mbids = f.readlines() records = [] for mbid in set(mbids): try: mb_data = get_artist_by_id(mbid.strip().split("/")[-1], includes=['url-rels'])["artist"] except ResponseError: try: mb_data = get_place_by_id(mbid.strip().split("/")[-1], includes=['url-rels'])["place"] except ResponseError: try: mb_data = get_label_by_id(mbid.strip().split("/")[-1], includes=['url-rels'])["label"] except ResponseError: mb_data = get_series_by_id(mbid.strip().split("/")[-1], includes=['url-rels'])["series"] print(mb_data) data = { "name": mb_data["name"], "mbid": mbid, "sort-name": mb_data["sort-name"] if "sort-name" in mb_data else None, "disambiguation": mb_data["disambiguation"] if "disambiguation" in mb_data else None, "country": mb_data["country"] if "country" in mb_data else None
def get_label_value(id): l = musicbrainzngs.get_label_by_id(id) return l['label']['name']