Structured parsing of International Standard Recording
Project description
py-iso3901
Structured parsing of International Standard Recording Code (ISRC) in python, as defined in ISO 3901:2019.
Install
pip install -U iso3901
Usage Example
The most usual way to create object is via ISRC.parse
method:
>>> from iso3901 import ISRC
>>> data = ISRC.parse('ISRC GB-AJY-12-34567')
>>> data == ISRC.parse('GBAJY1234567') # Same as compact form
True
>>> data.country.name
'United Kingdom of Great Britain and Northern Ireland'
>>> data.owner
'GBAJY'
>>> data.year
12
>>> data.designation
34567
>>> str(data)
'GBAJY1234567'
>>> data.stringify()
'GB-AJY-12-34567'
>>> data.raw # Get back the original unparsed string
'ISRC GB-AJY-12-34567'
validate()
method is provided for simple validation:
>>> ISRC.validate('isrc aa-xyz-01-23456')
True
>>> ISRC.validate('aa-xyz-012-3456')
False
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'
In case ISRC code does not start with a proper ISO 3166 2-letter country code, .country
attribute would be None
:
>>> data = ISRC.parse('QMDA71418090')
>>> data.owner
'QMDA7'
>>> type(data.country)
<class 'NoneType'>
Reference
Following documents are consulted when writing code:
Q&A
-
The "country code"
QM
is already known for use in United States, andZZ
reserved for International ISRC Agency, as described in various ISRC Bulletins. Why aren't they detected? Is there any plan to add modern ISRC Registrant allocations and do a mapping between newer prefixes and countries?Actually, the newest bulletin dated 2015 had pushed a new standard that no more binds country with the 2-letter prefix. That said, it is still open for consideration. List of currently accepted 'country codes' are available here.
-
Why is there no validation for invalid registrants, such as
US-S1Z
which is mentioned in above documents?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.
-
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.
Alternatives
If one only needs to check for validity of ISRC string, and no objectified access of various segments is needed, other python modules exist to provide such validation routine. For example:
Our ISRC
class also provides a validate()
method as well.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file iso3901-0.2.0.tar.gz
.
File metadata
- Download URL: iso3901-0.2.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f92b7a4e206efa0135c11e4aaeb24d25361c15f844172cd29be1776ef3df6dc2 |
|
MD5 | d831987352f03187dfad93a2d7a4d108 |
|
BLAKE2b-256 | 20c59bae88cdaf2a44afe6bfee5f11cc153a0774581b925507b5a584672f6ff8 |
File details
Details for the file iso3901-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: iso3901-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32a858e7e7049793a5c7bc5302faae36eb8e869504d7217f87e5e8bde20ebe42 |
|
MD5 | 42cb80675d9daf5310a9b704ea01abc1 |
|
BLAKE2b-256 | 8dd0f1153667275f0ea7374d9231447d1e5f0dfca1682919b1333c59de50fd64 |