mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-07-12 21:36:19 +00:00
Merge 48a248dfcbcb32c59e0e9ccc75a3d17144e9dd80 into c5098961b04ce83f4615f2a846c84f803b072639
This commit is contained in:
commit
8293db17f5
@ -1,20 +1,19 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
from socket import timeout
|
from socket import timeout
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DTubeIE(InfoExtractor):
|
class DTubeIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?d\.tube/(?:#!/)?v/(?P<uploader_id>[0-9a-z.-]+)/(?P<id>[0-9a-z]{8})'
|
_VALID_URL = r'https?://(?:www\.)?d\.tube/(?:#!/)?v/(?P<uploader_id>[0-9a-z.-]+)/(?P<id>[0-9a-zA-Z-_]{8,46})'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
|
# old test: fail
|
||||||
'url': 'https://d.tube/#!/v/broncnutz/x380jtr1',
|
'url': 'https://d.tube/#!/v/broncnutz/x380jtr1',
|
||||||
'md5': '9f29088fa08d699a7565ee983f56a06e',
|
'md5': '9f29088fa08d699a7565ee983f56a06e',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -29,21 +28,56 @@ class DTubeIE(InfoExtractor):
|
|||||||
'params': {
|
'params': {
|
||||||
'format': '480p',
|
'format': '480p',
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
# ipfs
|
||||||
|
'url': 'https://d.tube/v/anonyhack/QmXxj4j1prF5MUbFme4QVuGApeUw1MLq69Wf4GPBz2j2qL',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'QmXxj4j1prF5MUbFme4QVuGApeUw1MLq69Wf4GPBz2j2qL',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'i wont accept it',
|
||||||
|
'uploader_id': 'anonyhack',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'format': '480p',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
# facebook
|
||||||
|
'url': 'https://d.tube/v/whatstrending360/538648240276191',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '538648240276191',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Funny Videos 2019',
|
||||||
|
'timestamp': 1569481574,
|
||||||
|
'upload_date': '20190926',
|
||||||
|
'uploader': 'Funny Videos 2019',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
# youtube
|
||||||
|
'url': 'https://d.tube/#!/v/jeronimorubio/XCrCtqMeywk',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'XCrCtqMeywk',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Is it Beginning to Look a lot Like Christmas in Your City?',
|
||||||
|
'upload_date': '20191024',
|
||||||
|
'description': 'md5:9323433bbe8b34a55d84761e5bf652af',
|
||||||
|
'uploader': 'Jeronimo Rubio',
|
||||||
|
'uploader_id': 'UCbbG-SIMdWSW02RYKJucddw',
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
uploader_id, video_id = re.match(self._VALID_URL, url).groups()
|
uploader_id, video_id = re.match(self._VALID_URL, url).groups()
|
||||||
result = self._download_json('https://api.steemit.com/', video_id, data=json.dumps({
|
|
||||||
'jsonrpc': '2.0',
|
|
||||||
'method': 'get_content',
|
|
||||||
'params': [uploader_id, video_id],
|
|
||||||
}).encode())['result']
|
|
||||||
|
|
||||||
metadata = json.loads(result['json_metadata'])
|
result = self._download_json(
|
||||||
video = metadata['video']
|
'https://avalon.d.tube/content/%s/%s' % (uploader_id, video_id),
|
||||||
content = video['content']
|
video_id)
|
||||||
info = video.get('info', {})
|
|
||||||
title = info.get('title') or result['title']
|
metadata = result.get('json')
|
||||||
|
title = metadata.get('title') or result['title']
|
||||||
|
|
||||||
|
if metadata.get('providerName') != 'IPFS':
|
||||||
|
video_url = metadata.get('url')
|
||||||
|
return self.url_result(video_url)
|
||||||
|
|
||||||
def canonical_url(h):
|
def canonical_url(h):
|
||||||
if not h:
|
if not h:
|
||||||
@ -52,7 +86,8 @@ class DTubeIE(InfoExtractor):
|
|||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for q in ('240', '480', '720', '1080', ''):
|
for q in ('240', '480', '720', '1080', ''):
|
||||||
video_url = canonical_url(content.get('video%shash' % q))
|
video_url = canonical_url(
|
||||||
|
metadata.get('ipfs').get('video%shash' % q))
|
||||||
if not video_url:
|
if not video_url:
|
||||||
continue
|
continue
|
||||||
format_id = (q + 'p') if q else 'Source'
|
format_id = (q + 'p') if q else 'Source'
|
||||||
@ -73,11 +108,10 @@ class DTubeIE(InfoExtractor):
|
|||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': content.get('description'),
|
'description': metadata.get('description'),
|
||||||
'thumbnail': canonical_url(info.get('snaphash')),
|
'thumbnail': metadata.get('thumbnailUrl'),
|
||||||
'tags': content.get('tags') or metadata.get('tags'),
|
'tags': result.get('tags'),
|
||||||
'duration': info.get('duration'),
|
'duration': metadata.get('duration'),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'timestamp': parse_iso8601(result.get('created')),
|
|
||||||
'uploader_id': uploader_id,
|
'uploader_id': uploader_id,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user