Skip to content
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

[BrainPOP] Add new extractor (Closes #10000) #10025

Closed
wants to merge 5 commits into from

Conversation

nehalvpatel
Copy link
Contributor

@nehalvpatel nehalvpatel commented Jul 7, 2016

Before submitting a pull request make sure you have:

What is the purpose of your pull request?

  • Bug fix
  • New extractor
  • New feature

Description of your pull request and other information

Added a new extractor for BrainPOP. In addition to the video, it extracts the description and the thumbnail. It should work on any video on the site, even if it's in a different language.


self.report_extraction(video_id)

ec_token = self._html_search_regex(r'ec_token : \'(.+)\'', webpage, 'token')
Copy link
Contributor

Choose a reason for hiding this comment

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

Its easier to parse the JSON instead of searching through it manually.

Copy link
Contributor Author

@nehalvpatel nehalvpatel Jul 8, 2016

Choose a reason for hiding this comment

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

@TRox1972 Right, but the JSON is mixed in with the HTML. How should I go about extracting it?

EDIT: I think I found a way.


self.report_extraction(video_id)

ec_token = self._html_search_regex(r"ec_token : '([^']*)'", webpage, 'token')
Copy link
Contributor

Choose a reason for hiding this comment

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

It this needed? Does it work without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The token? Yea, you can't access the videos without it.

'id': content['category']['unit']['topic']['EntryID'],
'display_id': display_id,
'title': remove_end(settings['title'], ' - BrainPOP'),
'description': settings['description'],
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be non-fatal

'display_id': display_id,
'title': remove_end(settings['title'], ' - BrainPOP'),
'description': settings['description'],
'title': remove_end(settings.get('title', display_id), ' - BrainPOP'),
Copy link
Contributor

Choose a reason for hiding this comment

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

The title should be mandatory

Copy link
Collaborator

Choose a reason for hiding this comment

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

Such a pattern is OK if title is missing in settings. @nehalvpatel Do you have an example?

Copy link
Contributor

@TRox1972 TRox1972 Jul 13, 2016

Choose a reason for hiding this comment

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

title can be extracted from <title>(.*)</title> also. One of them should be fatal, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Either way is fine. In general <title> is better than extracting from embedded data as the former is less likely to change. If there's an example that <title> or settings['title'] is missing, a fallback should be provided, otherwise the extraction should be fatal.

@EpicCodeWizard
Copy link

Does this thing still work?

pukkandan pushed a commit to yt-dlp/yt-dlp that referenced this pull request Apr 12, 2023
@dirkf dirkf closed this Aug 1, 2023
@dirkf dirkf added the defunct PR source branch is not accessible label Oct 2, 2023
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defunct PR source branch is not accessible pending-fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants