mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-25 08:41:48 +02:00
[streamable] Fix title extraction and improve (Closes #9122)
This commit is contained in:
parent
59cc5bd8bf
commit
1a8f0773b6
@ -783,6 +783,7 @@
|
|||||||
from .ssa import SSAIE
|
from .ssa import SSAIE
|
||||||
from .stanfordoc import StanfordOpenClassroomIE
|
from .stanfordoc import StanfordOpenClassroomIE
|
||||||
from .steam import SteamIE
|
from .steam import SteamIE
|
||||||
|
from .streamable import StreamableIE
|
||||||
from .streamcloud import StreamcloudIE
|
from .streamcloud import StreamcloudIE
|
||||||
from .streamcz import StreamCZIE
|
from .streamcz import StreamCZIE
|
||||||
from .streetvoice import StreetVoiceIE
|
from .streetvoice import StreetVoiceIE
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
float_or_none
|
float_or_none,
|
||||||
|
int_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StreamableIE(InfoExtractor):
|
class StreamableIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://streamable\.com/(?P<id>[\w]+)'
|
_VALID_URL = r'https?://streamable\.com/(?:e/)?(?P<id>\w+)'
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
'url': 'https://streamable.com/dnd1',
|
'url': 'https://streamable.com/dnd1',
|
||||||
@ -18,7 +19,12 @@ class StreamableIE(InfoExtractor):
|
|||||||
'id': 'dnd1',
|
'id': 'dnd1',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Mikel Oiarzabal scores to make it 0-3 for La Real against Espanyol',
|
'title': 'Mikel Oiarzabal scores to make it 0-3 for La Real against Espanyol',
|
||||||
'thumbnail': 'http://cdn.streamable.com/image/dnd1.jpg',
|
'thumbnail': 're:https?://.*\.jpg$',
|
||||||
|
'uploader': 'teabaker',
|
||||||
|
'timestamp': 1454964157.35115,
|
||||||
|
'upload_date': '20160208',
|
||||||
|
'duration': 61.516,
|
||||||
|
'view_count': int,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
# older video without bitrate, width/height, etc. info
|
# older video without bitrate, width/height, etc. info
|
||||||
@ -29,8 +35,16 @@ class StreamableIE(InfoExtractor):
|
|||||||
'id': 'moo',
|
'id': 'moo',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '"Please don\'t eat me!"',
|
'title': '"Please don\'t eat me!"',
|
||||||
'thumbnail': 'http://cdn.streamable.com/image/f6441ae0c84311e4af010bc47400a0a4.jpg',
|
'thumbnail': 're:https?://.*\.jpg$',
|
||||||
|
'timestamp': 1426115495,
|
||||||
|
'upload_date': '20150311',
|
||||||
|
'duration': 12,
|
||||||
|
'view_count': int,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url': 'https://streamable.com/e/dnd1',
|
||||||
|
'only_matching': True,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -54,23 +68,31 @@ def _real_extract(self, url):
|
|||||||
'This video is currently unavailable. It may still be uploading or processing.',
|
'This video is currently unavailable. It may still be uploading or processing.',
|
||||||
expected=True)
|
expected=True)
|
||||||
|
|
||||||
|
title = video.get('reddit_title') or video['title']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for key, info in video.get('files').items():
|
for key, info in video['files'].items():
|
||||||
|
if not info.get('url'):
|
||||||
|
continue
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': key,
|
'format_id': key,
|
||||||
'url': info['url'],
|
'url': self._proto_relative_url(info['url']),
|
||||||
'width': info.get('width'),
|
'width': int_or_none(info.get('width')),
|
||||||
'height': info.get('height'),
|
'height': int_or_none(info.get('height')),
|
||||||
'filesize': info.get('size'),
|
'filesize': int_or_none(info.get('size')),
|
||||||
'fps': info.get('framerate'),
|
'fps': int_or_none(info.get('framerate')),
|
||||||
'vbr': float_or_none(info.get('bitrate'), 1000)
|
'vbr': float_or_none(info.get('bitrate'), 1000)
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video.get('result_title'),
|
'title': title,
|
||||||
'thumbnail': video.get('thumbnail_url'),
|
'description': video.get('description'),
|
||||||
'duration': video.get('duration'),
|
'thumbnail': self._proto_relative_url(video.get('thumbnail_url')),
|
||||||
|
'uploader': video.get('owner', {}).get('user_name'),
|
||||||
|
'timestamp': float_or_none(video.get('date_added')),
|
||||||
|
'duration': float_or_none(video.get('duration')),
|
||||||
|
'view_count': int_or_none(video.get('plays')),
|
||||||
'formats': formats
|
'formats': formats
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user