Prefer RDA fields (33x) to GMD
authorDan Scott <dscott@laurentian.ca>
Tue, 17 Apr 2018 18:11:15 +0000 (14:11 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 17 Apr 2018 18:11:15 +0000 (14:11 -0400)
Strip out the GMD (245 $h) and add 336, 337, 338 fields
that include our desired content, media, and carrier.

These should probably be made optional as well, for example
for different content types, or for records that are already
RDA-compliant.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/ebooks/prep_ebook_records.py

index 33dea86..6de5e7a 100755 (executable)
@@ -489,6 +489,7 @@ def process_fields(record, options):
         record.add_ordered_field(note)
 
     add_marc_source(record, options) # 598
+    add_rda_fields(record, options) # 336,337,338
     publisher = add_publisher(record, options) # 710
     add_restriction(record, options, publisher) # 506
     add_platform(record, options) # 710
@@ -526,6 +527,13 @@ def process_fields(record, options):
                 data=field.value()[:23] + 's' + field.value()[24:]
             )
             new_record.add_ordered_field(fixed_field)
+        # Strip out GMD
+        elif field.tag == '245':
+            if 'h' in field:
+                suffix = field['h'][-3:]
+                field.delete_subfield('h')
+                field['a'] = field['a'] + suffix
+            new_record.add_ordered_field(field)
         else:
             new_record.add_ordered_field(field)
 
@@ -945,6 +953,41 @@ def add_cat_source(record, options):
         )
         record.add_ordered_field(forty)
 
+def add_rda_fields(record, options):
+    """
+    Add 336,337,338 fields identifying the content as an ebook
+    """
+    content = pymarc.Field(tag = '336',
+        indicators = [' ', ' '],
+        subfields = [
+            'a', 'text',
+            'b', 'txt',
+            '2', 'rdacontent',
+            '0', 'http://id.loc.gov/vocabulary/contentTypes/txt'
+        ]
+    )
+    media = pymarc.Field(tag = '337',
+        indicators = [' ', ' '],
+        subfields = [
+            'a', 'computer',
+            'b', 'c',
+            '2', 'rdamedia',
+            '0', 'http://id.loc.gov/vocabulary/mediaTypes/c'
+        ]
+    )
+    carrier = pymarc.Field(tag = '338',
+        indicators = [' ', ' '],
+        subfields = [
+            'a', 'online resource',
+            'b', 'cr',
+            '2', 'rdacarrier',
+            '0', 'http://id.loc.gov/vocabulary/carriers/cr'
+        ]
+    )
+    record.add_ordered_field(content)
+    record.add_ordered_field(media)
+    record.add_ordered_field(carrier)
+
 def add_marc_source(record, options):
     """
     Add a 598 field identifying the source MARC file name and processing date