Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to save video with its metadata? #8253

Answered by mikf
gphg asked this question in Q&A
Discussion options

I want to emulate this that can be normally be done on yt-dlp, but on gallery-dl:

yt-dlp --embed-metadata <URL>

How?

Update:
For additional information, this is the content of my ~/.config/yt-dlp/config:

--embed-metadata
--output "%(extractor)s %(id)s %(title).200s.%(ext)s"

Additional update:
I was targeting x.com. But this could be useful on other services too.

Update:
I found the %(id)s returning not the tweet ID, but something else. But this is normal on YouTube, Vimeo, and other services — I don't know why.

You must be logged in to vote

Replies: 1 comment 4 replies

Comment options

See #8257

Use "videos": "ytdl" and look into downloader.ytdl.... options.

You must be logged in to vote
4 replies
Comment options

I got this error. What should I do?

Traceback (most recent call last):
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3540, in process_info
 info_dict['__finaldir'] = os.path.dirname(os.path.abspath(full_filename))
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "<frozen posixpath>", line 415, in abspath
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/gallery_dl/downloader/ytdl.py", line 165, in _download_video
 ytdl_instance.process_info(info_dict)
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 187, in wrapper
 return func(self, *args, **kwargs)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3546, in process_info
 raise UnavailableVideoError(err)
yt_dlp.utils.UnavailableVideoError: Unable to download video: [Errno 2] No such file or directory
[download][error] Failed to download 1966409327956340755_1.mp4
[twitter][debug] Sleeping 20.11 seconds (download)
[downloader.ytdl][debug] Forwarding cookies to yt_dlp.YoutubeDL
[downloader.ytdl][debug] [twitter] Extracting URL: https://x.com/i/web/status/1966408787532857391
[downloader.ytdl][debug] [twitter] 1966408787532857391: Downloading GraphQL JSON
[downloader.ytdl][debug] [twitter] 1966408787532857391: Downloading m3u8 information
./gallery-dl/twitter/elflina_private/1966408787532857391_1.mp4[downloader.ytdl][debug] [download] ./gallery-dl/twitter/elflina_private/1966408787532857391_1.fhls-10026.mp4 has already been downloaded
[downloader.ytdl][debug] [download] Download completed
[downloader.ytdl][debug] [download] ./gallery-dl/twitter/elflina_private/1966408787532857391_1.fhls-audio-128000-Audio.mp4 has already been downloaded
[downloader.ytdl][debug] [download] Download completed
[downloader.ytdl][debug]
Traceback (most recent call last):
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3540, in process_info
 info_dict['__finaldir'] = os.path.dirname(os.path.abspath(full_filename))
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "<frozen posixpath>", line 415, in abspath
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/gallery_dl/downloader/ytdl.py", line 165, in _download_video
 ytdl_instance.process_info(info_dict)
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 187, in wrapper
 return func(self, *args, **kwargs)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3546, in process_info
 raise UnavailableVideoError(err)
yt_dlp.utils.UnavailableVideoError: Unable to download video: [Errno 2] No such file or directory
[download][error] Failed to download 1966408787532857391_1.mp4

This is my configuration:

{
 ...
 "downloader": {
 "ytdl": {
 "cmdline-args": [
 "--embed-metadata",
 "--cookies-from-browser",
 "firefox"
 ]
 }
 },
 ...
}

Update: it is working now. Had to modify the yt-dlp config file into something like this:

--embed-metadata
--output "%(extractor)s %(display_id&display_id|id)s %(title).200s.%(ext)s"
Comment options

I got errors sometimes. It is different error and it has to do with receiving JSON.

[downloader.ytdl][debug] [twitter] 1955952892592185509: Downloading GraphQL JSON
[downloader.ytdl][error] ERROR: [twitter] 1955952892592185509: Unable to download JSON metadata: HTTPSConnectionPool(host='x.com', port=443): Read timed out. (read timeout=20.0) (caused by TransportError("HTTPSConnectionPool(host='x.com', port=443): Read timed out. (read timeout=20.0)"))
[download][error] Failed to download 1955952892592185509_1.mp4
[twitter][debug] Skipping 1955837203357339676 (quoted tweet)

Change the retries to higher value fixed this.

Comment options

mikf Sep 22, 2025
Maintainer

These are all yt-dlp errors. Sorry, but I can't help with those.

I can only report that it Works on my machine TM️ for regular videos:

$ gallery-dl -c config.json https://twitter.com/perrypumas/status/1065692031626829824?s=20
[twitter][info] Initializing client transaction keys
./twitter/perrypumas/1065692031626829824_1.mp4
Comment options

These are all yt-dlp errors. Sorry, but I can't help with those.

I can only report that it Works on my machine TM️ for regular videos:

$ gallery-dl -c config.json https://twitter.com/perrypumas/status/1065692031626829824?s=20
[twitter][info] Initializing client transaction keys
./twitter/perrypumas/1065692031626829824_1.mp4

For additional information, this is my configuration file:

{
 "postprocessors": [
 {
 "name": "metadata",
 "mode": "json",
 "directory": "./"
 },
 {
 "name": "mtime"
 }
 ],
 "downloader": {
 "ytdl": {
 "cmdline-args": [
 "--retries",
 "100",
 "--embed-metadata",
 "--cookies-from-browser",
 "firefox"
 ]
 }
 },
 "extractor": {
 "path-restrict": "windows",
 "twitter": {
 "text-tweets": true,
 "retweets": true,
 "cookies": ["firefox"],
 "sleep": [14.9, 29.2],
 "sleep-request": [13.8, 33.6],
 "videos": "ytdl",
 "retries": 99,
 },
 ...
 }
}

My idea is to download whole /media from an account, sometimes, out of curiosity. I put sleep so I can avoid suspension.

The retries does not seem working.

Answer selected by gphg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /