2018-04-29 23:19:14 +05:30
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-05-03 23:52:10 +05:30
|
|
|
from ..compat import compat_urlparse, compat_str
|
|
|
|
from ..utils import urljoin, int_or_none, try_get
|
2018-04-29 23:19:14 +05:30
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class PeertubeIE(InfoExtractor):
|
|
|
|
IE_DESC = 'Peertube Videos'
|
|
|
|
IE_NAME = 'Peertube'
|
2018-05-17 12:55:23 +05:30
|
|
|
_VALID_URL = r'(?:https?:)//peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})'
|
2018-04-29 23:19:14 +05:30
|
|
|
_TEST = {
|
|
|
|
'url': 'https://peertube.touhoppai.moe/videos/watch/7f3421ae-6161-4a4a-ae38-d167aec51683',
|
2018-05-01 01:23:11 +05:30
|
|
|
'md5': 'a5e1e4a978e6b789553198d1739f5643',
|
2018-04-29 23:19:14 +05:30
|
|
|
'info_dict': {
|
|
|
|
'id': '7f3421ae-6161-4a4a-ae38-d167aec51683',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'David Revoy Live Stream: Speedpainting',
|
2018-04-30 22:30:34 +05:30
|
|
|
'description': 'md5:4e67c2fec55739a2ccb86052505a741e',
|
|
|
|
'thumbnail': 'https://peertube.touhoppai.moe/static/thumbnails/7f3421ae-6161-4a4a-ae38-d167aec51683.jpg',
|
2018-04-29 23:19:14 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
2018-04-30 22:30:34 +05:30
|
|
|
url_data = compat_urlparse.urlparse(url)
|
2018-05-03 23:52:10 +05:30
|
|
|
base_url = "%s://%s" % (url_data.scheme or 'http', url_data.hostname)
|
2018-05-03 22:39:40 +05:30
|
|
|
api_url = urljoin(base_url, "/api/v1/videos/%s" % video_id)
|
2018-04-30 22:30:34 +05:30
|
|
|
details = self._download_json(api_url, video_id)
|
2018-05-03 23:24:42 +05:30
|
|
|
formats = [{'url': file_data['fileUrl'], 'filesize': int_or_none(file_data.get('size')), 'format': file_data.get('resolution', {}).get('label')} for file_data in details['files']]
|
2018-05-03 22:39:40 +05:30
|
|
|
self._sort_formats(formats)
|
2018-04-29 23:19:14 +05:30
|
|
|
return {
|
|
|
|
'id': video_id,
|
2018-05-03 22:39:40 +05:30
|
|
|
'title': details['name'],
|
2018-05-01 01:15:39 +05:30
|
|
|
'description': details.get('description'),
|
2018-05-03 22:39:40 +05:30
|
|
|
'formats': formats,
|
|
|
|
'thumbnail': urljoin(base_url, details['thumbnailPath']) if 'thumbnailPath' in details else None,
|
2018-05-03 23:52:10 +05:30
|
|
|
'uploader': try_get(details, lambda x: x['account']['displayName'], compat_str),
|
|
|
|
'uploader_id': try_get(details, lambda x: x['account']['id'], int),
|
|
|
|
'uploder_url': try_get(details, lambda x: x['account']['url'], compat_str),
|
2018-05-03 23:24:42 +05:30
|
|
|
'duration': int_or_none(details.get('duration')),
|
|
|
|
'view_count': int_or_none(details.get('views')),
|
|
|
|
'like_count': int_or_none(details.get('likes')),
|
|
|
|
'dislike_count': int_or_none(details.get('dislikes')),
|
2018-05-03 22:39:40 +05:30
|
|
|
'tags': details.get('tags')
|
2018-04-29 23:19:14 +05:30
|
|
|
}
|