Skip to content

Commit

Permalink
postInfo command added
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Lysenko committed Sep 25, 2018
1 parent cd00e59 commit 50d9feb
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Optional params (with example)

``` --tags "one, second one"```

### Post media file to blog

````bash
tt postInfo -c path/to/keys.json -b blogName --id "post-id"
````

### Clean broken video posts tool

Broken media posts cleaning tool. Cleans up (removes) video-posts with media pointing to 403 error returning URLs (by default). See available options below.
Expand Down
11 changes: 11 additions & 0 deletions cli/postInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = yargs => {

yargs
.describe('b', 'Blog name from where the post')
.usage('Usage: $0 postInfo -c [file] -b [blog] --id <post-id>')
.option('id', {
describe: 'Tumblr post id',
demandOption: true,
type: 'string',
});
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const command = argv._[0];

const tool = require(`./tools/${command}`)(argv);
// ugly as hell
if (command !== 'post') {
if (!['post', 'postInfo'].includes(command)) {
const feed = require('./lib/feed')(tool.cli);
feed.stream(tool.processor);
}
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module.exports = {
cli: require('yargs')

.command('post', 'Create blog post', require('../cli/post'))
.command('postInfo', 'Get post info', require('../cli/postInfo'))

.command('clean', 'Clean unavailable videos', yargs => {
yargs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tumblr-toolkit",
"version": "0.4.1",
"version": "0.5.0",
"description": "Tumblr API-based toolkit for batch posts processing.",
"main": "api.js",
"dependencies": {
Expand Down
19 changes: 19 additions & 0 deletions tools/postInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const tumblrJs = require('tumblr.js');

module.exports = async (params) => {
const { id } = params;

const tumblr = tumblrJs.createClient({
credentials: params.credentials,
returnPromises: true,
});

try {
const result = await tumblr.blogPosts(params.blog, { id });
console.log(result);
return result;
} catch (error) {
console.error(error);
return error;
}
}

0 comments on commit 50d9feb

Please sign in to comment.