mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 14:25:12 +00:00
style checks
This commit is contained in:
parent
acea8f31d4
commit
a87561248a
@ -4,17 +4,18 @@ from __future__ import unicode_literals
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
clean_html,
|
|
||||||
try_get,
|
|
||||||
)
|
)
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class CanalrcnIE(InfoExtractor):
|
class CanalrcnIE(InfoExtractor):
|
||||||
|
"""Information extractor for canalrcn.com"""
|
||||||
|
|
||||||
_VALID_URL = r'https?://(?:www\.)?canalrcn\.com/(?:[^/]+/)+(?P<id>[^/?&#]+)'
|
_VALID_URL = r'https?://(?:www\.)?canalrcn\.com/(?:[^/]+/)+(?P<id>[^/?&#]+)'
|
||||||
|
|
||||||
# Specify geo-restriction
|
# Specify geo-restriction
|
||||||
_GEO_COUNTRIES = ['CO']
|
_GEO_COUNTRIES = ['CO']
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.canalrcn.com/la-rosa-de-guadalupe/capitulos/la-rosa-de-guadalupe-capitulo-58-los-enamorados-3619',
|
'url': 'https://www.canalrcn.com/la-rosa-de-guadalupe/capitulos/la-rosa-de-guadalupe-capitulo-58-los-enamorados-3619',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -34,23 +35,23 @@ class CanalrcnIE(InfoExtractor):
|
|||||||
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)
|
||||||
|
|
||||||
json_ld = self._search_regex(
|
json_ld = self._search_regex(
|
||||||
r'<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json>[^<]+)</script>',
|
r'<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json>[^<]+)</script>',
|
||||||
webpage, 'JSON-LD', group='json', default='{}')
|
webpage, 'JSON-LD', group='json', default='{}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json_data = json.loads(json_ld)
|
json_data = json.loads(json_ld)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise ExtractorError('Could not parse JSON-LD data')
|
raise ExtractorError('Could not parse JSON-LD data')
|
||||||
|
|
||||||
video_data = None
|
video_data = None
|
||||||
if isinstance(json_data, list):
|
if isinstance(json_data, list):
|
||||||
for item in json_data:
|
for item in json_data:
|
||||||
if isinstance(item, dict) and item.get('@type') == 'VideoObject':
|
if isinstance(item, dict) and item.get('@type') == 'VideoObject':
|
||||||
video_data = item
|
video_data = item
|
||||||
break
|
break
|
||||||
|
|
||||||
if not video_data:
|
if not video_data:
|
||||||
raise ExtractorError('Could not find video information in JSON-LD data')
|
raise ExtractorError('Could not find video information in JSON-LD data')
|
||||||
|
|
||||||
@ -63,8 +64,7 @@ class CanalrcnIE(InfoExtractor):
|
|||||||
embed_url,
|
embed_url,
|
||||||
'dailymotion id'
|
'dailymotion id'
|
||||||
)
|
)
|
||||||
|
# geo-restriction handling
|
||||||
#geo-restriction handling
|
|
||||||
self.raise_geo_restricted(
|
self.raise_geo_restricted(
|
||||||
msg='This video is only available in Colombia',
|
msg='This video is only available in Colombia',
|
||||||
countries=self._GEO_COUNTRIES
|
countries=self._GEO_COUNTRIES
|
||||||
@ -79,4 +79,4 @@ class CanalrcnIE(InfoExtractor):
|
|||||||
'description': video_data.get('description'),
|
'description': video_data.get('description'),
|
||||||
'thumbnail': video_data.get('thumbnailUrl'),
|
'thumbnail': video_data.get('thumbnailUrl'),
|
||||||
'duration': video_data.get('duration'),
|
'duration': video_data.get('duration'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user