mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-06-01 19:08:14 +02:00
Compare commits
4 Commits
3b87f4d943
...
c61473c1d6
Author | SHA1 | Date | |
---|---|---|---|
|
c61473c1d6 | ||
|
8fddc232bf | ||
|
fad689c7b6 | ||
|
db6fa6960c |
|
@ -255,6 +255,7 @@
|
|||
CamdemyFolderIE
|
||||
)
|
||||
from .cammodels import CamModelsIE
|
||||
from .camsoda import CamsodaIE
|
||||
from .camtasia import CamtasiaEmbedIE
|
||||
from .camwithher import CamWithHerIE
|
||||
from .canalalpha import CanalAlphaIE
|
||||
|
@ -699,6 +700,7 @@
|
|||
HotStarIE,
|
||||
HotStarPrefixIE,
|
||||
HotStarPlaylistIE,
|
||||
HotStarSeasonIE,
|
||||
HotStarSeriesIE,
|
||||
)
|
||||
from .howcast import HowcastIE
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
import itertools
|
||||
import functools
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
HEADRequest,
|
||||
OnDemandPagedList,
|
||||
clean_html,
|
||||
get_element_by_class,
|
||||
get_elements_html_by_class,
|
||||
int_or_none,
|
||||
orderedSet,
|
||||
parse_count,
|
||||
parse_duration,
|
||||
traverse_obj,
|
||||
unified_strdate,
|
||||
urlencode_postdata,
|
||||
|
@ -109,51 +113,103 @@ def _real_extract(self, url):
|
|||
|
||||
|
||||
class BitChuteChannelIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?bitchute\.com/channel/(?P<id>[^/?#&]+)'
|
||||
_TEST = {
|
||||
'url': 'https://www.bitchute.com/channel/victoriaxrave/',
|
||||
'playlist_mincount': 185,
|
||||
_VALID_URL = r'https?://(?:www\.)?bitchute\.com/(?P<type>channel|playlist)/(?P<id>[^/?#&]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.bitchute.com/channel/bitchute/',
|
||||
'info_dict': {
|
||||
'id': 'victoriaxrave',
|
||||
'id': 'bitchute',
|
||||
'title': 'BitChute',
|
||||
'description': 'md5:5329fb3866125afa9446835594a9b138',
|
||||
},
|
||||
}
|
||||
'playlist': [
|
||||
{
|
||||
'md5': '7e427d7ed7af5a75b5855705ec750e2b',
|
||||
'info_dict': {
|
||||
'id': 'UGlrF9o9b-Q',
|
||||
'ext': 'mp4',
|
||||
'filesize': None,
|
||||
'title': 'This is the first video on #BitChute !',
|
||||
'description': 'md5:a0337e7b1fe39e32336974af8173a034',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
'uploader': 'BitChute',
|
||||
'upload_date': '20170103',
|
||||
'duration': 16,
|
||||
'view_count': int,
|
||||
},
|
||||
}
|
||||
],
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
'playlist_items': '-1',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.bitchute.com/playlist/wV9Imujxasw9/',
|
||||
'playlist_mincount': 20,
|
||||
'info_dict': {
|
||||
'id': 'wV9Imujxasw9',
|
||||
'title': 'Bruce MacDonald and "The Light of Darkness"',
|
||||
'description': 'md5:04913227d2714af1d36d804aa2ab6b1e',
|
||||
}
|
||||
}]
|
||||
|
||||
_TOKEN = 'zyG6tQcGPE5swyAEFLqKUwMuMMuF6IO2DZ6ZDQjGfsL0e4dcTLwqkTTul05Jdve7'
|
||||
PAGE_SIZE = 25
|
||||
HTML_CLASS_NAMES = {
|
||||
'channel': {
|
||||
'container': 'channel-videos-container',
|
||||
'title': 'channel-videos-title',
|
||||
'description': 'channel-videos-text',
|
||||
},
|
||||
'playlist': {
|
||||
'container': 'playlist-video',
|
||||
'title': 'title',
|
||||
'description': 'description',
|
||||
}
|
||||
|
||||
def _entries(self, channel_id):
|
||||
channel_url = 'https://www.bitchute.com/channel/%s/' % channel_id
|
||||
offset = 0
|
||||
for page_num in itertools.count(1):
|
||||
data = self._download_json(
|
||||
'%sextend/' % channel_url, channel_id,
|
||||
'Downloading channel page %d' % page_num,
|
||||
data=urlencode_postdata({
|
||||
'csrfmiddlewaretoken': self._TOKEN,
|
||||
'name': '',
|
||||
'offset': offset,
|
||||
}), headers={
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Referer': channel_url,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Cookie': 'csrftoken=%s' % self._TOKEN,
|
||||
})
|
||||
if data.get('success') is False:
|
||||
break
|
||||
html = data.get('html')
|
||||
if not html:
|
||||
break
|
||||
video_ids = re.findall(
|
||||
r'class=["\']channel-videos-image-container[^>]+>\s*<a\b[^>]+\bhref=["\']/video/([^"\'/]+)',
|
||||
html)
|
||||
if not video_ids:
|
||||
break
|
||||
offset += len(video_ids)
|
||||
for video_id in video_ids:
|
||||
yield self.url_result(
|
||||
'https://www.bitchute.com/video/%s' % video_id,
|
||||
ie=BitChuteIE.ie_key(), video_id=video_id)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _make_url(playlist_id, playlist_type):
|
||||
return f'https://www.bitchute.com/{playlist_type}/{playlist_id}/'
|
||||
|
||||
def _fetch_page(self, playlist_id, playlist_type, page_num):
|
||||
playlist_url = self._make_url(playlist_id, playlist_type)
|
||||
data = self._download_json(
|
||||
f'{playlist_url}extend/', playlist_id, f'Downloading page {page_num}',
|
||||
data=urlencode_postdata({
|
||||
'csrfmiddlewaretoken': self._TOKEN,
|
||||
'name': '',
|
||||
'offset': page_num * self.PAGE_SIZE,
|
||||
}), headers={
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Referer': playlist_url,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Cookie': f'csrftoken={self._TOKEN}',
|
||||
})
|
||||
if not data.get('success'):
|
||||
return
|
||||
classes = self.HTML_CLASS_NAMES[playlist_type]
|
||||
for video_html in get_elements_html_by_class(classes['container'], data.get('html')):
|
||||
video_id = self._search_regex(
|
||||
r'<a\s[^>]*\bhref=["\']/video/([^"\'/]+)', video_html, 'video id', default=None)
|
||||
if not video_id:
|
||||
continue
|
||||
yield self.url_result(
|
||||
f'https://www.bitchute.com/video/{video_id}', BitChuteIE, video_id, url_transparent=True,
|
||||
title=clean_html(get_element_by_class(classes['title'], video_html)),
|
||||
description=clean_html(get_element_by_class(classes['description'], video_html)),
|
||||
duration=parse_duration(get_element_by_class('video-duration', video_html)),
|
||||
view_count=parse_count(clean_html(get_element_by_class('video-views', video_html))))
|
||||
|
||||
def _real_extract(self, url):
|
||||
channel_id = self._match_id(url)
|
||||
playlist_type, playlist_id = self._match_valid_url(url).group('type', 'id')
|
||||
webpage = self._download_webpage(self._make_url(playlist_id, playlist_type), playlist_id)
|
||||
|
||||
page_func = functools.partial(self._fetch_page, playlist_id, playlist_type)
|
||||
return self.playlist_result(
|
||||
self._entries(channel_id), playlist_id=channel_id)
|
||||
OnDemandPagedList(page_func, self.PAGE_SIZE), playlist_id,
|
||||
title=self._html_extract_title(webpage, default=None),
|
||||
description=self._html_search_meta(
|
||||
('description', 'og:description', 'twitter:description'), webpage, default=None),
|
||||
playlist_count=int_or_none(self._html_search_regex(
|
||||
r'<span>(\d+)\s+videos?</span>', webpage, 'playlist count', default=None)))
|
||||
|
|
59
yt_dlp/extractor/camsoda.py
Normal file
59
yt_dlp/extractor/camsoda.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
import random
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import ExtractorError, traverse_obj
|
||||
|
||||
|
||||
class CamsodaIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://www\.camsoda\.com/(?P<id>[\w-]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.camsoda.com/lizzhopf',
|
||||
'info_dict': {
|
||||
'id': 'lizzhopf',
|
||||
'ext': 'mp4',
|
||||
'title': 'lizzhopf (lizzhopf) Nude on Cam. Free Live Sex Chat Room - CamSoda',
|
||||
'description': str,
|
||||
'is_live': True,
|
||||
'age_limit': 18,
|
||||
},
|
||||
'skip': 'Room is offline',
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_id, headers=self.geo_verification_headers())
|
||||
|
||||
data = self._download_json(
|
||||
f'https://camsoda.com/api/v1/video/vtoken/{video_id}', video_id,
|
||||
query={'username': f'guest_{random.randrange(10000, 99999)}'},
|
||||
headers=self.geo_verification_headers())
|
||||
if not data:
|
||||
raise ExtractorError('Unable to find configuration for stream.')
|
||||
elif data.get('private_servers'):
|
||||
raise ExtractorError('Model is in private show.', expected=True)
|
||||
elif not data.get('stream_name'):
|
||||
raise ExtractorError('Model is offline.', expected=True)
|
||||
|
||||
stream_name = traverse_obj(data, 'stream_name', expected_type=str)
|
||||
token = traverse_obj(data, 'token', expected_type=str)
|
||||
|
||||
formats = []
|
||||
for server in traverse_obj(data, ('edge_servers', ...)):
|
||||
formats = self._extract_m3u8_formats(
|
||||
f'https://{server}/{stream_name}_v1/index.m3u8?token={token}',
|
||||
video_id, ext='mp4', m3u8_id='hls', fatal=False, live=True)
|
||||
if formats:
|
||||
break
|
||||
if not formats:
|
||||
self.raise_no_formats('No active streams found', expected=True)
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': self._html_extract_title(webpage),
|
||||
'description': self._html_search_meta('description', webpage, default=None),
|
||||
'is_live': True,
|
||||
'formats': formats,
|
||||
'age_limit': 18,
|
||||
}
|
|
@ -1,22 +1,19 @@
|
|||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
import json
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import (
|
||||
compat_HTTPError,
|
||||
compat_str
|
||||
)
|
||||
from ..compat import compat_HTTPError, compat_str
|
||||
from ..utils import (
|
||||
determine_ext,
|
||||
ExtractorError,
|
||||
determine_ext,
|
||||
int_or_none,
|
||||
join_nonempty,
|
||||
str_or_none,
|
||||
try_get,
|
||||
traverse_obj,
|
||||
url_or_none,
|
||||
)
|
||||
|
||||
|
@ -26,6 +23,11 @@ class HotStarBaseIE(InfoExtractor):
|
|||
_API_URL = 'https://api.hotstar.com'
|
||||
_AKAMAI_ENCRYPTION_KEY = b'\x05\xfc\x1a\x01\xca\xc9\x4b\xc4\x12\xfc\x53\x12\x07\x75\xf9\xee'
|
||||
|
||||
def _call_api_v1(self, path, *args, **kwargs):
|
||||
return self._download_json(
|
||||
f'{self._API_URL}/o/v1/{path}', *args, **kwargs,
|
||||
headers={'x-country-code': 'IN', 'x-platform-code': 'PCTV'})
|
||||
|
||||
def _call_api_impl(self, path, video_id, query, st=None, cookies=None):
|
||||
st = int_or_none(st) or int(time.time())
|
||||
exp = st + 6000
|
||||
|
@ -59,17 +61,6 @@ def _call_api_impl(self, path, video_id, query, st=None, cookies=None):
|
|||
response['message'], expected=True)
|
||||
return response['data']
|
||||
|
||||
def _call_api(self, path, video_id, query_name='contentId'):
|
||||
return self._download_json(
|
||||
f'{self._API_URL}/{path}', video_id=video_id,
|
||||
query={
|
||||
query_name: video_id,
|
||||
'tas': 10000,
|
||||
}, headers={
|
||||
'x-country-code': 'IN',
|
||||
'x-platform-code': 'PCTV',
|
||||
})
|
||||
|
||||
def _call_api_v2(self, path, video_id, st=None, cookies=None):
|
||||
return self._call_api_impl(
|
||||
f'{path}/content/{video_id}', video_id, st=st, cookies=cookies, query={
|
||||
|
@ -79,6 +70,13 @@ def _call_api_v2(self, path, video_id, st=None, cookies=None):
|
|||
'os-version': '10',
|
||||
})
|
||||
|
||||
def _playlist_entries(self, path, item_id, root=None, **kwargs):
|
||||
results = self._call_api_v1(path, item_id, **kwargs)['body']['results']
|
||||
for video in traverse_obj(results, (('assets', None), 'items', ...)):
|
||||
if video.get('contentId'):
|
||||
yield self.url_result(
|
||||
HotStarIE._video_url(video['contentId'], root=root), HotStarIE, video['contentId'])
|
||||
|
||||
|
||||
class HotStarIE(HotStarBaseIE):
|
||||
IE_NAME = 'hotstar'
|
||||
|
@ -104,6 +102,7 @@ class HotStarIE(HotStarBaseIE):
|
|||
'duration': 381,
|
||||
'episode': 'Can You Not Spread Rumours?',
|
||||
},
|
||||
'params': {'skip_download': 'm3u8'},
|
||||
}, {
|
||||
'url': 'https://www.hotstar.com/tv/ek-bhram-sarvagun-sampanna/s-2116/janhvi-targets-suman/1000234847',
|
||||
'info_dict': {
|
||||
|
@ -161,7 +160,8 @@ def _real_extract(self, url):
|
|||
video_type = self._TYPE.get(video_type, video_type)
|
||||
cookies = self._get_cookies(url) # Cookies before any request
|
||||
|
||||
video_data = self._call_api(f'o/v1/{video_type}/detail', video_id)['body']['results']['item']
|
||||
video_data = self._call_api_v1(f'{video_type}/detail', video_id,
|
||||
query={'tas': 10000, 'contentId': video_id})['body']['results']['item']
|
||||
if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
|
||||
self.report_drm(video_id)
|
||||
|
||||
|
@ -258,16 +258,16 @@ class HotStarPrefixIE(InfoExtractor):
|
|||
'url': 'hotstar:1000076273',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'hotstar:movies:1000057157',
|
||||
'url': 'hotstar:movies:1260009879',
|
||||
'info_dict': {
|
||||
'id': '1000057157',
|
||||
'id': '1260009879',
|
||||
'ext': 'mp4',
|
||||
'title': 'Radha Gopalam',
|
||||
'description': 'md5:be3bc342cc120bbc95b3b0960e2b0d22',
|
||||
'timestamp': 1140805800,
|
||||
'upload_date': '20060224',
|
||||
'duration': 9182,
|
||||
'episode': 'Radha Gopalam',
|
||||
'title': 'Nuvvu Naaku Nachav',
|
||||
'description': 'md5:d43701b1314e6f8233ce33523c043b7d',
|
||||
'timestamp': 1567525674,
|
||||
'upload_date': '20190903',
|
||||
'duration': 10787,
|
||||
'episode': 'Nuvvu Naaku Nachav',
|
||||
},
|
||||
}, {
|
||||
'url': 'hotstar:episode:1000234847',
|
||||
|
@ -289,7 +289,7 @@ def _real_extract(self, url):
|
|||
|
||||
class HotStarPlaylistIE(HotStarBaseIE):
|
||||
IE_NAME = 'hotstar:playlist'
|
||||
_VALID_URL = r'https?://(?:www\.)?hotstar\.com/tv/[^/]+/s-\w+/list/[^/]+/t-(?P<id>\w+)'
|
||||
_VALID_URL = r'https?://(?:www\.)?hotstar\.com(?:/in)?/tv(?:/[^/]+){2}/list/[^/]+/t-(?P<id>\w+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.hotstar.com/tv/savdhaan-india/s-26/list/popular-clips/t-3_2_26',
|
||||
'info_dict': {
|
||||
|
@ -299,22 +299,49 @@ class HotStarPlaylistIE(HotStarBaseIE):
|
|||
}, {
|
||||
'url': 'https://www.hotstar.com/tv/savdhaan-india/s-26/list/extras/t-2480',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'https://www.hotstar.com/in/tv/karthika-deepam/15457/list/popular-clips/t-3_2_1272',
|
||||
'only_matching': True,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
playlist_id = self._match_id(url)
|
||||
id_ = self._match_id(url)
|
||||
return self.playlist_result(
|
||||
self._playlist_entries('tray/find', id_, query={'tas': 10000, 'uqId': id_}), id_)
|
||||
|
||||
collection = self._call_api('o/v1/tray/find', playlist_id, 'uqId')['body']['results']
|
||||
entries = [
|
||||
self.url_result(HotStarIE._video_url(video['contentId']), HotStarIE, video['contentId'])
|
||||
for video in collection['assets']['items'] if video.get('contentId')]
|
||||
|
||||
return self.playlist_result(entries, playlist_id)
|
||||
class HotStarSeasonIE(HotStarBaseIE):
|
||||
IE_NAME = 'hotstar:season'
|
||||
_VALID_URL = r'(?P<url>https?://(?:www\.)?hotstar\.com(?:/in)?/tv/[^/]+/\w+)/seasons/[^/]+/ss-(?P<id>\w+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.hotstar.com/tv/radhakrishn/1260000646/seasons/season-2/ss-8028',
|
||||
'info_dict': {
|
||||
'id': '8028',
|
||||
},
|
||||
'playlist_mincount': 35,
|
||||
}, {
|
||||
'url': 'https://www.hotstar.com/in/tv/ishqbaaz/9567/seasons/season-2/ss-4357',
|
||||
'info_dict': {
|
||||
'id': '4357',
|
||||
},
|
||||
'playlist_mincount': 30,
|
||||
}, {
|
||||
'url': 'https://www.hotstar.com/in/tv/bigg-boss/14714/seasons/season-4/ss-8208/',
|
||||
'info_dict': {
|
||||
'id': '8208',
|
||||
},
|
||||
'playlist_mincount': 19,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
url, season_id = self._match_valid_url(url).groups()
|
||||
return self.playlist_result(self._playlist_entries(
|
||||
'season/asset', season_id, url, query={'tao': 0, 'tas': 0, 'size': 10000, 'id': season_id}), season_id)
|
||||
|
||||
|
||||
class HotStarSeriesIE(HotStarBaseIE):
|
||||
IE_NAME = 'hotstar:series'
|
||||
_VALID_URL = r'(?P<url>https?://(?:www\.)?hotstar\.com(?:/in)?/tv/[^/]+/(?P<id>\d+))'
|
||||
_VALID_URL = r'(?P<url>https?://(?:www\.)?hotstar\.com(?:/in)?/tv/[^/]+/(?P<id>\d+))/?(?:[#?]|$)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.hotstar.com/in/tv/radhakrishn/1260000646',
|
||||
'info_dict': {
|
||||
|
@ -332,22 +359,13 @@ class HotStarSeriesIE(HotStarBaseIE):
|
|||
'info_dict': {
|
||||
'id': '435',
|
||||
},
|
||||
'playlist_mincount': 269,
|
||||
'playlist_mincount': 267,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
url, series_id = self._match_valid_url(url).groups()
|
||||
headers = {
|
||||
'x-country-code': 'IN',
|
||||
'x-platform-code': 'PCTV',
|
||||
}
|
||||
detail_json = self._download_json(
|
||||
f'{self._API_URL}/o/v1/show/detail?contentId={series_id}', series_id, headers=headers)
|
||||
id = try_get(detail_json, lambda x: x['body']['results']['item']['id'], int)
|
||||
item_json = self._download_json(
|
||||
f'{self._API_URL}/o/v1/tray/g/1/items?etid=0&tao=0&tas=10000&eid={id}', series_id, headers=headers)
|
||||
id_ = self._call_api_v1(
|
||||
'show/detail', series_id, query={'contentId': series_id})['body']['results']['item']['id']
|
||||
|
||||
return self.playlist_result([
|
||||
self.url_result(HotStarIE._video_url(video['contentId'], root=url), HotStarIE, video['contentId'])
|
||||
for video in item_json['body']['results']['items'] if video.get('contentId')
|
||||
], series_id)
|
||||
return self.playlist_result(self._playlist_entries(
|
||||
'tray/g/1/items', series_id, url, query={'tao': 0, 'tas': 10000, 'etid': 0, 'eid': id_}), series_id)
|
||||
|
|
|
@ -418,6 +418,8 @@ def get_elements_text_and_html_by_attribute(attribute, value, html, *, tag=r'[\w
|
|||
Return the text (content) and the html (whole) of the tag with the specified
|
||||
attribute in the passed HTML document
|
||||
"""
|
||||
if not value:
|
||||
return
|
||||
|
||||
quote = '' if re.match(r'''[\s"'`=<>]''', value) else '?'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user