Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ie/twitter:spaces] Fix format protocol #7550

Merged
merged 2 commits into from Jul 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions yt_dlp/extractor/twitter.py
Expand Up @@ -1555,13 +1555,11 @@ def _real_extract(self, url):
source = traverse_obj(
self._call_api(f'live_video_stream/status/{metadata["media_key"]}', metadata['media_key']),
('source', ('noRedirectPlaybackUrl', 'location'), {url_or_none}), get_all=False)
formats = self._extract_m3u8_formats(
source, metadata['media_key'], 'm4a', live=is_live, fatal=False,
headers={'Referer': 'https://twitter.com/'}) if source else []
formats = self._extract_m3u8_formats( # XXX: Needs ffmpeg as downloader
source, metadata['media_key'], 'm4a', entry_protocol='m3u8', live=is_live,
headers={'Referer': 'https://twitter.com/'}, fatal=False) if source else []
for fmt in formats:
fmt.update({'vcodec': 'none', 'acodec': 'aac'})
if not is_live:
fmt['container'] = 'm4a_dash'
Copy link
Member

@pukkandan pukkandan Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this anyway, since user can force native with --downloader native. Afair, fixup code will not run when ffmpeg is used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does still fixup when ffmpeg is used. Should we still add it back though? I have added it for now

Btw here's an example where native+fixup works (I wasn't just imagining it):

$ yt_dlp --cookies-from-browser firefox::twitter --downloader native 'https://twitter.com/i/spaces/1vAxRAVQWONJl'
[Cookies] Extracting cookies from firefox
[Cookies] Extracted 59 cookies from firefox
[twitter:spaces] Extracting URL: https://twitter.com/i/spaces/1vAxRAVQWONJl
[twitter:spaces] 1vAxRAVQWONJl: Downloading GraphQL JSON
[twitter:spaces] 28_1646577130061590528: Downloading legacy API JSON
[twitter:spaces] 28_1646577130061590528: Downloading m3u8 information
[info] 1vAxRAVQWONJl: Downloading 1 format(s): 0
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 829
[download] Destination: 20230413_googlecloud_1vAxRAVQWONJl_Framing_Up_FinOps_-_Billing_Tools.m4a
[download] 100% of   31.58MiB in 00:03:07 at 172.21KiB/s
[FixupM4a] Correcting container of "20230413_googlecloud_1vAxRAVQWONJl_Framing_Up_FinOps_-_Billing_Tools.m4a"
$

Copy link
Member

@pukkandan pukkandan Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does still fixup when ffmpeg is used.

diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index d0be3c964..cc1741b75 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -3418,7 +3418,7 @@ def ffmpeg_fixup(cndn, msg, cls):
                     postprocessed_by_ffmpeg = info_dict.get('requested_formats') or any((
                         isinstance(pp, FFmpegVideoConvertorPP)
                         and resolve_recode_mapping(ext, pp.mapping)[0] not in (ext, None)
-                    ) for pp in self._pps['post_process'])
+                    ) for pp in self._pps['post_process']) or fd == FFmpegFD

                     if not postprocessed_by_ffmpeg:
                         ffmpeg_fixup(ext == 'm4a' and info_dict.get('container') == 'm4a_dash',

This should fix it. I'll push it later.


participants = ', '.join(traverse_obj(
space_data, ('participants', 'speakers', ..., 'display_name'))) or 'nobody yet'
Expand Down