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

[pornhub] Download archive improvement #31432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ def _extract_entries(self, webpage, host):
return [
self.url_result(
'http://www.%s/%s' % (host, video_url),
PornHubIE.ie_key(), video_title=title)
for video_url, title in orderedSet(re.findall(
r'href="/?(view_video\.php\?.*\bviewkey=[\da-z]+[^"]*)"[^>]*\s+title="([^"]+)"',
PornHubIE.ie_key(), video_title=title, video_id=id)
for video_url, id, title in orderedSet(re.findall(
r'href="/?(view_video\.php\?.*\bviewkey=([\da-z]+)[^"]*)"[^>]*\s+title="([^"]+)"',
Comment on lines +521 to +523
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, if extracting the ID, that's the primary key on which we should be filtering.

        seen_ids = set()
        for m in re.finditer(
                r'href="/?(view_video\.php\?.*\bviewkey=([\da-z]+)[^"]*)"[^>]*\s+title="([^"]+)"',
                container):
            v_url, v_id, title = m.group(1, 2, 3)
            if v_id in seen_ids:
                continue
            yield self.url_result(
                'http://www.%s/%s' % (host, v_url),
                PornHubIE.ie_key(), video_title=title, video_id=v_id)
            seen_ids.add(v_id)

Anyhow, avoid a variable id since that has a specific meaning in Python.

Suggested change
PornHubIE.ie_key(), video_title=title, video_id=id)
for video_url, id, title in orderedSet(re.findall(
r'href="/?(view_video\.php\?.*\bviewkey=([\da-z]+)[^"]*)"[^>]*\s+title="([^"]+)"',
PornHubIE.ie_key(), video_title=title, video_id=v_id)
for video_url, v_id, title in orderedSet(re.findall(
r'href="/?(view_video\.php\?.*\bviewkey=([\da-z]+)[^"]*)"[^>]*\s+title="([^"]+)"',

Also, the question as to why orderedSet(), which is de-duplicated but not sorted, got its name arises ...

container))
]

Expand Down