mirror of https://github.com/yt-dlp/yt-dlp.git
Compare commits
9 Commits
cd2063e303
...
138800b66e
Author | SHA1 | Date |
---|---|---|
HobbyistDev | 138800b66e | |
sepro | 96da952504 | |
HobbyistDev | 4741aded6f | |
HobbyistDev | d493ce72b6 | |
HobbyistDev | f326e05e9f | |
HobbyistDev | 89cb7f7d98 | |
HobbyistDev | 08563a1cad | |
HobbyistDev | 6c311b14c6 | |
HobbyistDev | eb2969d324 |
|
@ -2136,6 +2136,11 @@ class YoutubeDL:
|
|||
|
||||
def _check_formats(self, formats):
|
||||
for f in formats:
|
||||
working = f.get('__working')
|
||||
if working is not None:
|
||||
if working:
|
||||
yield f
|
||||
continue
|
||||
self.to_screen('[info] Testing format %s' % f['format_id'])
|
||||
path = self.get_output_path('temp')
|
||||
if not self._ensure_dir_exists(f'{path}/'):
|
||||
|
@ -2152,33 +2157,44 @@ class YoutubeDL:
|
|||
os.remove(temp_file.name)
|
||||
except OSError:
|
||||
self.report_warning('Unable to delete temporary file "%s"' % temp_file.name)
|
||||
f['__working'] = success
|
||||
if success:
|
||||
yield f
|
||||
else:
|
||||
self.to_screen('[info] Unable to download format %s. Skipping...' % f['format_id'])
|
||||
|
||||
def _select_formats(self, formats, selector):
|
||||
return list(selector({
|
||||
'formats': formats,
|
||||
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
|
||||
'incomplete_formats': (all(f.get('vcodec') == 'none' for f in formats) # No formats with video
|
||||
or all(f.get('acodec') == 'none' for f in formats)), # OR, No formats with audio
|
||||
}))
|
||||
|
||||
def _default_format_spec(self, info_dict, download=True):
|
||||
download = download and not self.params.get('simulate')
|
||||
prefer_best = download and (
|
||||
self.params['outtmpl']['default'] == '-'
|
||||
or info_dict.get('is_live') and not self.params.get('live_from_start'))
|
||||
|
||||
def can_merge():
|
||||
merger = FFmpegMergerPP(self)
|
||||
return merger.available and merger.can_merge()
|
||||
|
||||
prefer_best = (
|
||||
not self.params.get('simulate')
|
||||
and download
|
||||
and (
|
||||
not can_merge()
|
||||
or info_dict.get('is_live') and not self.params.get('live_from_start')
|
||||
or self.params['outtmpl']['default'] == '-'))
|
||||
compat = (
|
||||
prefer_best
|
||||
or self.params.get('allow_multiple_audio_streams', False)
|
||||
or 'format-spec' in self.params['compat_opts'])
|
||||
if not prefer_best and download and not can_merge():
|
||||
prefer_best = True
|
||||
formats = self._get_formats(info_dict)
|
||||
evaluate_formats = lambda spec: self._select_formats(formats, self.build_format_selector(spec))
|
||||
if evaluate_formats('b/bv+ba') != evaluate_formats('bv*+ba/b'):
|
||||
self.report_warning('ffmpeg not found. The downloaded format may not be the best available. '
|
||||
'Installing ffmpeg is strongly recommended: https://github.com/yt-dlp/yt-dlp#dependencies')
|
||||
|
||||
return (
|
||||
'best/bestvideo+bestaudio' if prefer_best
|
||||
else 'bestvideo*+bestaudio/best' if not compat
|
||||
else 'bestvideo+bestaudio/best')
|
||||
compat = (self.params.get('allow_multiple_audio_streams')
|
||||
or 'format-spec' in self.params['compat_opts'])
|
||||
|
||||
return ('best/bestvideo+bestaudio' if prefer_best
|
||||
else 'bestvideo+bestaudio/best' if compat
|
||||
else 'bestvideo*+bestaudio/best')
|
||||
|
||||
def build_format_selector(self, format_spec):
|
||||
def syntax_error(note, start):
|
||||
|
@ -2928,12 +2944,7 @@ class YoutubeDL:
|
|||
self.write_debug(f'Default format spec: {req_format}')
|
||||
format_selector = self.build_format_selector(req_format)
|
||||
|
||||
formats_to_download = list(format_selector({
|
||||
'formats': formats,
|
||||
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
|
||||
'incomplete_formats': (all(f.get('vcodec') == 'none' for f in formats) # No formats with video
|
||||
or all(f.get('acodec') == 'none' for f in formats)), # OR, No formats with audio
|
||||
}))
|
||||
formats_to_download = self._select_formats(formats, format_selector)
|
||||
if interactive_format_selection and not formats_to_download:
|
||||
self.report_error('Requested format is not available', tb=False, is_error=False)
|
||||
continue
|
||||
|
|
|
@ -713,6 +713,7 @@ from .globo import (
|
|||
from .gmanetwork import GMANetworkVideoIE
|
||||
from .go import GoIE
|
||||
from .godtube import GodTubeIE
|
||||
from .godresource import GodResourceIE
|
||||
from .gofile import GofileIE
|
||||
from .golem import GolemIE
|
||||
from .goodgame import GoodGameIE
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
determine_ext,
|
||||
str_or_none,
|
||||
unified_timestamp,
|
||||
url_or_none
|
||||
)
|
||||
from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
class GodResourceIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://new\.godresource\.com/video/(?P<id>\w+)'
|
||||
_TESTS = [{
|
||||
# hls stream
|
||||
'url': 'https://new.godresource.com/video/A01mTKjyf6w',
|
||||
'info_dict': {
|
||||
'id': 'A01mTKjyf6w',
|
||||
'ext': 'mp4',
|
||||
'view_count': int,
|
||||
'timestamp': 1710978666,
|
||||
'channel_id': '5',
|
||||
'thumbnail': 'https://cdn-02.godresource.com/e42968ac-9e8b-4231-ab86-f4f9d775841f/thumbnail.jpg',
|
||||
'channel': 'Stedfast Baptist Church',
|
||||
'upload_date': '20240320',
|
||||
'title': 'GodResource video #A01mTKjyf6w',
|
||||
}
|
||||
}, {
|
||||
# mp4 link
|
||||
'url': 'https://new.godresource.com/video/01DXmBbQv_X',
|
||||
'md5': '0e8f72aa89a106b9d5c011ba6f8717b7',
|
||||
'info_dict': {
|
||||
'id': '01DXmBbQv_X',
|
||||
'ext': 'mp4',
|
||||
'channel_id': '12',
|
||||
'view_count': int,
|
||||
'timestamp': 1687996800,
|
||||
'thumbnail': 'https://cdn-02.godresource.com/sodomitedeception/thumbnail.jpg',
|
||||
'channel': 'Documentaries',
|
||||
'title': 'The Sodomite Deception',
|
||||
'upload_date': '20230629',
|
||||
}
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id = self._match_id(url)
|
||||
|
||||
api_data = self._download_json(
|
||||
f'https://api.godresource.com/api/Streams/{display_id}', display_id)
|
||||
|
||||
video_url = api_data['streamUrl']
|
||||
if (ext := determine_ext(video_url)) == 'm3u8':
|
||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||
api_data['streamUrl'], display_id)
|
||||
elif ext == 'mp4':
|
||||
formats, subtitles = [{
|
||||
'url': video_url,
|
||||
'ext': ext
|
||||
}], {}
|
||||
else:
|
||||
raise ExtractorError(f'Unexpected video format {ext}')
|
||||
|
||||
return {
|
||||
'id': display_id,
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
'title': '',
|
||||
**traverse_obj(api_data, {
|
||||
'title': ('title', {str}),
|
||||
'thumbnail': ('thumbnail', {url_or_none}),
|
||||
'view_count': ('views', {int}),
|
||||
'channel': ('channelName', {str}),
|
||||
'channel_id': ('channelId', {str_or_none}),
|
||||
'timestamp': ('streamDateCreated', {unified_timestamp}),
|
||||
'modified_timestamp': ('streamDataModified', {unified_timestamp})
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue