From: Sergey M․ Date: Sat, 26 Dec 2020 14:24:43 +0000 (+0700) Subject: [pornhub] Improve like and dislike count extraction (closes #27356) X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=4f1dc1463d49167482e1722b4c637eabc560e7aa;p=youtube-dl [pornhub] Improve like and dislike count extraction (closes #27356) --- 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: .+?<(?: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']+\bclass="votes%s"[^>]*>([\d,\.]+)' % kind, + r']+\bclass=["\']votes%s["\'][^>]*\bdata-rating=["\'](\d+)' % kind), + webpage, name) + view_count = self._extract_count( r'([\d,\.]+) [Vv]iews', webpage, 'view') - like_count = self._extract_count( - r']+class="votesUp"[^>]*>([\d,\.]+)', webpage, 'like') - dislike_count = self._extract_count( - r']+class="votesDown"[^>]*>([\d,\.]+)', 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*\(([\d,.]+)\)', webpage, 'comment')