Dtube community support - update - new features and code improvement

in #utopian-io7 years ago (edited)

Introduction

Dtube is a video plateform based on the steem blockchain that store videos on IPFS. Because most of users doesn't use ipfs. Dtube is a central point that will store content on IPFS node.

Dtube community support is a bot that will "listen" for new dtube content for a specific steem tag and store the video on a local IPFS node. Plus it stores metadata about dtube content like title (steem post) / video size / permlink / author. The main goad is to persist dtube content of your favorite community on IPFS.

DCS will retrieve 480p videos. if not available, it will retrieve the source file.

New-features

here is the list of new features :

  • List all content (by date, by size, by author)
  • List all content with a markdown format
  • Add specific content based on the dtube url
  • remove specific content based on the pinset
  • failover script
  • log file for the collector

README contains more informations about the usage.

About the failover script

In the first version, DCS was configured by default on 'api.steemit.com'. I have added a failover script to use another api endpoint (in the config.json)

Failover script function (utils/utils.js)

exports.failover = function() {
if(config.rpc_nodes && config.rpc_nodes.length > 1) {
var cur_node_index = config.rpc_nodes.indexOf(steem.api.options.url) + 1;
if(cur_node_index == config.rpc_nodes.length)
cur_node_index = 0;
var rpc_node = config.rpc_nodes[cur_node_index];
steem.api.setOptions({ transport: 'http', uri: rpc_node, url: rpc_node });
}
}

Plus, api endpoint is randomly selected at startup.

steem.api.setOptions({ transport: 'http', uri: config.rpc_nodes.random(), url: config.rpc_nodes.random() });

Array.prototype.random = function () {
return this[Math.floor((Math.random()*this.length))];
}

code structure

index.js is used for the collector.

app.js is a collection of command that will be used manually by the user to query, add and delete content :

The following script has been declared in the package.json :

  • start : start the colletor
  • list : list all content
  • listAuthor : list all content for the specified author (passed in argument)
  • show : Display metadata for the specified pinset (passed in arguent)
  • report : Display content in markdown format
  • add : Manually add content for the specified dtube url (passed in argument)
  • rm : Manuelly remove content for the specified pinset (passed in argument)

Github



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @evildido I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.16
JST 0.030
BTC 65680.50
ETH 2657.30
USDT 1.00
SBD 2.88