mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 17:02:30 +00:00
[drtuber] Make dislike count optional (Closes #10297)
This commit is contained in:
parent
0c070681c5
commit
0aef0771f8
@ -3,7 +3,10 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import str_to_int
|
from ..utils import (
|
||||||
|
NO_DEFAULT,
|
||||||
|
str_to_int,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DrTuberIE(InfoExtractor):
|
class DrTuberIE(InfoExtractor):
|
||||||
@ -17,7 +20,6 @@ class DrTuberIE(InfoExtractor):
|
|||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'hot perky blonde naked golf',
|
'title': 'hot perky blonde naked golf',
|
||||||
'like_count': int,
|
'like_count': int,
|
||||||
'dislike_count': int,
|
|
||||||
'comment_count': int,
|
'comment_count': int,
|
||||||
'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
|
'categories': ['Babe', 'Blonde', 'Erotic', 'Outdoor', 'Softcore', 'Solo'],
|
||||||
'thumbnail': 're:https?://.*\.jpg$',
|
'thumbnail': 're:https?://.*\.jpg$',
|
||||||
@ -43,18 +45,20 @@ def _real_extract(self, url):
|
|||||||
r'poster="([^"]+)"',
|
r'poster="([^"]+)"',
|
||||||
webpage, 'thumbnail', fatal=False)
|
webpage, 'thumbnail', fatal=False)
|
||||||
|
|
||||||
def extract_count(id_, name):
|
def extract_count(id_, name, default=NO_DEFAULT):
|
||||||
return str_to_int(self._html_search_regex(
|
return str_to_int(self._html_search_regex(
|
||||||
r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
|
r'<span[^>]+(?:class|id)="%s"[^>]*>([\d,\.]+)</span>' % id_,
|
||||||
webpage, '%s count' % name, fatal=False))
|
webpage, '%s count' % name, default=default, fatal=False))
|
||||||
|
|
||||||
like_count = extract_count('rate_likes', 'like')
|
like_count = extract_count('rate_likes', 'like')
|
||||||
dislike_count = extract_count('rate_dislikes', 'dislike')
|
dislike_count = extract_count('rate_dislikes', 'dislike', default=None)
|
||||||
comment_count = extract_count('comments_count', 'comment')
|
comment_count = extract_count('comments_count', 'comment')
|
||||||
|
|
||||||
cats_str = self._search_regex(
|
cats_str = self._search_regex(
|
||||||
r'<div[^>]+class="categories_list">(.+?)</div>', webpage, 'categories', fatal=False)
|
r'<div[^>]+class="categories_list">(.+?)</div>',
|
||||||
categories = [] if not cats_str else re.findall(r'<a title="([^"]+)"', cats_str)
|
webpage, 'categories', fatal=False)
|
||||||
|
categories = [] if not cats_str else re.findall(
|
||||||
|
r'<a title="([^"]+)"', cats_str)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user