# stdnum.isan

ISAN (International Standard Audiovisual Number).

The ISAN (International Standard Audiovisual Number) is used to identify audiovisual works.

The number is hexadecimal and can consists of at least a root identifier, and an episode or part. After that an optional check digit, optional version and optionally another check digit can be provided. The check digits are validated using the ISO 7064 Mod 37, 36 algorithm.

    >>> validate('000000018947000000000000')
    '000000018947000000000000'
    >>> compact('0000-0000-D07A-0090-Q-0000-0000-X')
    '00000000D07A009000000000'
    >>> validate('0000-0001-8CFA-0000-I-0000-0000-K')
    '000000018CFA0000I00000000K'
    >>> validate('0000-0001-8CFA-0000-A-0000-0000-K')
    Traceback (most recent call last):
        ...
    InvalidChecksum: ...
    >>> format('000000018947000000000000')
    '0000-0001-8947-0000-8-0000-0000-D'

    >>> to_urn('00000000D07A009000000000')
    'URN:ISAN:0000-0000-D07A-0090-Q-0000-0000-X'
    >>> to_xml('1881-66C7-3420-6541-Y-9F3A-0245-O')
    '<ISAN root="1881-66C7-3420" episode="6541" version="9F3A-0245" />'

stdnum.isan.compact(number: str, strip_check_digits: bool = True) → str

  Convert the ISAN to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace. The check digits are removed by default.

stdnum.isan.format(number: str, separator: str = '-', strip_check_digits: bool = False, add_check_digits: bool = True) → str

  Reformat the number to the standard presentation format. If add_check_digits is True the check digit will be added if they are not present yet. If both strip_check_digits and add_check_digits are True the check digits will be recalculated.

stdnum.isan.is_valid(number: str) → bool

  Check if the number provided is a valid ISAN. If check digits are present in the number they are validated.

stdnum.isan.split(number: str) → tuple[str, str, str, str, str]

  Split the number into a root, an episode or part, a check digit a version and another check digit. If any of the parts are missing an empty string is returned.

stdnum.isan.to_binary(number: str) → bytes

  Convert the number to its binary representation (without the check digits).

stdnum.isan.to_urn(number: str) → str

  Return the URN representation of the ISAN.

stdnum.isan.to_xml(number: str) → str

  Return the XML form of the ISAN as a string.

stdnum.isan.validate(number: str, strip_check_digits: bool = False, add_check_digits: bool = False) → str

  Check if the number provided is a valid ISAN. If check digits are present in the number they are validated. If strip_check_digits is True any existing check digits will be removed (after checking). If add_check_digits is True the check digit will be added if they are not present yet.