mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-18 09:24:15 +09:00
Compare commits
5 Commits
db989e225b
...
33f7194f87
Author | SHA1 | Date | |
---|---|---|---|
![]() |
33f7194f87 | ||
![]() |
673277e510 | ||
![]() |
91b1569f68 | ||
![]() |
d3850e8c7f | ||
![]() |
b9b3231316 |
@ -939,6 +939,7 @@ from .picarto import (
|
|||||||
PicartoIE,
|
PicartoIE,
|
||||||
PicartoVodIE,
|
PicartoVodIE,
|
||||||
)
|
)
|
||||||
|
from .piczel import PiczelIE
|
||||||
from .piksel import PikselIE
|
from .piksel import PikselIE
|
||||||
from .pinkbike import PinkbikeIE
|
from .pinkbike import PinkbikeIE
|
||||||
from .pinterest import (
|
from .pinterest import (
|
||||||
|
95
youtube_dl/extractor/piczel.py
Normal file
95
youtube_dl/extractor/piczel.py
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
|
||||||
|
# coding: utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from .common import InfoExtractor
|
||||||
|
from ..compat import (
|
||||||
|
compat_HTTPError,
|
||||||
|
compat_urllib_request
|
||||||
|
)
|
||||||
|
from ..utils import (
|
||||||
|
ExtractorError
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PiczelIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'https?://(?:www.)?piczel\.tv/watch/(?P<id>[a-zA-Z0-9]+)'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://piczel.tv/watch/Schwoo',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'Schwoo',
|
||||||
|
'uploader_id': '43564',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Schwoo - Piczel.tv',
|
||||||
|
'description': 'Horni Vibin\'',
|
||||||
|
'is_live': bool,
|
||||||
|
},
|
||||||
|
'skip': 'Stream is offline',
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://piczel.tv/watch/GeneralButchTv',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'GeneralButchTv',
|
||||||
|
'uploader_id': '39042',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'GeneralButchTv - Piczel.tv',
|
||||||
|
'description': 'GENERAL BUTCH',
|
||||||
|
'is_live': bool,
|
||||||
|
},
|
||||||
|
'skip': 'Stream is offline',
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://piczel.tv/watch/Nifffi',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'Nifffi',
|
||||||
|
'uploader_id': '60996',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Nifffi - Piczel.tv',
|
||||||
|
'description': u'(ノ´ヮ`)ノ*: ・゚',
|
||||||
|
'is_live': bool,
|
||||||
|
},
|
||||||
|
'skip': 'Stream is offline',
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
title = self._html_search_regex(r'<title data-react-helmet=\"true\">(.+?)<\/title>', webpage, 'title')
|
||||||
|
|
||||||
|
api_data = self._download_json('https://piczel.tv/api/streams/%s' % video_id, video_id)
|
||||||
|
uploader_id = api_data['data'][0]['id']
|
||||||
|
is_live = api_data['data'][0]['live']
|
||||||
|
|
||||||
|
if not is_live:
|
||||||
|
# There is a bug where the api says user is not streaming when they are.
|
||||||
|
# So checing user's index.m3u8 file for 404 errors
|
||||||
|
try:
|
||||||
|
req = compat_urllib_request.urlopen('https://piczel.tv/hls/%i/index.m3u8' % uploader_id)
|
||||||
|
print(req.code)
|
||||||
|
except:
|
||||||
|
raise ExtractorError('Stream is offline', expected=True)
|
||||||
|
|
||||||
|
|
||||||
|
formats = []
|
||||||
|
formats.append({
|
||||||
|
'url': 'https://piczel.tv/hls/%i/index.m3u8' % uploader_id,
|
||||||
|
'ext': 'mp4',
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'uploader_id': str(uploader_id),
|
||||||
|
'title': title,
|
||||||
|
'description': self._og_search_description(webpage),
|
||||||
|
'is_live': is_live,
|
||||||
|
'formats': formats,
|
||||||
|
}
|
@ -27,6 +27,7 @@ from ..compat import (
|
|||||||
)
|
)
|
||||||
from ..jsinterp import JSInterpreter
|
from ..jsinterp import JSInterpreter
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
bug_reports_message,
|
||||||
clean_html,
|
clean_html,
|
||||||
dict_get,
|
dict_get,
|
||||||
error_to_compat_str,
|
error_to_compat_str,
|
||||||
@ -65,6 +66,7 @@ from ..utils import (
|
|||||||
url_or_none,
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
urljoin,
|
urljoin,
|
||||||
|
variadic,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -460,6 +462,26 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_thumbnails(data, *path_list, **kw_final_key):
|
||||||
|
"""
|
||||||
|
Extract thumbnails from thumbnails dict
|
||||||
|
@param path_list: path list to level that contains 'thumbnails' key
|
||||||
|
"""
|
||||||
|
final_key = kw_final_key.get('final_key', 'thumbnails')
|
||||||
|
|
||||||
|
return traverse_obj(data, ((
|
||||||
|
tuple(variadic(path) + (final_key, Ellipsis)
|
||||||
|
for path in path_list or [()])), {
|
||||||
|
'url': ('url', T(url_or_none),
|
||||||
|
# Sometimes youtube gives a wrong thumbnail URL. See:
|
||||||
|
# https://github.com/yt-dlp/yt-dlp/issues/233
|
||||||
|
# https://github.com/ytdl-org/youtube-dl/issues/28023
|
||||||
|
T(lambda u: update_url(u, query=None) if u and 'maxresdefault' in u else u)),
|
||||||
|
'height': ('height', T(int_or_none)),
|
||||||
|
'width': ('width', T(int_or_none)),
|
||||||
|
}, T(lambda t: t if t.get('url') else None)))
|
||||||
|
|
||||||
def _search_results(self, query, params):
|
def _search_results(self, query, params):
|
||||||
data = {
|
data = {
|
||||||
'context': {
|
'context': {
|
||||||
@ -3183,8 +3205,12 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
expected_type=txt_or_none)
|
expected_type=txt_or_none)
|
||||||
|
|
||||||
def _grid_entries(self, grid_renderer):
|
def _grid_entries(self, grid_renderer):
|
||||||
for item in grid_renderer['items']:
|
for item in traverse_obj(grid_renderer, ('items', Ellipsis, T(dict))):
|
||||||
if not isinstance(item, dict):
|
lockup_view_model = traverse_obj(item, ('lockupViewModel', T(dict)))
|
||||||
|
if lockup_view_model:
|
||||||
|
entry = self._extract_lockup_view_model(lockup_view_model)
|
||||||
|
if entry:
|
||||||
|
yield entry
|
||||||
continue
|
continue
|
||||||
renderer = self._extract_grid_item_renderer(item)
|
renderer = self._extract_grid_item_renderer(item)
|
||||||
if not isinstance(renderer, dict):
|
if not isinstance(renderer, dict):
|
||||||
@ -3268,6 +3294,25 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
continue
|
continue
|
||||||
yield self._extract_video(renderer)
|
yield self._extract_video(renderer)
|
||||||
|
|
||||||
|
def _extract_lockup_view_model(self, view_model):
|
||||||
|
content_id = view_model.get('contentId')
|
||||||
|
if not content_id:
|
||||||
|
return
|
||||||
|
content_type = view_model.get('contentType')
|
||||||
|
if content_type not in ('LOCKUP_CONTENT_TYPE_PLAYLIST', 'LOCKUP_CONTENT_TYPE_PODCAST'):
|
||||||
|
self.report_warning(
|
||||||
|
'Unsupported lockup view model content type "{0}"{1}'.format(content_type, bug_reports_message()), only_once=True)
|
||||||
|
return
|
||||||
|
return merge_dicts(self.url_result(
|
||||||
|
update_url_query('https://www.youtube.com/playlist', {'list': content_id}),
|
||||||
|
ie=YoutubeTabIE.ie_key(), video_id=content_id), {
|
||||||
|
'title': traverse_obj(view_model, (
|
||||||
|
'metadata', 'lockupMetadataViewModel', 'title', 'content', T(compat_str))),
|
||||||
|
'thumbnails': self._extract_thumbnails(view_model, (
|
||||||
|
'contentImage', 'collectionThumbnailViewModel', 'primaryThumbnail',
|
||||||
|
'thumbnailViewModel', 'image'), final_key='sources'),
|
||||||
|
})
|
||||||
|
|
||||||
def _video_entry(self, video_renderer):
|
def _video_entry(self, video_renderer):
|
||||||
video_id = video_renderer.get('videoId')
|
video_id = video_renderer.get('videoId')
|
||||||
if video_id:
|
if video_id:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user