Commit 1523ae8b authored by Mark Jordan's avatar Mark Jordan
Browse files

Initial commit.

parents
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
# Fetch Islandora Collections
Command-line tool for downloading collections from Islandora.
## Requirements
* On the target Islandora instance
* [Islandora REST](https://github.com/discoverygarden/islandora_rest)
* On the system where the script is run
## Installation
1. `git clone https://github.com/mjordan/fetch_islandora_collections.git`
1. `cd fetch_islandora_collections`
## Overview and usage
### Running the script
`python fetch_collection.py`
Select a collection, specify an output directory, and hit enter.
## Maintainer
* [Mark Jordan](https://github.com/mjordan)
## Development and feedback
* If you discover a bug, or have a use case not documented here, open an issue.
* If you want to open a pull request, open an issue first.
* By opening a pull request, you agree to placing your contribution into the public domain.
* Check code style with `composer style`
* If the work in your PR can be tested, write tests for it. Even if it can't, run `composer tests` to make sure you didn't break anything.
* Use the pull request template.
## License
The Unlicense
#!/usr/bin/env python
# Usage: ./fetch_collection
site_base_url = 'http://digital.lib.sfu.ca/'
import urllib2
import json
import pprint
pp = pprint.PrettyPrinter(indent=4)
model = 'islandora:collectionCModel'
collections_query = 'RELS_EXT_hasModel_uri_t:"' + model + '"?sort=fgs_label_s+asc&fl=PID,fgs_label_t&rows=1000000'
site_rest_url = site_base_url + 'islandora/rest/v1/'
collections_request_url = site_rest_url + 'solr/' + collections_query
collections_response_body = urllib2.urlopen(collections_request_url).read()
collections_response_body_dict = json.loads(collections_response_body)
collections = collections_response_body_dict['response']['docs']
index = 0
collections_menu = {}
for collection in collections:
index += 1
collections_menu[index] = collection
print str(index) + ' - ' + collection['fgs_label_t']
choice = raw_input("Enter the number of the collection you want to download: ")
choice = int(choice)
indexes = list(collections_menu.keys())
if choice in indexes:
print collections_menu[choice]['fgs_label_t']
else:
print "That isn't a valid choice. Bye for now."
exit()
collection_pid = collections_menu[choice]['PID'];
objects_query = 'RELS_EXT_isMemberOfCollection_uri_t:"' + collection_pid + '"?sort=fgs_label_s+asc&fl=PID,fgs_label_t,RELS_EXT_hasModel_uri_t&rows=1000000'
objects_request_url = site_rest_url + 'solr/' + objects_query
objects_response_body = urllib2.urlopen(objects_request_url).read()
objects_response_body_dict = json.loads(objects_response_body)
objects = objects_response_body_dict['response']['docs']
for object in objects:
# pp.pprint(object)
print object['PID'] + '\t' + object['RELS_EXT_hasModel_uri_t'] + '\t' + object['fgs_label_t']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment