Skip to content

Commit

Permalink
[pornhub] Detect geo restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Jun 20, 2021
1 parent da32828 commit 751c9ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ class PornHubIE(PornHubBaseIE):
}, {
'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5f75b0f4b18e3',
'only_matching': True,
}, {
# geo restricted
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5a9813bfa7156',
'only_matching': True,
}]

@staticmethod
Expand Down Expand Up @@ -275,6 +279,11 @@ def dl_webpage(platform):
'PornHub said: %s' % error_msg,
expected=True, video_id=video_id)

if any(re.search(p, webpage) for p in (
r'class=["\']geoBlocked["\']',
r'>\s*This content is unavailable in your country')):
self.raise_geo_restricted()

# video_title from flashvars contains whitespace instead of non-ASCII (see
# http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying
# on that anymore.
Expand Down

0 comments on commit 751c9ae

Please sign in to comment.