mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 15:44:30 +00:00
[canalplus] Fix id determination (Fixes #2851)
This commit is contained in:
parent
0067d6c4be
commit
4de9e9a6db
1 changed files with 11 additions and 4 deletions
|
@ -4,11 +4,14 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import unified_strdate
|
from ..utils import (
|
||||||
|
unified_strdate,
|
||||||
|
url_basename,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CanalplusIE(InfoExtractor):
|
class CanalplusIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>\d+))'
|
_VALID_URL = r'https?://(?:www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>[0-9]+))'
|
||||||
_VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
|
_VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
|
||||||
IE_NAME = 'canalplus.fr'
|
IE_NAME = 'canalplus.fr'
|
||||||
|
|
||||||
|
@ -26,10 +29,13 @@ class CanalplusIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.groupdict().get('id')
|
||||||
|
|
||||||
|
# Beware, some subclasses do not define an id group
|
||||||
|
display_id = url_basename(mobj.group('path'))
|
||||||
|
|
||||||
if video_id is None:
|
if video_id is None:
|
||||||
webpage = self._download_webpage(url, mobj.group('path'))
|
webpage = self._download_webpage(url, display_id)
|
||||||
video_id = self._search_regex(r'<canal:player videoId="(\d+)"', webpage, 'video id')
|
video_id = self._search_regex(r'<canal:player videoId="(\d+)"', webpage, 'video id')
|
||||||
|
|
||||||
info_url = self._VIDEO_INFO_TEMPLATE % video_id
|
info_url = self._VIDEO_INFO_TEMPLATE % video_id
|
||||||
|
@ -53,6 +59,7 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
'display_id': display_id,
|
||||||
'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
|
'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
|
||||||
infos.find('TITRAGE/SOUS_TITRE').text),
|
infos.find('TITRAGE/SOUS_TITRE').text),
|
||||||
'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
|
'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
|
||||||
|
|
Loading…
Reference in a new issue