mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.3 KiB
Python
94 lines
3.3 KiB
Python
10 years ago
|
import re
|
||
|
|
||
|
from .common import InfoExtractor
|
||
10 years ago
|
from ..utils import (
|
||
|
int_or_none,
|
||
|
remove_end,
|
||
10 years ago
|
remove_start,
|
||
|
str_to_int,
|
||
|
unified_strdate,
|
||
10 years ago
|
)
|
||
10 years ago
|
|
||
|
|
||
|
class PinkbikeIE(InfoExtractor):
|
||
10 years ago
|
_VALID_URL = r'https?://(?:(?:www\.)?pinkbike\.com/video/|es\.pinkbike\.org/i/kvid/kvid-y5\.swf\?id=)(?P<id>[0-9]+)'
|
||
10 years ago
|
_TESTS = [{
|
||
|
'url': 'http://www.pinkbike.com/video/402811/',
|
||
|
'md5': '4814b8ca7651034cd87e3361d5c2155a',
|
||
|
'info_dict': {
|
||
|
'id': '402811',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Brandon Semenuk - RAW 100',
|
||
10 years ago
|
'description': 'Official release: www.redbull.ca/rupertwalker',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||
10 years ago
|
'duration': 100,
|
||
10 years ago
|
'upload_date': '20150406',
|
||
10 years ago
|
'uploader': 'revelco',
|
||
|
'location': 'Victoria, British Columbia, Canada',
|
||
|
'view_count': int,
|
||
|
'comment_count': int,
|
||
10 years ago
|
}
|
||
|
}, {
|
||
10 years ago
|
'url': 'http://es.pinkbike.org/i/kvid/kvid-y5.swf?id=406629',
|
||
|
'only_matching': True,
|
||
10 years ago
|
}]
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
video_id = self._match_id(url)
|
||
|
|
||
10 years ago
|
webpage = self._download_webpage(
|
||
|
'http://www.pinkbike.com/video/%s' % video_id, video_id)
|
||
10 years ago
|
|
||
10 years ago
|
formats = []
|
||
|
for _, format_id, src in re.findall(
|
||
10 years ago
|
r'data-quality=((?:\\)?["\'])(.+?)\1[^>]+src=\1(.+?)\1', webpage):
|
||
10 years ago
|
height = int_or_none(self._search_regex(
|
||
|
r'^(\d+)[pP]$', format_id, 'height', default=None))
|
||
|
formats.append({
|
||
|
'url': src,
|
||
|
'format_id': format_id,
|
||
|
'height': height,
|
||
|
})
|
||
10 years ago
|
|
||
10 years ago
|
title = remove_end(self._og_search_title(webpage), ' Video - Pinkbike')
|
||
|
description = self._html_search_regex(
|
||
|
r'(?s)id="media-description"[^>]*>(.+?)<',
|
||
|
webpage, 'description', default=None) or remove_start(
|
||
|
self._og_search_description(webpage), title + '. ')
|
||
|
thumbnail = self._og_search_thumbnail(webpage)
|
||
10 years ago
|
duration = int_or_none(self._html_search_meta(
|
||
|
'video:duration', webpage, 'duration'))
|
||
10 years ago
|
|
||
10 years ago
|
uploader = self._search_regex(
|
||
8 years ago
|
r'<a[^>]+\brel=["\']author[^>]+>([^<]+)', webpage,
|
||
|
'uploader', fatal=False)
|
||
10 years ago
|
upload_date = unified_strdate(self._search_regex(
|
||
|
r'class="fullTime"[^>]+title="([^"]+)"',
|
||
|
webpage, 'upload date', fatal=False))
|
||
10 years ago
|
|
||
|
location = self._html_search_regex(
|
||
10 years ago
|
r'(?s)<dt>Location</dt>\s*<dd>(.+?)<',
|
||
|
webpage, 'location', fatal=False)
|
||
10 years ago
|
|
||
10 years ago
|
def extract_count(webpage, label):
|
||
|
return str_to_int(self._search_regex(
|
||
|
r'<span[^>]+class="stat-num"[^>]*>([\d,.]+)</span>\s*<span[^>]+class="stat-label"[^>]*>%s' % label,
|
||
|
webpage, label, fatal=False))
|
||
10 years ago
|
|
||
10 years ago
|
view_count = extract_count(webpage, 'Views')
|
||
|
comment_count = extract_count(webpage, 'Comments')
|
||
10 years ago
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
|
'title': title,
|
||
|
'description': description,
|
||
10 years ago
|
'thumbnail': thumbnail,
|
||
10 years ago
|
'duration': duration,
|
||
10 years ago
|
'upload_date': upload_date,
|
||
10 years ago
|
'uploader': uploader,
|
||
10 years ago
|
'location': location,
|
||
10 years ago
|
'view_count': view_count,
|
||
|
'comment_count': comment_count,
|
||
10 years ago
|
'formats': formats
|
||
|
}
|