aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-12-26 21:24:43 +0700
committerSergey M․ <dstftw@gmail.com>2020-12-26 21:24:43 +0700
commit4f1dc1463d49167482e1722b4c637eabc560e7aa (patch)
tree6fa984e4f84b7cb83e3c54dcbbf5069ab427c4b8
parent17e0f41d345b8cea7043b777bb68716219d3dc60 (diff)
downloadyoutube-dl-4f1dc1463d49167482e1722b4c637eabc560e7aa.tar.xz
[pornhub] Improve like and dislike count extraction (closes #27356)
-rw-r--r--youtube_dl/extractor/pornhub.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/youtube_dl/extractor/pornhub.py b/youtube_dl/extractor/pornhub.py
index 21ec48895..2fcbd186f 100644
--- a/youtube_dl/extractor/pornhub.py
+++ b/youtube_dl/extractor/pornhub.py
@@ -361,12 +361,16 @@ class PornHubIE(PornHubBaseIE):
r'(?s)From:&nbsp;.+?<(?:a\b[^>]+\bhref=["\']/(?:(?:user|channel)s|model|pornstar)/|span\b[^>]+\bclass=["\']username)[^>]+>(.+?)<',
webpage, 'uploader', default=None)
+ def extract_vote_count(kind, name):
+ return self._extract_count(
+ (r'<span[^>]+\bclass="votes%s"[^>]*>([\d,\.]+)</span>' % kind,
+ r'<span[^>]+\bclass=["\']votes%s["\'][^>]*\bdata-rating=["\'](\d+)' % kind),
+ webpage, name)
+
view_count = self._extract_count(
r'<span class="count">([\d,\.]+)</span> [Vv]iews', webpage, 'view')
- like_count = self._extract_count(
- r'<span[^>]+class="votesUp"[^>]*>([\d,\.]+)</span>', webpage, 'like')
- dislike_count = self._extract_count(
- r'<span[^>]+class="votesDown"[^>]*>([\d,\.]+)</span>', webpage, 'dislike')
+ like_count = extract_vote_count('Up', 'like')
+ dislike_count = extract_vote_count('Down', 'dislike')
comment_count = self._extract_count(
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')