2018-04-29 23:19:14 +05:30
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-04-30 22:30:34 +05:30
|
|
|
from ..compat import compat_urlparse
|
2018-05-01 01:15:39 +05:30
|
|
|
from ..utils import urljoin
|
2018-04-29 23:19:14 +05:30
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class PeertubeIE(InfoExtractor):
|
|
|
|
IE_DESC = 'Peertube Videos'
|
|
|
|
IE_NAME = 'Peertube'
|
|
|
|
_VALID_URL = r'https?:\/\/peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9|\-|a-z]+)'
|
|
|
|
_TEST = {
|
|
|
|
'url': 'https://peertube.touhoppai.moe/videos/watch/7f3421ae-6161-4a4a-ae38-d167aec51683',
|
2018-04-30 22:30:34 +05:30
|
|
|
'md5': '051ef9823d237416d5a6fc0bd8d67812',
|
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-01 01:15:39 +05:30
|
|
|
base_url = "%s://%s" % (url_data.scheme, url_data.hostname)
|
|
|
|
api_url = urljoin(urljoin(base_url, "/api/v1/videos/"), video_id)
|
2018-04-30 22:30:34 +05:30
|
|
|
details = self._download_json(api_url, video_id)
|
2018-04-29 23:19:14 +05:30
|
|
|
return {
|
|
|
|
'id': video_id,
|
2018-05-01 01:15:39 +05:30
|
|
|
'title': details.get('name'),
|
|
|
|
'description': details.get('description'),
|
2018-04-30 22:30:34 +05:30
|
|
|
'url': details['files'][-1]['fileUrl'],
|
2018-05-01 01:15:39 +05:30
|
|
|
'thumbnail': urljoin(base_url, details['thumbnailPath'])
|
2018-04-29 23:19:14 +05:30
|
|
|
}
|