2014-01-17 03:09:07 +01:00
# coding: utf-8
2014-01-15 12:18:55 +01:00
from __future__ import unicode_literals
2014-01-15 07:19:50 +01:00
from . common import InfoExtractor
2016-09-02 18:31:52 +02:00
from . . utils import (
unified_timestamp ,
month_by_name ,
)
2014-01-17 03:09:07 +01:00
2014-01-15 07:19:50 +01:00
class FranceInterIE ( InfoExtractor ) :
2016-09-02 18:31:52 +02:00
_VALID_URL = r ' https?://(?:www \ .)?franceinter \ .fr/emissions/(?P<id>[^?#]+) '
2014-01-17 03:09:07 +01:00
_TEST = {
2016-09-02 18:31:52 +02:00
' url ' : ' https://www.franceinter.fr/emissions/la-marche-de-l-histoire/la-marche-de-l-histoire-18-decembre-2013 ' ,
2014-01-17 03:09:07 +01:00
' md5 ' : ' 4764932e466e6f6c79c317d2e74f6884 ' ,
2016-02-14 10:37:17 +01:00
' info_dict ' : {
2016-09-02 18:31:52 +02:00
' id ' : ' la-marche-de-l-histoire/la-marche-de-l-histoire-18-decembre-2013 ' ,
2014-09-19 15:58:50 +02:00
' ext ' : ' mp3 ' ,
2016-09-02 18:31:52 +02:00
' title ' : ' L’ Histoire dans les jeux vidéo du 18 décembre 2013 - France Inter ' ,
' description ' : ' L’ Histoire dans les jeux vidéo du 18 décembre 2013 par Jean Lebrun en replay sur France Inter. Retrouvez l \' émission en réécoute gratuite et abonnez-vous au podcast ! ' ,
' timestamp ' : 1387324800 ,
2014-09-19 15:58:50 +02:00
' upload_date ' : ' 20131218 ' ,
2014-01-17 03:09:07 +01:00
} ,
}
2014-01-15 07:19:50 +01:00
2014-01-17 03:09:07 +01:00
def _real_extract ( self , url ) :
2015-12-22 11:30:35 +01:00
video_id = self . _match_id ( url )
2014-01-17 03:10:54 +01:00
2014-01-17 03:09:07 +01:00
webpage = self . _download_webpage ( url , video_id )
2014-09-19 15:58:50 +02:00
2016-09-02 18:31:52 +02:00
video_url = self . _search_regex (
r ' <button class= " replay-button playable " data-is-aod= " 1 " data-url= " ([^ " ]+) " ' , webpage , ' video url ' )
title = self . _og_search_title ( webpage )
description = self . _og_search_description ( webpage )
extractdate = self . _search_regex ( ' ( \ d {2} -([a-zA-Z \ s]+)- \ d {4} $) ' , url , ' extractdate ' , fatal = False )
extractdate = extractdate . split ( ' - ' )
extractdate = extractdate [ 2 ] + " , " + str ( month_by_name ( extractdate [ 1 ] , ' fr ' ) ) + " , " + extractdate [ 0 ]
timestamp = unified_timestamp ( extractdate )
2014-09-19 15:58:50 +02:00
2014-01-17 03:09:07 +01:00
return {
' id ' : video_id ,
2014-09-19 15:58:50 +02:00
' title ' : title ,
' description ' : description ,
' timestamp ' : timestamp ,
2014-01-17 03:09:07 +01:00
' formats ' : [ {
' url ' : video_url ,
' vcodec ' : ' none ' ,
} ] ,
}