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

bbc-pid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bbc-pid

Simple JavaScript API to validate Programme Identifier (PID) syntax and to compute BBC URLs.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

bbc-pid Build Status

Simple JavaScript API to validate Programme Identifier (PID) syntax and to compute BBC URLs.

BBC Programmes Identifiers 0.4 spec defines a PID as following:

Characters: digits 0-9 and lower case letters, less vowels.

Length: Minimum 8 digits. No defined maximum – they will grow as necessary.

For historical reasons there are some 15 character pids existing for World Service content.

Install

npm i --save bbc-pid

Use

var pid = require('bbc-pid');
var request = require('superagent');

request.get(pid('b062mzcw').programme).end(function(err, res){
  console.log(res.body.programme.short_synopsis);
});

API

pid(pid)

Returns programmatic URLs for a given PID. Expect a 301 redirect from the iplayer URL and a 404 if the PID does not match any programme at all.

pid('p01l1z04')
// {
//  programme: "http://www.bbc.co.uk/programmes/b062mzcw.json",
//  iplayer: "http://www.bbc.co.uk/iplayer/episode/b062mzcw.json",
//  crid: "crid://bbc.co.uk/programmes/b062mzcw",
//  tag: "bbc:programme=b062mzcw"
// }

pid('thedoctor')
// Error: invalid pid
//  at script.js:xx
//  

pid.isValid(pid)

The underlying method used in pid() to validate if a given string is PID compliant.

pid.isValid('p01l1z04');
// -> true

pid.isValid('thedoctor');
// -> false

Keywords

FAQs

Package last updated on 17 Jul 2015

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