acuter
Advanced tools
Comparing version 1.0.0 to 1.0.1
18
index.js
@@ -96,2 +96,19 @@ 'use strict'; | ||
function videoPreview(tweetURL) { | ||
if (typeof tweetURL !== 'string' && isURL(tweetURL) === false) { | ||
return Promise.reject(new Error('url required')); | ||
} | ||
var url = tweetURL; | ||
return got(url).then(function (res) { | ||
var $ = cheerio.load(res.body); | ||
var getMediaLink = matchRegEx(($('.PlayableMedia-player').attr('style'))) || null; | ||
return getMediaLink; | ||
}).catch(function (err) { | ||
if (err.statusCode === 404) { | ||
err.message = 'Link do not contain any video preview'; | ||
} | ||
throw err; | ||
}); | ||
} | ||
exports.profile = profileImage; | ||
@@ -102,1 +119,2 @@ exports.cover = coverImage; | ||
exports.gif = gifLink; | ||
exports.vidPrev = videoPreview; |
{ | ||
"name": "acuter", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "NodeJS API for Twitter media", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -97,2 +97,15 @@ <h1 align="center"> | ||
✔ <code>Preview __```link```__ of a __```video```__ available on twitter : </code> | ||
__Example :__ | ||
```js | ||
const acuter = require('acuter'); | ||
acuter.vidPrev('https://twitter.com/video../738..028').then(gifLink => { | ||
console.log(gifLink); | ||
// => https://o.twimg.com/../proxy.jpg...SAFSDFUYY | ||
}); | ||
``` | ||
## Related | ||
@@ -99,0 +112,0 @@ |
64143
12
142
116