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

[Stitcher] - Reorganized call to json data accessing of {config} and … #20811

Closed

Conversation

zanejchen
Copy link

…{feed} to support return of show_title and publication_date in response to ticket #20510

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 youtube-dl 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

Responding to @wertercatt's open ticket (Ticket #20510) for poor metadata extraction of Stitcher URLs, I added the support to display the show that uploaded the podcast episode as well as the release/publication date in the info_dict object. These two items are encoded as "show_name" and "publication_date".

A test case was added to test the new functionality of "show_name" and "publication_date".

Subsequently, I noticed that the contribution and coding practice guidelines recommending using the get() method to better support backwards compatibility so that the extractor code does not break. Therefore, I reformatted the previous calls to self._parse_json() to utilize the get() method to extract data from ['config']['episode'] and ['config']['feed'] for "show_name" and "publication_date" respectively.

…{feed} to support return of show_title and publication_date in response to ticket #20510
# Safe grab 'config' json data using get()
config = self._parse_json(
js_to_json(self._search_regex(r'(?s)var\s+stitcher(?:Config)?\s*=\s*({.+?});\n', webpage, 'episode config')),
display_id).get('config')
Copy link
Collaborator

Choose a reason for hiding this comment

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

No, this does not make any sense.

display_id).get('config')

# Safe grab 'episode' json data using get()
episode = config.get('episode')
Copy link
Collaborator

Choose a reason for hiding this comment

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

No.

episode = config.get('episode')

# Safe grab 'episode' json data using get()
feed = config.get('feed')
Copy link
Collaborator

Choose a reason for hiding this comment

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

No, this does not give your any safety.

@@ -69,12 +88,16 @@ def _real_extract(self, url):
r'Episode Info:\s*</span>([^<]+)<', webpage, 'description', fatal=False)
duration = int_or_none(episode.get('duration'))
thumbnail = episode.get('episodeImage')
pub_date = episode.get('pubDate')
show_name = feed.get('name')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Breaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants