bbc-pid
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 = ;var request = ; request;
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.
// {// 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"// } // 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;// -> true pid;// -> false