Sitemap

BBC iPlayer geolocation identification

4 min readDec 22, 2019
Press enter or click to view image in full size

Developing video player in Yandex, I’m not always limited to what we do but also wondering what technologies and techniques are used in other companies. As I like England I investigated the player of BBC, well-known quite a big company. Unfortunately I haven’t used it before, but maybe this is why I’m going to tell you how it’s working.

Watch the content from non-UK

iPlayer is working only in the UK. After going to The Graham Norton Show you’ll see this:

Press enter or click to view image in full size

VPN, incognito window or other simple hacks are just not working. Even in 2014 BBC configured Geolocation technology to manage online content rights.

How BBC identifies you

First of all, to understand how it’s working we need to find where country identification is placed.

If you go to HTML source, you’ll see inline script in it:

Press enter or click to view image in full size

Let’s go through it to get a general idea of what is going on here:

  1. First, user profile is initialised
Press enter or click to view image in full size

2. Then many auxiliary functions are declared, skip them for now

3. User API is declared in window.bbcuser, some of the functions use getUserInfo

Press enter or click to view image in full size

4. getUserInfo checks if data is saved or not:

  • If saved, data is used from the closure
  • If fetch and CORS-requests are allowed, GET-request is initiated from the user profile (for bbc.co.uk it is https://www.bbc.co.uk/userinfo), after first time the response is cached. The response looks like:
Press enter or click to view image in full size
  • Otherwise, there’s a fallback function which loads module orb/fig with _figManager.js . It uses microservice which is available on https://fig.bbc.co.uk/frameworks/fig/2/fig.js and returns a code which is executed later on. The most interest part here is a parameter uk — it equals 1 if the request has been sent from the UK, otherwise 0.
  • If the request hasn’t been sent from the UK, watching is prohibited due to rights issues.
  • As I investigated iPlayer from Russia, it returned 0 and the content wasn’t available. The response was:
Press enter or click to view image in full size

5. At the end of HTML there a script which calls isUKCombined, it uses API that I described above, saving my profile to a variable user

Press enter or click to view image in full size

6. Script with id='tvip-script-app-store' is inlined in HTML closer to the end of HTML and includes initial Redux state. You can find the flag isForeignRegion which is null by default.

7. When app.bundle.js is loaded, componentDidMound checks that isUK is not 0. As it’s 0, it calls callback function onUserForeignRegion

Press enter or click to view image in full size

8. It updates store value of isForeignRegion

Press enter or click to view image in full size
the reducer for user
Press enter or click to view image in full size
the action to set foreign region value

9. It forces React.component with possible name ForeignRegionBanner to rerender (at least one prop was changed)

Press enter or click to view image in full size

10. And finally you can see the warning message on the page

Alexey Berezin,
Front-end Developer from Yandex

LinkedIn
GitHub

--

--

Alexey Berezin
Alexey Berezin

Written by Alexey Berezin

Senior Software Engineer, Bloomberg

No responses yet