mirror of https://github.com/yt-dlp/yt-dlp.git
[utils,franceinter] Add french months' names and fix extraction
Update of the "FranceInter" radio extractor : webpages HTML structure had changed, the extractor didn't work. So I updated this extractor to get the mp3 URL and all details.
This commit is contained in:
parent
961516bfd1
commit
a942d6cb48
|
@ -2,20 +2,24 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import int_or_none
|
from ..utils import (
|
||||||
|
unified_timestamp,
|
||||||
|
month_by_name,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FranceInterIE(InfoExtractor):
|
class FranceInterIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?franceinter\.fr/player/reecouter\?play=(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P<id>[^?#]+)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://www.franceinter.fr/player/reecouter?play=793962',
|
'url': 'https://www.franceinter.fr/emissions/la-marche-de-l-histoire/la-marche-de-l-histoire-18-decembre-2013',
|
||||||
'md5': '4764932e466e6f6c79c317d2e74f6884',
|
'md5': '4764932e466e6f6c79c317d2e74f6884',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '793962',
|
'id': 'la-marche-de-l-histoire/la-marche-de-l-histoire-18-decembre-2013',
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
'title': 'L’Histoire dans les jeux vidéo',
|
'title': 'L’Histoire dans les jeux vidéo du 18 décembre 2013 - France Inter',
|
||||||
'description': 'md5:7e93ddb4451e7530022792240a3049c7',
|
'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': 1387369800,
|
'timestamp': 1387324800,
|
||||||
'upload_date': '20131218',
|
'upload_date': '20131218',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -25,17 +29,17 @@ class FranceInterIE(InfoExtractor):
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
path = self._search_regex(
|
video_url = self._search_regex(
|
||||||
r'<a id="player".+?href="([^"]+)"', webpage, 'video url')
|
r'<button class="replay-button playable" data-is-aod="1" data-url="([^"]+)"', webpage, 'video url')
|
||||||
video_url = 'http://www.franceinter.fr/' + path
|
|
||||||
|
|
||||||
title = self._html_search_regex(
|
title = self._og_search_title(webpage)
|
||||||
r'<span class="title-diffusion">(.+?)</span>', webpage, 'title')
|
description = self._og_search_description(webpage)
|
||||||
description = self._html_search_regex(
|
|
||||||
r'<span class="description">(.*?)</span>',
|
extractdate = self._search_regex('(\d{2}-([a-zA-Z\s]+)-\d{4}$)', url, 'extractdate', fatal=False)
|
||||||
webpage, 'description', fatal=False)
|
extractdate = extractdate.split('-')
|
||||||
timestamp = int_or_none(self._search_regex(
|
extractdate = extractdate[2] + "," + str(month_by_name(extractdate[1], 'fr')) + "," + extractdate[0]
|
||||||
r'data-date="(\d+)"', webpage, 'upload date', fatal=False))
|
|
||||||
|
timestamp = unified_timestamp(extractdate)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
|
|
@ -91,6 +91,10 @@ ENGLISH_MONTH_NAMES = [
|
||||||
'January', 'February', 'March', 'April', 'May', 'June',
|
'January', 'February', 'March', 'April', 'May', 'June',
|
||||||
'July', 'August', 'September', 'October', 'November', 'December']
|
'July', 'August', 'September', 'October', 'November', 'December']
|
||||||
|
|
||||||
|
FRENCH_MONTH_NAMES = [
|
||||||
|
'janvier', 'fevrier', 'mars', 'avril', 'mai', 'juin',
|
||||||
|
'juillet', 'aout', 'septembre', 'octobre', 'novembre', 'decembre']
|
||||||
|
|
||||||
KNOWN_EXTENSIONS = (
|
KNOWN_EXTENSIONS = (
|
||||||
'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v', 'aac',
|
'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v', 'aac',
|
||||||
'flv', 'f4v', 'f4a', 'f4b',
|
'flv', 'f4v', 'f4a', 'f4b',
|
||||||
|
@ -1587,11 +1591,16 @@ def parse_count(s):
|
||||||
return lookup_unit_table(_UNIT_TABLE, s)
|
return lookup_unit_table(_UNIT_TABLE, s)
|
||||||
|
|
||||||
|
|
||||||
def month_by_name(name):
|
def month_by_name(name, lang='en'):
|
||||||
""" Return the number of a month by (locale-independently) English name """
|
""" Return the number of a month by (locale-independently) English name """
|
||||||
|
|
||||||
|
name_list = ENGLISH_MONTH_NAMES
|
||||||
|
|
||||||
|
if lang == 'fr':
|
||||||
|
name_list = FRENCH_MONTH_NAMES
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return ENGLISH_MONTH_NAMES.index(name) + 1
|
return name_list.index(name) + 1
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue