<commit_before># Parse media easily
Simple JavaScript library to ease integration with media and oEmbed. Useful for obtaining direct links to media content and thumbnails. Uses a combination of oEmbed APIs and custom APIs.

You should see [media-embed-server](https://github.com/Doist/media-embed-server) for a server that provides this as a JSON/JSONP service.


## Installing the library
Installing the service is quite easy:
    
    npm install media-parser


## Parsing info about a resource

```js
// Signature (timeout is in milliseconds):
media_parser = require('media-parser')
media_parser.parse(content, callback, timeout=5000)
```

```js
// Example
media_parser = require('media-parser')
callback = function(obj) { 
    console.log(obj); 
    console.log(obj.get_thumbnail_url(55)); 
}
media_parser.parse('This is a test http://www.youtube.com/watch?v=9bZkp7q19f0', callback)

// Will print
{ 
    "get_thumbnail_url": [Function],
    "title": 'PSY - GANGNAM STYLE (강남스타일) M/V',
    "raw": { .. raw oEmbed data .. }
}
```<commit_msg>Updated documentation for underlying_type and others<commit_after># Parse media easily
Simple JavaScript library to ease integration with media and oEmbed. Useful for obtaining direct links to media content and thumbnails. Uses a combination of oEmbed APIs and custom APIs.

You should see [media-embed-server](https://github.com/Doist/media-embed-server) for a server that provides this as a JSON/JSONP service.


## Installing the library
Installing the service is quite easy:
    
    npm install media-parser


## Parsing info about a resource

```js
// Signature (timeout is in milliseconds):
media_parser = require('media-parser')
media_parser.parse(content, callback, timeout=5000)
```

```js
// Example
media_parser = require('media-parser')
callback = function(obj) { 
    console.log(obj); 
    console.log(obj.get_thumbnail_url(55)); 
}
media_parser.parse('This is a test http://www.youtube.com/watch?v=9bZkp7q19f0', callback)

// Will print
{ 
    "get_thumbnail_url": [Function],
    "title": 'PSY - GANGNAM STYLE (강남스타일) M/V',
    "raw": { .. raw oEmbed data .. }
}
```

## Result description
```js
// Example
{
    "title": "...",
    "underlying_type": ... can be: [page, image, video, audio] ,
    "content_url": ... direct link to the content (only for some),
    "content_type": ... MIME type of content_url,
    "raw": ... raw oEmbed response (only for oEmbed resources),
    "get_thumbnail_url": function(min_size) { ... returns thumbnail }
}
```
{'fraction_non_alphanumeric': 0.1270410195141378, 'fraction_numerical': 0.008761449621664676, 'mean_word_length': 3.9742574257425742, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6656418', 'n_tokens_mistral': 818, 'n_tokens_neox': 775, 'n_words': 249}