aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSergey M․ <[email protected]>2021-06-21 03:33:43 +0700
committerSergey M․ <[email protected]>2021-06-21 03:33:43 +0700
commit751c9ae39a0bb9c66eca888a12595624db00bf16 (patch)
tree4b33ade64f78b86941ee5740561820f590b74a50
parentda32828208743c8012c8eea01780cbf9b3f60436 (diff)
downloadyoutube-dl-751c9ae39a0bb9c66eca888a12595624db00bf16.tar.gz
youtube-dl-751c9ae39a0bb9c66eca888a12595624db00bf16.zip
[pornhub] Detect geo restriction
-rw-r--r--youtube_dl/extractor/pornhub.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/youtube_dl/extractor/pornhub.py b/youtube_dl/extractor/pornhub.py
index 10516ee5a..d74e69ed9 100644
--- a/youtube_dl/extractor/pornhub.py
+++ b/youtube_dl/extractor/pornhub.py
@@ -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
@@ -275,6 +279,11 @@ class PornHubIE(PornHubBaseIE):
'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.