Skip to content

Commit

Permalink
style checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Amirthan committed Dec 10, 2024
1 parent acea8f3 commit a875612
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions youtube_dl/extractor/canalrcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
from .common import InfoExtractor
from ..utils import (
ExtractorError,
clean_html,
try_get,
)
import json


class CanalrcnIE(InfoExtractor):
"""Information extractor for canalrcn.com"""

_VALID_URL = r'https?://(?:www\.)?canalrcn\.com/(?:[^/]+/)+(?P<id>[^/?&#]+)'

# Specify geo-restriction
_GEO_COUNTRIES = ['CO']

_TESTS = [{
'url': 'https://www.canalrcn.com/la-rosa-de-guadalupe/capitulos/la-rosa-de-guadalupe-capitulo-58-los-enamorados-3619',
'info_dict': {
Expand All @@ -34,23 +35,23 @@ class CanalrcnIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)

json_ld = self._search_regex(
r'<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json>[^<]+)</script>',
webpage, 'JSON-LD', group='json', default='{}')

try:
json_data = json.loads(json_ld)
except json.JSONDecodeError:
raise ExtractorError('Could not parse JSON-LD data')

video_data = None
if isinstance(json_data, list):
for item in json_data:
if isinstance(item, dict) and item.get('@type') == 'VideoObject':
video_data = item
break

if not video_data:
raise ExtractorError('Could not find video information in JSON-LD data')

Expand All @@ -63,8 +64,7 @@ def _real_extract(self, url):
embed_url,
'dailymotion id'
)

#geo-restriction handling
# geo-restriction handling
self.raise_geo_restricted(
msg='This video is only available in Colombia',
countries=self._GEO_COUNTRIES
Expand All @@ -79,4 +79,4 @@ def _real_extract(self, url):
'description': video_data.get('description'),
'thumbnail': video_data.get('thumbnailUrl'),
'duration': video_data.get('duration'),
}
}

0 comments on commit a875612

Please sign in to comment.