pod-ident
v1.0.5
Published
Podcast Client Detector without the clutter
Downloads
4
Maintainers
Readme
PodIdent - Podcast Client Detector without the clutter
Rationale
Focus
There are plenty of libraries that can parse and detect user agents in a generic way.
PodIdent
takes a different approach here: it puts a lot of effort into getting the most used Podcast clients right, leaving the job of detecting browsers and more obscure
devices to generic user agent detecting libraries.
Simplicity
Version numbers might be interesting for some use cases, but are not relevant at all to podcasters - podcasters want to know where their listeners are, and what platforms / clients work the best.
There is a great deal of confusion about what is a device, an operating system or a platform in general. To keep things simple, PodIdent
uses platform
as a generic term to describe the place where software runs. It can be an iPhone (device), iOS (operating system) or even just an "Apple device" (category).
PodIdent
has no production dependencies. Keep it simple, and all that.
Preciseness
User agents are known to be confusing and difficult to understand. Most vendors don't document their user agents explicitly, and most of the detection rules are created by trying and collecting information from other sources.
This is why PodIdent
tries to be always as precise as possible (if it knows that a client runs on an iPad, it will return platform: 'iPad'
, instead of a generic iOS
.
Performance, memory usage
The detection rules always try to match substrings first, before using full-fledged regular expressions. This should make detection a lot faster. Also, since there are not even 100 podcast clients out there, there is no need to support a billion different browsers and devices.
Installation
npm install pod-ident
Usage
const detector = require('pod-ident')
const userAgent = 'AppleCoreMedia/1.0.0.10B500 (iPod; U; CPU OS 6_1_6 like Mac OS X; en_gb)'
const result = detector.detect(userAgent)
console.log(result)
=> {
app: 'Apple Podcasts',
platform: 'iPod',
userAgent: 'AppleCoreMedia/1.0.0.10B500 (iPod; U; CPU OS 6_1_6 like Mac OS X; en_gb)'
}
Development & contributing
Feel free to run the tests with npm test
.
The detection rules are found as a yaml file under lib/detectionRules.yml
.
Please, only edit this file, and afterwards run npm run parseRules
in order to generate both the detection rules as a js
file for production usage, and the complete rules with their corresponding test cases for testing.
Future implementations
It would be nice to have the following features in future versions:
- bot & crawler detection (instead of having to use a generic user agent parser)
- adding custom detection rules (this can be achieved today by pushing rules into the rules array, but there should be a better way)