question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having multiple YoutubeDL objects open simultaneously

See original GitHub issue

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I remove or skip any mandatory* field

Checklist

  • I’m asking a question and not reporting a bug or requesting a feature
  • I’ve looked through the README
  • I’ve verified that I’m running yt-dlp version 2022.09.01 (update instructions) or later (specify commit)
  • I’ve searched the bugtracker for similar questions including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue

Please make sure the question is worded well enough to be understood

Instances of the YoutubeDL class are supposed to be used with a context manager:

with YoutubeDL(opts) as ydl:
  ... # do stuff with ydl

I have looked at (though not fully understood) the __enter__() and __exit__() code. __exit__() saves cookies to a file if one is explicitly specified, which I don’t. Is there anything else I need to worry about or is it okay for me to do the following?

with YoutubeDL(opts1) as ydl1, YoutubeDL(opts2) as ydl2:
  ...

To make clear why this is concerning me: The code might make the assumption that only one YoutubeDL object is open at a time, like the cookie file code probably does, and produce erroneous behavior if that is not the case and the multiple instances “interfere with each other.”

I want to do things this way because constructing a YoutubeDL instance is runtime-intensive, so I would like to to avoid doing that each time I switch between options.

I am using {"cachedir": False} as part of both opts in case that matters.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pukkandancommented, Sep 2, 2022

As far as I know, it should be fine. But this use-case is not well tested, so I can’t be 100% sure. If you find any issues, let me know and we can fix it

0reactions
pukkandancommented, Sep 5, 2022

No. Cache files are open and closed as required. Since your code isn’t multithreaded, it is fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to download multiple videos at the same time in ...
I'm running a yt-dlp instance with hundreds of links to videos, which becomes very inefficient and takes days to complete when they're all ......
Read more >
How to use youtube-dl to download multiple ... - gHacks
Open a command prompt window by selecting Start, typing cmd, and selecting Command Prompt. If you have saved the file to the Downloads...
Read more >
Download multiple videos with youtube-dl | michaelheap.com
yt-dlp is a fantastic tool for archiving media and it turns out that it supports downloading multiple files at once with the --batch-file ......
Read more >
multiple videos at same time · Issue #10214 · ytdl-org/youtube-dl
Issues with outdated version will be rejected. [x ] I've verified and I assure that I'm running youtube-dl 2016.08.01. Before submitting an ...
Read more >
Downloading multiple files with youtube-dl - Ask Ubuntu
I have to open multiple terminals and start afresh every time I want to download a video. Can you help me to download...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found