1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-15 06:13:04 +08:00

[franceculture] improve 2 beautiful

This commit is contained in:
flatgreen 2015-12-28 17:41:41 +01:00
parent bd7b1dd250
commit 3d2e410ec1
2 changed files with 6 additions and 12 deletions

View File

@ -200,7 +200,7 @@ from .foxnews import FoxNewsIE
from .foxsports import FoxSportsIE from .foxsports import FoxSportsIE
from .franceculture import ( from .franceculture import (
FranceCultureIE, FranceCultureIE,
FranceCultureUrlIE, FranceCultureEmissionIE,
) )
from .franceinter import FranceInterIE from .franceinter import FranceInterIE
from .francetv import ( from .francetv import (

View File

@ -1,8 +1,6 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import (
compat_urlparse, compat_urlparse,
@ -10,6 +8,7 @@ from ..compat import (
from ..utils import ( from ..utils import (
determine_ext, determine_ext,
int_or_none, int_or_none,
ExtractorError,
) )
@ -79,7 +78,7 @@ class FranceCultureIE(InfoExtractor):
return self._extract_infos_from_player(url, video_id) return self._extract_infos_from_player(url, video_id)
class FranceCultureUrlIE(FranceCultureIE): class FranceCultureEmissionIE(FranceCultureIE):
_VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emission-(?P<id>[^?#]+)' _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emission-(?P<id>[^?#]+)'
_TEST = { _TEST = {
'url': 'http://www.franceculture.fr/emission-les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', 'url': 'http://www.franceculture.fr/emission-les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13',
@ -95,19 +94,14 @@ class FranceCultureUrlIE(FranceCultureIE):
} }
} }
# dl url
# find : <a class="rf-player-open" href="/player/reecouter?play=5093239"><img ...></a>
# extract '/player/reecouter?play=5093239' join to url base of franceculture
# extract mp3 with FranceCultureIE _extract_infos_from_player
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_path = self._html_search_regex( video_path = self._html_search_regex(
r'<a class="rf-player-open".*?href="([^"]+)"', webpage, 'video path', 'no_path_player') r'<a class="rf-player-open".*?href="([^"]+)"', webpage, 'video path', 'no_path_player')
if video_path == 'no_path_player': if video_path == 'no_path_player':
self.to_screen('no player : no sound in this page.') raise ExtractorError('no player : no sound in this page.', expected=True)
return None return None
new_id = re.search('play=(?P<id>[0-9]+)', video_path).group('id') new_id = self._search_regex('play=(?P<id>[0-9]+)', video_path, 'new_id', group='id')
video_url = compat_urlparse.urljoin(url, video_path) video_url = compat_urlparse.urljoin(url, video_path)
return self._extract_infos_from_player(video_url, new_id) return self._extract_infos_from_player(video_url, new_id)