mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 18:36:22 +00:00
[piczel] Add new extractor
This commit is contained in:
parent
a803582717
commit
b9b3231316
2 changed files with 96 additions and 0 deletions
|
@ -907,6 +907,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,
|
||||||
|
}
|
Loading…
Reference in a new issue