-
-
Notifications
You must be signed in to change notification settings - Fork 10k
[CanalAlpha] Add extractor. #1655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
yt_dlp/extractor/canalalpha.py
Outdated
def _real_extract(self, url): | ||
id = self._match_id(url) | ||
webpage = self._download_webpage(url, id) | ||
data_json = self._parse_json(self._search_regex(r'window\.__SERVER_STATE__\s?=\s?({(?:(?!};)[^"]|"([^"]|\\")*")+})\s?;', webpage, 'data_json'), id)['1']['data']['data'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long
yt_dlp/extractor/canalalpha.py
Outdated
for video in try_get(data_json, lambda x: x['video']['mp4'], expected_type=list) or []: | ||
video_url = video.get('$url') | ||
if video_url: | ||
formats.append({ | ||
'url': video_url, | ||
'ext': 'mp4', | ||
'width': try_get(video, lambda x: x['res']['width'], expected_type=int), | ||
'height': try_get(video, lambda x: x['res']['height'], expected_type=int), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd set formats to this before adding manifests. But not gonna force u tbh
formats = [
{...}
for video in ...
if video.get('$url')])
yt_dlp/extractor/canalalpha.py
Outdated
'title': data_json.get('title').strip(), | ||
'description': clean_html(data_json.get('longDesc') or data_json.get('shortDesc')), | ||
'thumbnail': data_json.get('poster'), | ||
'upload_date': unified_strdate(data_json.get('webPublishAt') or data_json.get('featuredAt') or data_json.get('diffusionDate')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use dict_get
/traverse_obj
yt_dlp/extractor/canalalpha.py
Outdated
return { | ||
'id': id, | ||
'title': data_json.get('title').strip(), | ||
'description': clean_html(data_json.get('longDesc') or data_json.get('shortDesc')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict_get
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
closes #1528
TODO:
Add testsImprove json regex to not break for"
Parse subtitles if avilable(Not available)