2013-12-16 21:34:41 +01:00
# coding: utf-8
2014-03-23 17:43:33 +01:00
from __future__ import unicode_literals
2013-12-16 21:34:41 +01:00
import re
from . common import InfoExtractor
class RadioFranceIE ( InfoExtractor ) :
_VALID_URL = r ' ^https?://maison \ .radiofrance \ .fr/radiovisions/(?P<id>[^?#]+) '
2014-03-23 17:43:33 +01:00
IE_NAME = ' radiofrance '
2013-12-16 21:34:41 +01:00
_TEST = {
2014-03-23 17:43:33 +01:00
' url ' : ' http://maison.radiofrance.fr/radiovisions/one-one ' ,
' md5 ' : ' bdbb28ace95ed0e04faab32ba3160daf ' ,
' info_dict ' : {
' id ' : ' one-one ' ,
' ext ' : ' ogg ' ,
" title " : " One to one " ,
" description " : " Plutôt que d ' imaginer la radio de demain comme technologie ou comme création de contenu, je veux montrer que quelles que soient ses évolutions, j ' ai l ' intime conviction que la radio continuera d ' être un grand média de proximité pour les auditeurs. " ,
" uploader " : " Thomas Hercouët " ,
2013-12-16 21:34:41 +01:00
} ,
}
def _real_extract ( self , url ) :
m = re . match ( self . _VALID_URL , url )
video_id = m . group ( ' id ' )
webpage = self . _download_webpage ( url , video_id )
2014-03-23 17:43:33 +01:00
title = self . _html_search_regex ( r ' <h1>(.*?)</h1> ' , webpage , ' title ' )
2013-12-16 21:34:41 +01:00
description = self . _html_search_regex (
r ' <div class= " bloc_page_wrapper " ><div class= " text " >(.*?)</div> ' ,
2014-03-23 17:43:33 +01:00
webpage , ' description ' , fatal = False )
2013-12-16 21:34:41 +01:00
uploader = self . _html_search_regex (
r ' <div class= " credit " > © (.*?)</div> ' ,
2014-03-23 17:43:33 +01:00
webpage , ' uploader ' , fatal = False )
2013-12-16 21:34:41 +01:00
formats_str = self . _html_search_regex (
r ' class= " jp-jplayer[^ " ]* " data-source= " ([^ " ]+) " > ' ,
2014-03-23 17:43:33 +01:00
webpage , ' audio URLs ' )
2013-12-16 21:34:41 +01:00
formats = [
{
2013-12-17 12:35:16 +01:00
' format_id ' : fm [ 0 ] ,
' url ' : fm [ 1 ] ,
2013-12-16 21:34:41 +01:00
' vcodec ' : ' none ' ,
2014-03-23 17:43:33 +01:00
' preference ' : i ,
2013-12-16 21:34:41 +01:00
}
2014-03-23 17:43:33 +01:00
for i , fm in
enumerate ( re . findall ( r " ([a-z0-9]+) \ s*: \ s* ' ([^ ' ]+) ' " , formats_str ) )
2013-12-16 21:34:41 +01:00
]
2014-03-23 17:43:33 +01:00
self . _sort_formats ( formats )
2013-12-16 21:34:41 +01:00
return {
' id ' : video_id ,
' title ' : title ,
' formats ' : formats ,
' description ' : description ,
' uploader ' : uploader ,
}