Skip to content
Open
Show file tree
Hide file tree
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
Binary file added .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ target/
# Idea PyCharm
.idea/
.idea_modules/
out/
out/

**/.DS_Store
*__pycache__
16 changes: 11 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CWR Data Model API
==================

This projects offers a domain model for the CISAC CWR standard v2.1 to be
This projects offers a domain model for the CISAC CWR standard v2.2 to be
used on Python applications, along a series of parsing which allow
transformations between the model and various data structures.

Expand All @@ -13,6 +13,9 @@ works data.
While the CWR standard has been created by `CISAC`_ this library has been
developed by `WESO`_ independently, with help from `BMAT`_.

This is a fork of the `official CWR-DataApi repository`_ by WESO, updated to
support CWR standard v2.2 by `max1millions`_.

.. image:: https://badge.fury.io/py/cwr-api.svg
:target: https://pypi.python.org/pypi/cwr-api
:alt: CWR-API Pypi package page
Expand Down Expand Up @@ -51,9 +54,10 @@ Prerequisites

The project has been tested in the following versions of the interpreter:

- Python 3.4
- Python 3.5
- Python 3.6
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12

All other dependencies are indicated on the requirements.txt file.
The included makefile can install them with the command:
Expand Down Expand Up @@ -146,9 +150,11 @@ The project has been released under the `MIT License`_.
.. _BMAT: http://www.bmat.com/
.. _WESO: http://www.weso.es/
.. _project issues page: https://github.com/weso/CWR-DataApi/issues
.. _Pyparsing: https://pyparsing.wikispaces.com/
.. _Pyparsing: https://pyparsing-docs.readthedocs.io/
.. _Pypi package: https://pypi.python.org/pypi/CWR-API
.. _Sphinx: http://sphinx-doc.org/
.. _latest docs: http://cwr-dataapi.readthedocs.org
.. _GitHub project page: https://github.com/weso/CWR-DataApi
.. _official CWR-DataApi repository: https://github.com/weso/CWR-DataApi
.. _max1millions: https://github.com/max1millions
.. _MIT License: http://www.opensource.org/licenses/mit-license.php
2 changes: 1 addition & 1 deletion config_cwr/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def read_yaml_file(self, file_name):
"""
with open(os.path.join(self.__path(), os.path.basename(file_name)),
'rt') as yamlfile:
return yaml.load(yamlfile)
return yaml.load(yamlfile, Loader=yaml.FullLoader)

def read_config_file(self, file_name):
"""
Expand Down
2 changes: 1 addition & 1 deletion config_cwr/default_values.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_version: 2.1
default_version: 2.2
73 changes: 70 additions & 3 deletions config_cwr/field_config_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ character_set:
size: 15
name: Character Set

creation_date:
type: date
size: 8
name: Creation Date

creation_time:
type: time
size: 6
name: Creation Time

creation_date_time:
type: date_time
size: 16
Expand Down Expand Up @@ -137,7 +147,7 @@ date_publication_printed_edition:

duration:
type: time
size: 8
size: 6
name: Duration

ean13:
Expand All @@ -153,6 +163,12 @@ edi_standard:
values:
- '01.10'

hdr_version_type:
type: alphanum
size: 3
name: Header Version Type
results_name: version_type

entire_work_title:
type: alphanum
size: 60
Expand Down Expand Up @@ -357,6 +373,11 @@ original_transaction_sequence_n:
size: 8
name: Original Transaction Sequence Number

organisation_code:
type: alphanum
size: 3
name: Organisation Code

original_record_sequence_n:
type: numeric
size: 8
Expand Down Expand Up @@ -599,7 +620,7 @@ submitter_work_n:
name: Submitter Work Number

tax_id:
type: numeric
type: alphanum
size: 9
name: Tax ID Number

Expand Down Expand Up @@ -765,4 +786,50 @@ writer_unknown:
year_production:
type: numeric
size: 4
name: Year of Production
name: Year of Production

recording_title:
type: alphanum_ext
size: 60
name: Recording Title

version_title:
type: alphanum_ext
size: 60
name: Version Title

display_artist:
type: alphanum_ext
size: 60
name: Display Artist

record_label:
type: alphanum
size: 60
name: Record Label

isrc_validity:
type: alphanum
size: 20
name: ISRC Validity

submitter_recording_identifier:
type: alphanum_end
size: 14
name: Submitter Recording Identifier

identifier_type:
type: alphanum
size: 1
name: Identifier Type

validity:
type: alphanum
size: 1
name: Validity

xrf_identifier:
type: alphanum
size: 14
name: Identifier
results_name: identifier
23 changes: 22 additions & 1 deletion config_cwr/record_config_common.cml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ transaction_record:

transaction_record:
id: publisher_territory
head: SPT
head: SPT,OPT
rules:
[
field: ip_n
Expand Down Expand Up @@ -396,6 +396,14 @@ transaction_record:
optional [
field: media_type
]
optional [
field: recording_title
field: version_title
field: display_artist
field: record_label
field: isrc_validity
field: submitter_recording_identifier
]
]

transaction_record:
Expand All @@ -422,6 +430,7 @@ record:
optional
[
field: character_set
field: hdr_version_type
]
]

Expand Down Expand Up @@ -470,6 +479,17 @@ transaction_record:
]
]

transaction_record:
id: work_id_cross_reference
head: XRF
rules:
[
field: organisation_code
field: xrf_identifier
field: identifier_type
field: validity
]

transaction_record:
id: work_alternate_title
head: ALT
Expand Down Expand Up @@ -573,6 +593,7 @@ transaction_record:
field: submitter_agreement_n
field: society_assigned_agreement_n
field: writer_ip_n
field: publisher_sequence_n
]

transaction_record:
Expand Down
Binary file added cwr/.DS_Store
Binary file not shown.
43 changes: 43 additions & 0 deletions cwr/cross_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

from cwr.record import TransactionRecord

"""
CWR 2.2 § 5.32 Work ID Cross Reference (XRF) record.

This record links a work transaction to identifiers issued by any organisation
including the intended recipient, other PROs, ISWC (org_code='ISW'), or ISRC
(org_code='ISR').

The XRF record is an optional trailing record inside NWR, REV, and ISW
transactions (see CWR 2.2 §6.1 BNF).
"""

__author__ = 'Rightstune'
__license__ = 'MIT'
__status__ = 'Development'


class XrfRecord(TransactionRecord):
"""CWR 2.2 § 5.32 Work ID Cross Reference (XRF).

Field layout after the 19-char Record Prefix:
organisation_code 3 alphanum M
identifier 14 alphanum M
identifier_type 1 alphanum M W=Work, R=Recording, P=Product, V=Video
validity 1 alphanum M Y=valid, U=link invalid, N=identifier invalid
"""

def __init__(self, transaction_sequence_n, record_sequence_n,
organisation_code, identifier,
identifier_type='W', validity='Y'):
super(XrfRecord, self).__init__(
'XRF', transaction_sequence_n, record_sequence_n
)
org = str(organisation_code)
if org.isdigit():
org = org.zfill(3)
self.organisation_code = org[:3]
self.identifier = str(identifier)[:14]
self.identifier_type = identifier_type
self.validity = validity
2 changes: 1 addition & 1 deletion cwr/grammar/factory/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
pp.Word(pp.nums).setResultsName('count')
rule_at_least.setParseAction(lambda v: int(v[0]))

_rule_config_string = pp.Regex('[^()\[\]\\n,:]*')
_rule_config_string = pp.Regex(r'[^()\[\]\n,:]*')
_rule_config_string.setParseAction(lambda v: v[0].strip())

_rule_identifier = _rule_config_string + pp.Literal(':').suppress()
Expand Down
1 change: 0 additions & 1 deletion cwr/grammar/field/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import datetime

import pyparsing as pp
from pyparsing import ParseResults

"""
CWR fields grammar.
Expand Down
2 changes: 1 addition & 1 deletion cwr/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self,
record_type='',
group_id=0,
transaction_type='',
version_number='02.10',
version_number='02.20',
batch_request_id=0
):
super(GroupHeader, self).__init__(
Expand Down
33 changes: 26 additions & 7 deletions cwr/interested_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self,
record_type='',
transaction_sequence_n=0,
record_sequence_n=0,
first_recording_refusal='U',
first_recording_refusal='N',
usa_license='',
pr_society=None,
pr_ownership_share=0,
Expand Down Expand Up @@ -292,7 +292,7 @@ def usa_license(self, value):

class IPTerritoryOfControlRecord(TransactionRecord):
"""
Represents a CWR Publisher or Writer Territory of Control (SPT/SWT).
Represents a CWR Publisher or Writer Territory of Control (SPT/OPT/SWT).

This indicates if a Publisher or Writer has control or not over a
Territory, and the shares it has on it.
Expand Down Expand Up @@ -551,7 +551,7 @@ def __init__(self,
sr_society=None,
sr_ownership_share=0,
special_agreements=None,
first_recording_refusal='U',
first_recording_refusal='N',
usa_license=''
):
"""
Expand Down Expand Up @@ -995,7 +995,8 @@ def __init__(self,
publisher_name='',
writer_ip_n='',
submitter_agreement_n=None,
society_assigned_agreement_n=None
society_assigned_agreement_n=None,
publisher_sequence_n=0
):
super(PublisherForWriterRecord, self).__init__(
record_type,
Expand All @@ -1011,6 +1012,9 @@ def __init__(self,
self._submitter_agreement_n = submitter_agreement_n
self._society_assigned_agreement_n = society_assigned_agreement_n

# Publisher chain link
self._publisher_sequence_n = publisher_sequence_n

@property
def publisher_ip_n(self):
"""
Expand Down Expand Up @@ -1082,6 +1086,21 @@ def publisher_name(self):
def publisher_name(self, value):
self._publisher_name = value

@property
def publisher_sequence_n(self):
"""
Publisher Sequence # field. Numeric.

Must match the Publisher Sequence # of the relating SPU/OPU record.

:return: the publisher sequence number in the chain
"""
return self._publisher_sequence_n

@publisher_sequence_n.setter
def publisher_sequence_n(self, value):
self._publisher_sequence_n = value


class WriterRecord(InterestedPartyRecord):
"""
Expand All @@ -1100,9 +1119,9 @@ def __init__(self,
writer=None,
writer_designation=None,
work_for_hire=False,
writer_unknown='F',
reversionary='U',
first_recording_refusal='U',
writer_unknown='',
reversionary='',
first_recording_refusal='N',
usa_license='',
pr_society=None,
pr_ownership_share=0,
Expand Down
Loading