OIP-NPM
OIP-NPM is an easy to use Node.js module to help with publishing to OIP media formats. It publishes the OIP metadata to the Florincoin blockchain using predefined metadata templates.
Installation
Import OIP-NPM into your existing application using the following below.
$ npm install oip-npm --save
Usage
Starting Off
To start off, you will need to import LibaryDJS into your application, then set it up using the example below.
var oip041 = ; var oip = host: 'localhost' # Information about your local Florincoin RPC port: 18322 username: 'florincoinrpc' password: 'password';
Main Functions
Publish Media:
publishArtifact(oipArtifact, callback)
: Validates and publishes a submitted OIP-041 artifact:
var oip041 = ; var oip = host: 'localhost' # Information about your local Florincoin RPC port: 18322 username: 'florincoinrpc' password: 'password'; // The artifact to publish in OIP-041 format.var artifact = "oip-041": "artifact": "publisher": "FD6qwMcfpnsKmoL2kJSfp1czBMVicmkK1Q" "timestamp": 1481419390 "type": "music" "info": "title": "Test Artifact" "description": "Testing publishing from OIP-NPM" "year": "2016" "extraInfo": {} "storage": "network": "IPFS" "location": "QmPukCZKeJD4KZFtstpvrguLaq94rsWfBxLU1QoZxvgRxA" "files": "dname": "Skipping Stones" "fame": "1 - Skipping Stones.mp3" "fsize": 6515667 "type": "album track" "duration": 1533603293 "payment": oip
After processing the publishArtifact
function will return a response as follows:
"success": true # This variable is set dependant on if the API call was successful or not "message": "tx1,tx2,tx3,tx4,tx5" # This variable will be filled in on success If success is false `error` will be used instead of `message`
Announce Publisher:
announcePublisher(publisherJSON, callback)
: Changes the ownership of an artifact from your publisher to another user. transferOwnership
function example:
// The artifact txid that we are transferingvar publisherJSON = "oip-publisher":"name":"Publisher Name""address":"FLO Address""emailmd5":"""bitmessage":""; oip
After processing the announcePublisher
function will return a response as follows:
"success": true # This variable is set dependant on if the API call was successful or not "message": "txid" # This variable will be filled in on success If success is false `error` will be used instead of `message`
Edit Media:
editArtifact(newOIPArtifact, callback)
: The Edit Artifact function accepts data in the OIP-041 Edit format (example below) along with data in the standard OIP-041 schema (same as publishArtifact
but with an added txid
field inside the data at oip-041.artifact.txid
). It calculates what information is new and publish that to the Florincoin blockchain. Example Edit code:
// The artifact txid that we are editting// The updated artifact in OIP-041 format.var artifact = "oip-041": "artifact": "txid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "publisher": "FD6qwMcfpnsKmoL2kJSfp1czBMVicmkK1Q" "timestamp": 1481419391 "type": "music" "info": "title": "Test Artifact (edit)" "description": "Testing editting from OIP-NPM" "year": "2016" "extraInfo": {} "storage": "network": "IPFS" "location": "QmPukCZKeJD4KZFtstpvrguLaq94rsWfBxLU1QoZxvgRxA" "files": "dname": "Skipping Stones" "fame": "1 - Skipping Stones.mp3" "fsize": 6515667 "type": "album track" "duration": 1533 "payment": oip
After processing the editArtifact
function will return a response in a callback as follows:
"success": true # This variable is set dependant on if the API call was successful or not "message": "tx1,tx2,tx3,tx4,tx5" # This variable will be filled in on success If success is false `error` will be used instead of `message`
Remove Media:
deactivateArtifact(txid, title, callback)
: Deactivates an artifact in LibraryD. This will cause the artifact to stop showing up in the browser, however it does NOT remove the previously published data from the blockchain. Any information previously published will be accessable for as long as Florincoin exists. Example deactivation of an artifact:
// The artifact txid that we are edittingvar originalTX = "XXXXXXXXXXXXX";// The updated artifact in OIP-041 format.var title = "Test Artifact" oip
After processing the deactivateArtifact
API endpoint will return a response as follows:
"success": true # This variable is set dependant on if the API call was successful or not "message": "txid" # This variable will be filled in on success If success is false `error` will be used instead of `message`
Transfer Artifact:
transferArtifact(txid, newOwner, callback)
: Changes the ownership of an artifact from your publisher to another user. transferArtifact
function example:
// The artifact txid that we are transferingvar originalTX = "XXXXXXXXXXXXX";// Your publisher addressvar origOwner = "XXXXXXXXXXXXX";// The updated artifact in OIP-041 format.var newOwner = "XXXXXXXXXXXXX"; // This needs to be a florincoin address that is a registered publisher. If it is not a registered publisher it will fail. oip
After processing the transferArtifact
function will return a response as follows:
"success": true # This variable is set dependant on if the API call was successful or not "message": "txid" # This variable will be filled in on success If success is false `error` will be used instead of `message`
OIP Artifact Formats
You can find more information about the OIP-041 standard here: https://github.com/dloa/media-protocol
License
This module uses the MIT License. This can be found inside the file named LICENSE