mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.8 KiB
Python
74 lines
2.8 KiB
Python
11 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
from .common import InfoExtractor
|
||
10 years ago
|
from ..utils import (
|
||
|
determine_ext,
|
||
8 years ago
|
extract_attributes,
|
||
|
int_or_none,
|
||
10 years ago
|
)
|
||
11 years ago
|
|
||
|
|
||
|
class FranceCultureIE(InfoExtractor):
|
||
8 years ago
|
_VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emissions/(?:[^/]+/)*(?P<id>[^/?#&]+)'
|
||
4 years ago
|
_TESTS = [{
|
||
8 years ago
|
'url': 'http://www.franceculture.fr/emissions/carnet-nomade/rendez-vous-au-pays-des-geeks',
|
||
11 years ago
|
'info_dict': {
|
||
8 years ago
|
'id': 'rendez-vous-au-pays-des-geeks',
|
||
|
'display_id': 'rendez-vous-au-pays-des-geeks',
|
||
11 years ago
|
'ext': 'mp3',
|
||
|
'title': 'Rendez-vous au pays des geeks',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||
11 years ago
|
'upload_date': '20140301',
|
||
4 years ago
|
'timestamp': 1393700400,
|
||
8 years ago
|
'vcodec': 'none',
|
||
11 years ago
|
}
|
||
4 years ago
|
}, {
|
||
|
# no thumbnail
|
||
|
'url': 'https://www.franceculture.fr/emissions/la-recherche-montre-en-main/la-recherche-montre-en-main-du-mercredi-10-octobre-2018',
|
||
|
'only_matching': True,
|
||
|
}]
|
||
11 years ago
|
|
||
8 years ago
|
def _real_extract(self, url):
|
||
|
display_id = self._match_id(url)
|
||
10 years ago
|
|
||
8 years ago
|
webpage = self._download_webpage(url, display_id)
|
||
11 years ago
|
|
||
8 years ago
|
video_data = extract_attributes(self._search_regex(
|
||
5 years ago
|
r'''(?sx)
|
||
|
(?:
|
||
|
</h1>|
|
||
|
<div[^>]+class="[^"]*?(?:title-zone-diffusion|heading-zone-(?:wrapper|player-button))[^"]*?"[^>]*>
|
||
|
).*?
|
||
4 years ago
|
(<button[^>]+data-(?:url|asset-source)="[^"]+"[^>]+>)
|
||
5 years ago
|
''',
|
||
8 years ago
|
webpage, 'video data'))
|
||
9 years ago
|
|
||
4 years ago
|
video_url = video_data.get('data-url') or video_data['data-asset-source']
|
||
|
title = video_data.get('data-asset-title') or video_data.get('data-diffusion-title') or self._og_search_title(webpage)
|
||
11 years ago
|
|
||
8 years ago
|
description = self._html_search_regex(
|
||
|
r'(?s)<div[^>]+class="intro"[^>]*>.*?<h2>(.+?)</h2>',
|
||
|
webpage, 'description', default=None)
|
||
8 years ago
|
thumbnail = self._search_regex(
|
||
8 years ago
|
r'(?s)<figure[^>]+itemtype="https://schema.org/ImageObject"[^>]*>.*?<img[^>]+(?:data-dejavu-)?src="([^"]+)"',
|
||
4 years ago
|
webpage, 'thumbnail', default=None)
|
||
10 years ago
|
uploader = self._html_search_regex(
|
||
8 years ago
|
r'(?s)<span class="author">(.*?)</span>',
|
||
10 years ago
|
webpage, 'uploader', default=None)
|
||
8 years ago
|
ext = determine_ext(video_url.lower())
|
||
11 years ago
|
|
||
|
return {
|
||
8 years ago
|
'id': display_id,
|
||
|
'display_id': display_id,
|
||
11 years ago
|
'url': video_url,
|
||
|
'title': title,
|
||
8 years ago
|
'description': description,
|
||
11 years ago
|
'thumbnail': thumbnail,
|
||
8 years ago
|
'ext': ext,
|
||
|
'vcodec': 'none' if ext == 'mp3' else None,
|
||
8 years ago
|
'uploader': uploader,
|
||
4 years ago
|
'timestamp': int_or_none(video_data.get('data-start-time')) or int_or_none(video_data.get('data-asset-created-date')),
|
||
8 years ago
|
'duration': int_or_none(video_data.get('data-duration')),
|
||
11 years ago
|
}
|