Ebrary CEL: Work towards ebook requirements
authorDan Scott <dscott@laurentian.ca>
Sat, 12 Nov 2011 01:59:00 +0000 (20:59 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:57:17 +0000 (14:57 -0400)
Of most importance, copy the incoming 001 value identifying the Ebrary
record into the 924 for use in SFX lookups.

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

index bc6ceea..99f54f1 100644 (file)
@@ -96,6 +96,8 @@ Required arguments:
 
     -o / --output : The name of the output MARC file.
 
+    -e / --ebrary-id : Put Ebrary 001 into 924 as a URN for SFX lookup purposes
+
     -a / --authorization: The name of the online platorm to be inserted in each
                           506$e access restriction note.
 
@@ -141,6 +143,8 @@ def consolidate_options(opts):
             _options['--authorization'] = val
         elif key == '-c':
             _options['--consortium'] = val
+        elif key == '-e':
+            _options['--ebrary-id'] = val
         elif key == '-p':
             _options['--publisher'] = val
         elif key == '-P':
@@ -262,10 +266,10 @@ def check_libraries(options):
 def parse_opts():
     """Get command-line arguments from the script"""
     try:
-        _short_opts = 'i:o:a:c:p:ALWn:P:s:h'
+        _short_opts = 'i:o:a:c:p:ALWne:P:s:h'
         _long_opts = ['input=', 'output=', 'authorization=', 'consortium=', 
             'publisher=', 'algoma', 'laurentian', 'windsor', 'note=',
-            'platform=', 'sample=', 'help'
+            'platform=', 'sample=', 'ebrary-id', 'help'
         ]
         opts = getopt.getopt(sys.argv[1:], _short_opts, _long_opts) 
     except getopt.GetoptError, ex:
@@ -596,6 +600,20 @@ def mark_isbn_for_sfx(record, options):
                     # Add the $9 subfield to mark this as a good one
                     isbn.add_subfield('9', 'SFX')
                     return True
+
+    # For ebrary records, add a 924 for the custom URN
+    if options['ebrary-id'] is True:
+        for scn in record.get_field('001'):
+            urn = pymarc.Field(tag = '924',
+                indicators = ['8', ' '],
+                subfields = [
+                    'a', 'urn:ebrary:' + scn.value(),
+                    '9', 'SFX' 
+                ]
+            )
+
+            record.add_field(urn)
+
     return False
 
 def check_for_isbn(options, lib, isbnval):