fixed spee.ch/example/claim_id resolve breakage

This commit is contained in:
bill bittner 2017-06-14 15:47:10 -07:00
parent 2c732fa2f4
commit cb5d71e8c3
2 changed files with 5 additions and 7 deletions

View file

@ -18,7 +18,7 @@ function filterForFreePublicClaims(claimsListArray){
} }
function isFreePublicClaim(claim){ function isFreePublicClaim(claim){
console.log(">> isFreePublicClaim, claim:", claim); console.log(">> isFreePublicClaim? claim:", claim);
if ((claim.value.stream.metadata.license === 'Public Domain' || claim.value.stream.metadata.license === 'Creative Commons') && if ((claim.value.stream.metadata.license === 'Public Domain' || claim.value.stream.metadata.license === 'Creative Commons') &&
(!claim.value.stream.metadata.fee || claim.value.stream.metadata.fee.amount === 0)) { (!claim.value.stream.metadata.fee || claim.value.stream.metadata.fee.amount === 0)) {
return true; return true;
@ -28,7 +28,7 @@ function isFreePublicClaim(claim){
} }
function orderTopClaims(claimsListArray){ function orderTopClaims(claimsListArray){
console.log(">> orderTopClaims, claimsListArray:"); console.log(">> orderTopClaims");
claimsListArray.sort(function(claimA, claimB){ claimsListArray.sort(function(claimA, claimB){
if (claimA.amount === claimB.amount){ if (claimA.amount === claimB.amount){
return (claimA.height > claimB.height); return (claimA.height > claimB.height);
@ -41,11 +41,9 @@ function orderTopClaims(claimsListArray){
function getAllFreePublicClaims(claimName){ function getAllFreePublicClaims(claimName){
var deferred = new Promise(function(resolve, reject){ var deferred = new Promise(function(resolve, reject){
console.log(">> get all claims data for", claimName)
// make a call to the daemon to get the claims list // make a call to the daemon to get the claims list
lbryApi.getClaimsList(claimName) lbryApi.getClaimsList(claimName)
.then(function(data){ .then(function(data){
console.log(">> 'claim_list' success");
var claimsList = data.result.claims; var claimsList = data.result.claims;
console.log(">> Number of claims:", claimsList.length) console.log(">> Number of claims:", claimsList.length)
// return early if no claims were found // return early if no claims were found
@ -106,9 +104,9 @@ module.exports = {
// resolve the claim // resolve the claim
lbryApi.resolveUri(uri) lbryApi.resolveUri(uri)
.then(function(resolvedUri){ .then(function(resolvedUri){
console.log("result >>", resolvedUri) //console.log("result >>", resolvedUri)
// check to make sure it is free and public // check to make sure it is free and public
if (isFreePublicClaim(resolvedUri.result.claim)){ if (isFreePublicClaim(resolvedUri.result[uri].claim)){
// promise to get the chosen uri // promise to get the chosen uri
lbryApi.getClaim(uri) lbryApi.getClaim(uri)
.then(function(data){ .then(function(data){

View file

@ -2,7 +2,7 @@
module.exports = function(app, routeHelpers, lbryHelpers, ua, googleAnalyticsId){ module.exports = function(app, routeHelpers, lbryHelpers, ua, googleAnalyticsId){
// route to fetch all free public claims // route to fetch all free public claims
app.get("/:name/all", function(req, res){ app.get("/:name/all", function(req, res){
console.log(">> GET request on /" + req.params.name + " (all)"); console.log(">> GET request on /" + req.params.name + "/all");
ua(googleAnalyticsId, {https: true}).event("Show Routes", "/name/all", req.params.name + "/all").send(); ua(googleAnalyticsId, {https: true}).event("Show Routes", "/name/all", req.params.name + "/all").send();
// create promise // create promise
lbryHelpers.getAllClaims(req.params.name) lbryHelpers.getAllClaims(req.params.name)