Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use iso-3166-2-codes if iso-3166-1-codes is not available #377

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions plugins/additional_artists_details/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Additional Artists Details
"""
# Copyright (C) 2023 Bob Swift (rdswift)
# Copyright (C) 2023-2024 Bob Swift (rdswift)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -58,8 +58,8 @@
Please see the <a href="https://github.com/rdswift/picard-plugins/blob/2.0_RDS_Plugins/plugins/additional_artists_details/docs/README.md">user
guide</a> on GitHub for more information.
'''
PLUGIN_VERSION = '0.3'
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.7', '2.8']
PLUGIN_VERSION = '0.4'
PLUGIN_API_VERSIONS = ['2.0', '2.1', '2.2', '2.7', '2.8', '2.11']
PLUGIN_LICENSE = 'GPL-2.0-or-later'
PLUGIN_LICENSE_URL = 'https://www.gnu.org/licenses/gpl-2.0.html'

Expand All @@ -86,7 +86,8 @@
ARTIST_REQUESTS = 'artist_requests'
AREA = 'area'
AREA_REQUESTS = 'area_requests'
ISO_CODES = 'iso-3166-1-codes'
ISO_CODES_1 = 'iso-3166-1-codes'
ISO_CODES_2 = 'iso-3166-2-codes'
OPT_AREA_DETAILS = 'aad_area_details'
OPT_PROCESS_TRACKS = 'aad_process_tracks'
TRACKS = 'tracks'
Expand Down Expand Up @@ -337,7 +338,7 @@ def _get_artist_info(self, artist_id, album):
self._artist_submission_handler,
artist=artist_id,
album=album,
)
)
return helper.get_artist_by_id(artist_id, handler)

def _artist_submission_handler(self, document, _reply, error, artist=None, album=None):
Expand Down Expand Up @@ -381,7 +382,7 @@ def _get_area_info(self, area_id, album):
self._area_submission_handler,
area=area_id,
album=album,
)
)
return helper.get_area_by_id(area_id, handler)

def _area_submission_handler(self, document, _reply, error, area=None, album=None):
Expand Down Expand Up @@ -464,10 +465,12 @@ def _parse_area(area_info):
area_name = area_info['name'] if 'name' in area_info else 'Unknown Name'
area_type = area_info['type-id'] if 'type-id' in area_info else ''
area_type_text = area_info['type'] if 'type' in area_info else 'Unknown Area Type'
country = ''
if area_type == AREA_TYPE_COUNTRY:
country = area_info[ISO_CODES][0] if ISO_CODES in area_info and area_info[ISO_CODES] else ''
else:
country = ''
if ISO_CODES_1 in area_info and area_info[ISO_CODES_1]:
country = area_info[ISO_CODES_1][0]
elif ISO_CODES_2 in area_info and area_info[ISO_CODES_2]:
country = area_info[ISO_CODES_2][0][:2]
return (area_id, area_name, country, area_type, area_type_text)

@staticmethod
Expand Down
Loading