Skip to main content

Structured parsing of ISRC in python defined in ISO 3901:2019

Project description

py-iso3901

Structured parsing of International Standard Recording Code (ISRC) in python, as defined in ISO 3901:2019.

Usage Example

The most usual way to create object is via ISRC.parse method:

>>> from iso3901 import ISRC

>>> data = ISRC.parse('GBAJY1234567')  # 'ISRC GB-AJY-12-34567' is fine too
>>> data.country.name
'United Kingdom of Great Britain and Northern Ireland'
>>> data.owner
'GBAJY'
>>> data.year
12
>>> str(data)
'GBAJY1234567'
>>> data.stringify()
'GB-AJY-12-34567'

Caveats

In the very rare case that no data validation is desired, it is possible to initiate object directly. Be warned that supplying free form data would result in illegal ISRC code:

>>> data = ISRC('GBAJY', 12, 34567)
>>> str(data)
'GBAJY1234567'
>>> data = ISRC('Some Owner', 123, 456789)
>>> str(data)
'Some Owner123456789'

Reference

Following documents are consulted when writing code:

Q&A

  1. Is there any plan to detect modern ISRC Registrant allocations and do a mapping between newer prefixes and countries?

    It is still open for consideration. List of currently accepted 'country codes' are available here.

  2. Why is there no validation for invalid registrants, such as US-S1Z which is mentioned in document?

    Registrant allocation info is not public; it is held privately within allocator of each nation (and most likely International ISRC Agency itself). It is practically impossible to exhaust and blacklist all examples used in various documents on internet.

  3. Why is the year kept as integer and not python datetime structure?

    In ISRC standard, only the last 2 digit of year is available. It is easier to tell the actual year in some cases, but for years like '20', it is impossible to distinguish 1920 from 2020 via ISRC alone. Acoustic recording already existed during 1920 era.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iso3901-0.1.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

iso3901-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page