Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

video-parser

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

video-parser - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 2.1.0
- Add authentication processing based on version upgrade of Facebook sdk ([@ignocide](https://github.com/ignocide))
# 2.0.0

@@ -2,0 +6,0 @@

111

lib/parser.js

@@ -52,2 +52,7 @@ /**

},
facebook: {
appId: '',
appSecret: '',
access_token: ''
},
ttl: 3600 * 12 // 1 day

@@ -64,2 +69,3 @@ })

this._config = config
this._updateFacebookToken(function () {})
}

@@ -560,44 +566,60 @@

var self = this
FB.napi(id, function (err, res) {
if (err) {
return cb('video.invalid_url')
}
var retry = 0
if (res.published === false) {
return cb('video.forbidden')
}
// filter
var filtered = []
for (var i = 0; i < res.format.length; i++) {
if (res.format[i].width > 400) {
filtered.push(res.format[i])
var _requestFacebook = function () {
FB.setAccessToken(self._config.facebook.access_token)
FB.napi(id, function (err, res) {
if (err) {
if (err.response.error.code == 104) {
if (retry == 0) {
retry++
self._updateFacebookToken(function () {
return _requestFacebook()
})
}
return cb('facebook.auth')
}
return cb('video.invalid_url')
}
}
var thumbnail = filtered.length > 0 ? filtered[0] : res.format[res.format.length - 1]
self.loadMeta(function (err, meta) {
if (err) {
return cb(err)
if (res.published === false) {
return cb('video.forbidden')
}
// filter
var filtered = []
for (var i = 0; i < res.format.length; i++) {
if (res.format[i].width > 400) {
filtered.push(res.format[i])
}
}
var thumbnail = filtered.length > 0 ? filtered[0] : res.format[res.format.length - 1]
cb(err, {
id: id,
url: ['https://www.facebook.com/', res.from.id, '/videos/', id].join(''),
name: res.from.name,
desc: res.description,
thumb_url: thumbnail.picture || res.picture,
duration: Math.round(meta.format.duration),
ctime: moment(res.created_time).format(),
ratings: null,
details: {
definition: '',
author: {
id: res.from.id,
title: res.from.name
},
source: res.source
self.loadMeta(function (err, meta) {
if (err) {
return cb(err)
}
})
}, 'facebook_meta_' + id, res.source)
})
cb(err, {
id: id,
url: ['https://www.facebook.com/', res.from.id, '/videos/', id].join(''),
name: res.from.name,
desc: res.description,
thumb_url: thumbnail.picture || res.picture,
duration: Math.round(meta.format.duration),
ctime: moment(res.created_time).format(),
ratings: null,
details: {
definition: '',
author: {
id: res.from.id,
title: res.from.name
},
source: res.source
}
})
}, 'facebook_meta_' + id, res.source)
})
}
_requestFacebook()
}

@@ -642,3 +664,2 @@

}
Parser.prototype.requestDailymotion = function (cb, id) {

@@ -1155,2 +1176,18 @@ var url = ['https://api.dailymotion.com/video/',

Parser.prototype._updateFacebookToken = function (cb) {
var self = this
var opts = self._config.facebook
FB.api('oauth/access_token', {
client_id: opts.appId,
client_secret: opts.appSecret,
grant_type: 'client_credentials'
}, function (res) {
if (!res || res.error) {
return cb('facebook.auth')
}
opts.access_token = res.access_token
cb(null, res.access_token)
})
}
module.exports = Parser
{
"name": "video-parser",
"version": "2.0.0",
"version": "2.1.0",
"author": {

@@ -40,3 +40,3 @@ "name": "egg",

"cheerio": "^0.19.0",
"fb": "^0.7.0",
"fb": "^2.0.0",
"fluent-ffmpeg": "^2.0.1",

@@ -43,0 +43,0 @@ "merge-defaults": "^0.2.1",

@@ -60,3 +60,8 @@ # video-parser

key: ''
}
},
facebook: {
appId: '',
appSecret: '',
access_token: ''
},
ttl: 3600 * 12 // 1 day

@@ -63,0 +68,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc