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

attachment-detection

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attachment-detection

Attactment detection for youtube, images and links

  • 0.2.2-0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Usage:

var AttachmentDetector = require('attachment-detection');
var detector = new AttachmentDetector();

detector.use(AttachmentDetector.YouTube);
detector.use(AttachmentDetector.Image);
detector.use(AttachmentDetector.Link);

Detectors are tried in the way they are used, so be sure to use the most specific ones first. Link catches all.

Each new attachment detector has its own set of handlers. When you have added some handlers to the detector, you can then pass the detector an array of string, containing one link each:

detector.detect([
  'http://www.youtube.com/watch?v=R_WHWCy48c0', 
  'http://youtu.be/R_WHWCy48c0', 
  'www.google.dk', 
  'www.test.com/image.jpg'
 ], function(attachments) {

}))

Responds with the following:

[{
  "link": "http://youtu.be/R_WHWCy48c0",
  "id": "R_WHWCy48c0",
  "type": "youtube",
  "url": "http://youtu.be/R_WHWCy48c0",
  "title": "GirlsOnDrugs - Pass the ∆",
  "description": "Location: UK\nReleased: May 2012\nGirlsOnDrugs\n(Alt -J - Breezeblocks Remix)\nhttp://soundcloud.com/girlsondrugs\nhttp://dl.dropbox.com/u/57622845/06%20Pass%20the.mp3",
  "images": [
    {
      "url": "http://i.ytimg.com/vi/R_WHWCy48c0/0.jpg",
      "height": 360,
      "width": 480
    },
    {
      "url": "http://i.ytimg.com/vi/R_WHWCy48c0/1.jpg",
      "height": 90,
      "width": 120
    },
    {
      "url": "http://i.ytimg.com/vi/R_WHWCy48c0/2.jpg",
      "height": 90,
      "width": 120
    },
    {
      "url": "http://i.ytimg.com/vi/R_WHWCy48c0/3.jpg",
      "height": 90,
      "width": 120
    }
  ]
}, {
  "link": "www.google.com",
  "type": "link",
  "url": "http://www.google.com",
  "title": "Google",
  "description": null
}, {
  "link": "www.test.com/image.jpg",
  "type": "image",
  "url": "http://www.test.com/image.jpg",
}]

Why not use og/opengraph data for everything?

For performance purposes we choose to utilize API's where available. That means we get YouTube video titles and thumbnails from the Google Data API instead of parsing the HTML.

FAQs

Package last updated on 13 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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