Skip to content

Commit

Permalink
[pornhub] Improve like and dislike count extraction (closes #27356)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Dec 26, 2020
1 parent 17e0f41 commit 4f1dc14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,16 @@ def parse_quality_items(quality_items):
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')

Expand Down

0 comments on commit 4f1dc14

Please sign in to comment.