2015-07-25 14:21:42 +00:00
# coding: utf-8
2014-02-08 14:55:28 +00:00
from __future__ import unicode_literals
2015-07-25 14:21:42 +00:00
import re
2016-08-15 21:36:23 +00:00
import itertools
2014-02-08 14:55:28 +00:00
2015-02-19 15:46:41 +00:00
from . common import InfoExtractor
2015-04-30 21:59:13 +00:00
from . . utils import (
2017-05-26 15:12:24 +00:00
clean_html ,
2016-08-07 11:01:50 +00:00
dict_get ,
2015-04-30 21:59:13 +00:00
ExtractorError ,
2015-07-25 14:21:42 +00:00
float_or_none ,
2017-05-26 15:12:24 +00:00
get_element_by_class ,
2015-04-30 21:59:13 +00:00
int_or_none ,
2018-06-02 21:07:59 +00:00
js_to_json ,
2015-07-25 14:21:42 +00:00
parse_duration ,
parse_iso8601 ,
2016-08-07 11:01:50 +00:00
try_get ,
2015-10-10 14:34:06 +00:00
unescapeHTML ,
2017-05-26 15:12:24 +00:00
urlencode_postdata ,
urljoin ,
2015-04-30 21:59:13 +00:00
)
2015-10-25 19:04:55 +00:00
from . . compat import (
compat_HTTPError ,
2016-08-15 21:36:23 +00:00
compat_urlparse ,
2015-10-25 19:04:55 +00:00
)
2014-02-08 14:55:28 +00:00
2015-07-29 18:55:06 +00:00
2015-02-19 15:46:41 +00:00
class BBCCoUkIE ( InfoExtractor ) :
2014-02-08 14:55:28 +00:00
IE_NAME = ' bbc.co.uk '
2014-02-08 21:00:24 +00:00
IE_DESC = ' BBC iPlayer '
2017-08-29 22:27:56 +00:00
_ID_REGEX = r ' [pbw][ \ da-z] {7} '
2016-01-02 13:22:39 +00:00
_VALID_URL = r ''' (?x)
https ? : / /
( ? : www \. ) ? bbc \. co \. uk /
( ? :
programmes / ( ? ! articles / ) |
iplayer ( ? : / [ ^ / ] + ) ? / ( ? : episode / | playlist / ) |
2017-06-29 15:29:28 +00:00
music / ( ? : clips | audiovideo / popular ) [ / #]|
2017-08-19 16:54:15 +00:00
radio / player / |
events / [ ^ / ] + / play / [ ^ / ] + /
2016-01-02 13:22:39 +00:00
)
2016-06-17 16:42:52 +00:00
( ? P < id > % s ) ( ? ! / ( ? : episodes | broadcasts | clips ) )
2016-01-02 13:22:39 +00:00
''' % _ID_REGEX
2014-02-08 14:55:28 +00:00
2017-05-26 15:12:24 +00:00
_LOGIN_URL = ' https://account.bbc.com/signin '
_NETRC_MACHINE = ' bbc '
2015-07-29 18:55:06 +00:00
_MEDIASELECTOR_URLS = [
2015-09-26 14:06:21 +00:00
# Provides HQ HLS streams with even better quality that pc mediaset but fails
# with geolocation in some cases when it's even not geo restricted at all (e.g.
2015-11-14 17:08:13 +00:00
# http://www.bbc.co.uk/programmes/b06bp7lf). Also may fail with selectionunavailable.
2015-09-18 18:51:41 +00:00
' http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/iptv-all/vpid/ %s ' ,
2015-07-29 18:55:06 +00:00
' http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/pc/vpid/ %s ' ,
]
2015-06-19 06:52:25 +00:00
2015-10-10 17:01:20 +00:00
_MEDIASELECTION_NS = ' http://bbc.co.uk/2008/mp/mediaselection '
_EMP_PLAYLIST_NS = ' http://bbc.co.uk/2008/emp/playlist '
_NAMESPACES = (
_MEDIASELECTION_NS ,
_EMP_PLAYLIST_NS ,
)
2014-02-08 21:00:24 +00:00
_TESTS = [
{
2014-02-18 23:46:14 +00:00
' url ' : ' http://www.bbc.co.uk/programmes/b039g8p7 ' ,
2014-02-08 21:00:24 +00:00
' info_dict ' : {
2014-02-18 23:46:14 +00:00
' id ' : ' b039d07m ' ,
2016-07-17 10:29:36 +00:00
' ext ' : ' flv ' ,
2015-12-05 08:45:24 +00:00
' title ' : ' Leonard Cohen, Kaleidoscope - BBC Radio 4 ' ,
2015-01-02 16:13:26 +00:00
' description ' : ' The Canadian poet and songwriter reflects on his musical career. ' ,
2014-02-08 21:00:24 +00:00
} ,
' params ' : {
2016-07-17 10:29:36 +00:00
# rtmp download
2014-02-08 21:00:24 +00:00
' skip_download ' : True ,
}
2014-02-08 14:55:28 +00:00
} ,
2014-02-08 21:00:24 +00:00
{
' url ' : ' http://www.bbc.co.uk/iplayer/episode/b00yng5w/The_Man_in_Black_Series_3_The_Printed_Name/ ' ,
' info_dict ' : {
' id ' : ' b00yng1d ' ,
' ext ' : ' flv ' ,
' title ' : ' The Man in Black: Series 3: The Printed Name ' ,
' description ' : " Mark Gatiss introduces Nicholas Pierpan ' s chilling tale of a writer ' s devilish pact with a mysterious man. Stars Ewan Bailey. " ,
' duration ' : 1800 ,
} ,
' params ' : {
# rtmp download
' skip_download ' : True ,
2014-02-17 17:26:12 +00:00
} ,
' skip ' : ' Episode is no longer available on BBC iPlayer Radio ' ,
2014-02-08 21:00:24 +00:00
} ,
{
' url ' : ' http://www.bbc.co.uk/iplayer/episode/b03vhd1f/The_Voice_UK_Series_3_Blind_Auditions_5/ ' ,
' info_dict ' : {
' id ' : ' b00yng1d ' ,
' ext ' : ' flv ' ,
2014-02-08 21:04:21 +00:00
' title ' : ' The Voice UK: Series 3: Blind Auditions 5 ' ,
2016-02-14 09:37:17 +00:00
' description ' : ' Emma Willis and Marvin Humes present the fifth set of blind auditions in the singing competition, as the coaches continue to build their teams based on voice alone. ' ,
2014-02-08 21:04:21 +00:00
' duration ' : 5100 ,
2014-02-08 21:00:24 +00:00
} ,
' params ' : {
# rtmp download
' skip_download ' : True ,
} ,
2016-07-17 10:29:36 +00:00
' skip ' : ' Currently BBC iPlayer TV programmes are available to play in the UK only ' ,
2014-11-30 16:37:56 +00:00
} ,
{
' url ' : ' http://www.bbc.co.uk/iplayer/episode/p026c7jt/tomorrows-worlds-the-unearthly-history-of-science-fiction-2-invasion ' ,
' info_dict ' : {
' id ' : ' b03k3pb7 ' ,
' ext ' : ' flv ' ,
' title ' : " Tomorrow ' s Worlds: The Unearthly History of Science Fiction " ,
' description ' : ' 2. Invasion ' ,
' duration ' : 3600 ,
} ,
' params ' : {
# rtmp download
' skip_download ' : True ,
} ,
2016-07-17 10:29:36 +00:00
' skip ' : ' Currently BBC iPlayer TV programmes are available to play in the UK only ' ,
2014-12-28 21:00:24 +00:00
} , {
' url ' : ' http://www.bbc.co.uk/programmes/b04v20dw ' ,
' info_dict ' : {
' id ' : ' b04v209v ' ,
' ext ' : ' flv ' ,
' title ' : ' Pete Tong, The Essential New Tune Special ' ,
' description ' : " Pete has a very special mix - all of 2014 ' s Essential New Tunes! " ,
' duration ' : 10800 ,
} ,
' params ' : {
# rtmp download
' skip_download ' : True ,
2015-12-05 08:51:13 +00:00
} ,
' skip ' : ' Episode is no longer available on BBC iPlayer Radio ' ,
2015-01-03 14:43:40 +00:00
} , {
2016-01-03 20:55:25 +00:00
' url ' : ' http://www.bbc.co.uk/music/clips/p022h44b ' ,
2015-01-03 14:43:40 +00:00
' note ' : ' Audio ' ,
' info_dict ' : {
2016-01-03 20:55:25 +00:00
' id ' : ' p022h44j ' ,
2016-07-17 10:29:36 +00:00
' ext ' : ' flv ' ,
2016-01-03 20:55:25 +00:00
' title ' : ' BBC Proms Music Guides, Rachmaninov: Symphonic Dances ' ,
' description ' : " In this Proms Music Guide, Andrew McGregor looks at Rachmaninov ' s Symphonic Dances. " ,
' duration ' : 227 ,
2015-01-03 14:43:40 +00:00
} ,
' params ' : {
2016-07-17 10:29:36 +00:00
# rtmp download
2015-01-03 14:43:40 +00:00
' skip_download ' : True ,
}
} , {
' url ' : ' http://www.bbc.co.uk/music/clips/p025c0zz ' ,
' note ' : ' Video ' ,
' info_dict ' : {
' id ' : ' p025c103 ' ,
2016-07-17 10:29:36 +00:00
' ext ' : ' flv ' ,
2015-01-03 14:43:40 +00:00
' title ' : ' Reading and Leeds Festival, 2014, Rae Morris - Closer (Live on BBC Three) ' ,
' description ' : ' Rae Morris performs Closer for BBC Three at Reading 2014 ' ,
' duration ' : 226 ,
} ,
' params ' : {
2016-07-17 10:29:36 +00:00
# rtmp download
2015-01-03 14:43:40 +00:00
' skip_download ' : True ,
}
2015-04-30 22:02:56 +00:00
} , {
' url ' : ' http://www.bbc.co.uk/iplayer/episode/b054fn09/ad/natural-world-20152016-2-super-powered-owls ' ,
' info_dict ' : {
' id ' : ' p02n76xf ' ,
' ext ' : ' flv ' ,
' title ' : ' Natural World, 2015-2016: 2. Super Powered Owls ' ,
' description ' : ' md5:e4db5c937d0e95a7c6b5e654d429183d ' ,
' duration ' : 3540 ,
} ,
' params ' : {
# rtmp download
' skip_download ' : True ,
} ,
2016-07-17 10:29:36 +00:00
' skip ' : ' geolocation ' ,
2015-06-18 14:00:13 +00:00
} , {
' url ' : ' http://www.bbc.co.uk/iplayer/episode/b05zmgwn/royal-academy-summer-exhibition ' ,
' info_dict ' : {
' id ' : ' b05zmgw1 ' ,
' ext ' : ' flv ' ,
' description ' : ' Kirsty Wark and Morgan Quaintance visit the Royal Academy as it prepares for its annual artistic extravaganza, meeting people who have come together to make the show unique. ' ,
' title ' : ' Royal Academy Summer Exhibition ' ,
' duration ' : 3540 ,
} ,
' params ' : {
# rtmp download