Skip to content

Conversation

Ashish0804
Copy link
Contributor

@Ashish0804 Ashish0804 commented Nov 13, 2021

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

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:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

closes #1528

TODO:

  • Add tests
  • Improve json regex to not break for "
  • Parse subtitles if avilable (Not available)

@Ashish0804 Ashish0804 marked this pull request as ready for review November 15, 2021 10:00
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']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long

Comment on lines 79 to 87
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),
})
Copy link
Member

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')])

'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')),
Copy link
Member

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

return {
'id': id,
'title': data_json.get('title').strip(),
'description': clean_html(data_json.get('longDesc') or data_json.get('shortDesc')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict_get

@pukkandan pukkandan added the pending-fixes PR has had changes requested label Nov 16, 2021
@Ashish0804 Ashish0804 requested a review from pukkandan November 16, 2021 05:47
@pukkandan pukkandan removed the pending-fixes PR has had changes requested label Nov 16, 2021
@Ashish0804 Ashish0804 merged commit 9d63137 into yt-dlp:master Nov 18, 2021
@Ashish0804 Ashish0804 deleted the canalalpha branch December 26, 2021 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Canal Alpha
2 participants