Geolocation identification in BBC iPlayer (2019 edition)
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:
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:
Let’s go through it to get a general idea of what is going on here:
- First, user profile is initialised
-
Then many auxiliary functions are declared, skip them for now.
-
User API is declared in
window.bbcuser, some of the functions usegetUserInfo
-
getUserInfochecks 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:
iPlayer userinfo response - Otherwise, there’s a fallback function which loads module
orb/figwith_figManager.js. It uses microservice which is available on fig.js and returns a code which is executed later on. The most interest part here is a parameteruk— it equals1if the request has been sent from the UK, otherwise0 - 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
0and the content wasn’t available. The response was:iPlayer fig response
-
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:
-
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 flagisForeignRegion(which is under user and isnullby default). -
When
app.bundle.jsis loaded,componentDidMoundchecks thatisUKis not0. As it’s0, it calls callback functiononUserForeignRegion:
- It updates store value of
isForeignRegion:
- It forces
React.componentwith possible nameForeignRegionBannerto rerender (at least one prop was changed)
- And finally you can see the warning message on the page