[VidLii] Add HD support

Also fix a bug with the view count
This commit is contained in:
Paper 2022-05-07 16:49:45 -04:00 committed by GitHub
parent e988fa4523
commit 13b0b2d37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
float_or_none, float_or_none,
get_element_by_id, get_element_by_id,
@ -35,6 +36,25 @@ class VidLiiIE(InfoExtractor):
'categories': ['News & Politics'], 'categories': ['News & Politics'],
'tags': ['Vidlii', 'Jan', 'Videogames'], 'tags': ['Vidlii', 'Jan', 'Videogames'],
} }
}, { # HD
'url': 'https://www.vidlii.com/watch?v=2Ng8Abj2Fkl',
'md5': '450e7da379c884788c3a4fa02a3ce1a4',
'info_dict': {
'id': '2Ng8Abj2Fkl',
'ext': 'mp4',
'title': 'test',
'description': 'md5:cc55a86032a7b6b3cbfd0f6b155b52e9',
'thumbnail': 'https://www.vidlii.com/usfi/thmp/2Ng8Abj2Fkl.jpg',
'uploader': 'VidLii',
'uploader_url': 'https://www.vidlii.com/user/VidLii',
'upload_date': '20200927',
'duration': 5,
'view_count': int,
'comment_count': int,
'average_rating': float,
'categories': ['Film & Animation'],
'tags': ['1', '2'],
},
}, { }, {
'url': 'https://www.vidlii.com/embed?v=tJluaH4BJ3v&a=0', 'url': 'https://www.vidlii.com/embed?v=tJluaH4BJ3v&a=0',
'only_matching': True, 'only_matching': True,
@ -46,9 +66,31 @@ class VidLiiIE(InfoExtractor):
webpage = self._download_webpage( webpage = self._download_webpage(
'https://www.vidlii.com/watch?v=%s' % video_id, video_id) 'https://www.vidlii.com/watch?v=%s' % video_id, video_id)
video_url = self._search_regex( formats = []
r'src\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1', webpage,
'video url', group='url') def add_format(format_url, height=None):
height = int(self._search_regex(r"(\d+).mp4",
format_url, "height", default=360))
formats.append({
'url': format_url,
'format_id': '%dp' % height if height else None,
'height': height,
})
sources = re.findall(
r'src\s*:\s*(["\'])(?P<url>(?:https?://)?(?:(?!\1).)+)\1',
webpage)
try:
self._request_webpage(sources[1][1], video_id, 'Checking HD URL')
add_format(sources[1][1])
except Exception:
pass
add_format(sources[0][1])
self._sort_formats(formats)
title = self._search_regex( title = self._search_regex(
(r'<h1>([^<]+)</h1>', r'<title>([^<]+) - VidLii<'), webpage, (r'<h1>([^<]+)</h1>', r'<title>([^<]+) - VidLii<'), webpage,
@ -83,9 +125,9 @@ class VidLiiIE(InfoExtractor):
r'duration\s*:\s*(\d+)', webpage, 'duration', fatal=False)) r'duration\s*:\s*(\d+)', webpage, 'duration', fatal=False))
view_count = int_or_none(self._search_regex( view_count = int_or_none(self._search_regex(
(r'<strong>(\d+)</strong> views', (r'<strong>([\d,]+)</strong> views',
r'Views\s*:\s*<strong>(\d+)</strong>'), r'Views\s*:\s*<strong>([\d,]+)</strong>'),
webpage, 'view count', fatal=False)) webpage, 'view count', fatal=False).replace(",", ""))
comment_count = int_or_none(self._search_regex( comment_count = int_or_none(self._search_regex(
(r'<span[^>]+id=["\']cmt_num[^>]+>(\d+)', (r'<span[^>]+id=["\']cmt_num[^>]+>(\d+)',
@ -109,7 +151,7 @@ class VidLiiIE(InfoExtractor):
return { return {
'id': video_id, 'id': video_id,
'url': video_url, 'formats': formats,
'title': title, 'title': title,
'description': description, 'description': description,
'thumbnail': thumbnail, 'thumbnail': thumbnail,