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

[iTunes] Add new extractor (Closes #2097) #9590

Closed
wants to merge 1 commit into from

Conversation

TRox1972
Copy link
Contributor

@TRox1972 TRox1972 commented May 23, 2016

The extractor only works for free content, like most podcasts, i.e. it does not download 30-seconds previews of paid songs.

@TRox1972 TRox1972 changed the title [iTunes] Add new extractor [iTunes] Add new extractor (Closes #2097) May 23, 2016

webpage = self._download_webpage(sanitized_Request(self._html_search_regex(
r'<string>\s*(https?://itunes.apple.com/[^>]+)</string>', self._download_webpage(
request, display_id), 'iTunes url'), headers={'User-Agent': self._USER_AGENT}), display_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid such cumbersome code. That's unreadable.

@yan12125
Copy link
Collaborator

Seems without an iTunes User-Agent, the response from https://itunes.apple.com/us/itunes-u/uc-davis-symphony-orchestra/id403834767 just contains all what we want. If you're going to keep the current approach, use self._download_xml() and xpath_text() instead of parsing XML by hand.

# coding: utf-8
from __future__ import unicode_literals

import datetime
Copy link
Collaborator

Choose a reason for hiding this comment

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

No longer used.

@TRox1972
Copy link
Contributor Author

@yan12125 You're right. I'll change the approach to not spoof the user agent.

webpage = self._download_webpage(url, display_id)

video_infos = re.findall(r'var\s+__desc_popup_d_\d+\s*=\s*({[^><]+});', webpage)
html_entries = re.findall(r'<tr\s+[^>]*role="row"[^>]+>', webpage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

get_element_by_attribute() may be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will get the content between <tr> and </tr>, but not the content inside the tags, like <tr preview-duration="485000">

@yan12125
Copy link
Collaborator

Don't git push for each commit, or Travis CI will be flooded.

@TRox1972
Copy link
Contributor Author

@yan12125 Sorry didn't know that.

@TRox1972 TRox1972 force-pushed the p18 branch 2 times, most recently from d4bf26f to 5762b67 Compare May 28, 2016 12:20
@TRox1972
Copy link
Contributor Author

@yan12125 @dstftw Does this seem good?



class iTunesIE(InfoExtractor):
_VALID_URL = r'https?://itunes\.apple\.com/[a-z]{2}/[a-z0-9-]+/(?P<display_id>[a-z0-9-]+)?/(?:id)?(?P<id>[0-9]+)'
Copy link

Choose a reason for hiding this comment

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

It should be the following as the (valid) URL variations of https://itunes.apple.com/us/itunes-u/uc-davis-symphony-orchestra/id403834767 don't match otherwise

_VALID_URL = r'https?://itunes\.apple\.com/[a-z]{2}?/?[a-z0-9-]+/?(?P<display_id>[a-z0-9-]+)?/(?:id)?(?P<id>[0-9]+)'

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants