You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please make sure the question is worded well enough to be understood
I tried to download instagram videos with this code but the cookie does not load.
But with yt-dlp --cookies instagram_cookie.txt "https://www.instagram.com/p/C9SEsmYCx_M/?hl=ja" it does.
Is there something wrong with my code? If so, please let me know the solution.
Sorry if I have missed something.
from yt_dlp import YoutubeDL
import subprocess
def download_video(url):
if url in ".m3u8":
subprocess.run(f'ffmpeg -i {url} -c copy "%name%.mp4"', shell=True)
print("m3u8ファイルをダウンロードました")
else:
ydl_opts = {
'format': 'best[ext=mp4]',
'outtmpl': '%(title)s.%(ext)s',
'verbose': True,
}
if "instagram.com" in url:
ydl_opts["cookies"] = "instagram_cookie.txt"
print(ydl_opts)
with YoutubeDL(ydl_opts) as ydl:
result = ydl.extract_info(url, download=True)
file_path = ydl.prepare_filename(result)
print(f"{file_path}をダウンロードました")
return file_path
if __name__ == "__main__":
download_video(input("URL:"))
Provide verbose output that clearly demonstrates the problem
Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
If using API, add 'verbose': True to YoutubeDL params instead
Copy the WHOLE output (starting with [debug] Command-line config) and insert it below
Complete Verbose Output
URL:https://www.instagram.com/p/C9SEsmYCx_M/?hl=ja
{'format': 'best[ext=mp4]', 'outtmpl': '%(title)s.%(ext)s', 'verbose': True, 'cookies': 'instagram_cookie.txt'}
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.07.13.232701 from yt-dlp/yt-dlp-nightly-builds [150ecc45d] (pip) API
[debug] params: {'format': 'best[ext=mp4]', 'outtmpl': '%(title)s.%(ext)s', 'verbose': True, 'cookies': 'instagram_cookie.txt', 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
[debug] Python 3.10.14 (CPython x86_64 64bit) - Linux-6.5.0-1023-gcp-x86_64-with-glibc2.39 (OpenSSL 3.0.13 30 Jan 2024, glibc 2.39)
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.07.04, mutagen-1.47.0, requests-2.32.3, sqlite3-3.45.3, urllib3-2.2.2, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1834 extractors
[Instagram] Extracting URL: https://www.instagram.com/p/C9SEsmYCx_M/?hl=ja
[Instagram] C9SEsmYCx_M: Setting up session
[Instagram] C9SEsmYCx_M: Downloading JSON metadata
WARNING: [Instagram] C9SEsmYCx_M: General metadata extraction failed (some metadata might be missing).
[Instagram] C9SEsmYCx_M: Downloading webpage
WARNING: [Instagram] unable to extract shared data; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
WARNING: [Instagram] Main webpage is locked behind the login page. Retrying with embed webpage (some metadata might be missing).
[Instagram] C9SEsmYCx_M: Downloading embed webpage
WARNING: [Instagram] unable to extract additional data; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
ERROR: [Instagram] C9SEsmYCx_M: Requested content is not available, rate-limit reached or login required. Use --cookies, --cookies-from-browser, --username and --password, --netrc-cmd, or --netrc (instagram) to provide account credentials
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 740, in extract
ie_result = self._real_extract(url)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/instagram.py", line 460, in _real_extract
self.raise_login_required('Requested content is not available, rate-limit reached or login required')
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 1245, in raise_login_required
raise ExtractorError(msg, expected=True)
Traceback (most recent call last):
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1622, in wrapper
return func(self, *args, **kwargs)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1757, in __extract_info
ie_result = ie.extract(url)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 740, in extract
ie_result = self._real_extract(url)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/instagram.py", line 460, in _real_extract
self.raise_login_required('Requested content is not available, rate-limit reached or login required')
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/extractor/common.py", line 1245, in raise_login_required
raise ExtractorError(msg, expected=True)
yt_dlp.utils.ExtractorError: [Instagram] C9SEsmYCx_M: Requested content is not available, rate-limit reached or login required. Use --cookies, --cookies-from-browser, --username and --password, --netrc-cmd, or --netrc (instagram) to provide account credentials
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/moive-download-exe/main.py", line 27, in<module>
download_video(input("URL:"))
File "/home/runner/moive-download-exe/main.py", line 20, in download_video
result = ydl.extract_info(url, download=True)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1611, in extract_info
return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1640, in wrapper
self.report_error(str(e), e.format_traceback())
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1088, in report_error
self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
File "/home/runner/moive-download-exe/.pythonlibs/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 1027, in trouble
raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: [Instagram] C9SEsmYCx_M: Requested content is not available, rate-limit reached or login required. Use --cookies, --cookies-from-browser, --username and --password, --netrc-cmd, or --netrc (instagram) to provide account credentials
The text was updated successfully, but these errors were encountered:
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Please make sure the question is worded well enough to be understood
I tried to download instagram videos with this code but the cookie does not load.
But with
yt-dlp --cookies instagram_cookie.txt "https://www.instagram.com/p/C9SEsmYCx_M/?hl=ja"
it does.Is there something wrong with my code? If so, please let me know the solution.
Sorry if I have missed something.
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
The text was updated successfully, but these errors were encountered: