-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YouTube] Unthrottle downloads by responding to the "n" parameter challenge #30184
Conversation
b17a74f
to
20fc434
Compare
Thanks I cherry picked this into my fork and it works for single video downloads but if I download a playlist, I get ssl errors example downloading this playlist from youtube PLUJAYadtuizA5JblMkTYUuOhUqiQco0pu
|
I doubt that this is related. This issue has been seen before and it has been put down to server-side weirdness. You could iterate the playlist download, perhaps using Just now I tried for the mentioned playlist and got items 1-4 of 17 with no error before I gave up. |
Thanks, this totally fixed my youtube download issues here. Hopefully this makes it into the official code and the next release. |
Not sure that you can assert that: this is arguably a derivative work of VLC's |
In my opinion, #30188 is a better approach: youtube-dl already has a javascript interpreter framework, which is a technically superior solution, and from a project direction point of view, it doesn't make much sense to start doing ad hoc emulation in individual extractors instead. I appreciate the work, though :) |
Yes, in the long term, should merging ever happen, it would be better to use the solution based on JSInterp, but that needs further work that is not needed for this PR.
In case that should not come to pass, I agree that while I assert authorship in the PR boilerplate the implementation of While there is no copyright in ideas, and I don't know whether it was used in the |
This exact same thing has already been implemented by pytube (Unlicense) pytube/pytube@79befd6 long before the VLC implementation. So I am not sure how much this license argument holds |
This comment was marked as off-topic.
This comment was marked as off-topic.
Now, now. Generally I would prefer open source projects to use copyleft. The permissive licences offer too much leeway to commercial interests. Further, yt-dl's Unlicense is something of a chocolate teapot among licences: it would be no problem if (say) VLC wished to adopt (say, again) the recently enhanced JSInterp in a reverse derivation, but then it is unclear whether yt-dl could make use of enhancements made to the adopted version without seeking permission each time. In this case we are talking about a small script component adapted into the PR that was, as I understood, proposed to yt-dl for the use that I made of it. Since the nature of yt-dl (and other interpreted language projects) is that the source code is delivered with the product, as well as being available from the project repository, I find it hard to see why the author of the component would not be happy to see his work used in this way. Certainly it is possible that this Python version of As the PR text says and as further explained in my previous comment, the implementation was deliberately arranged to stay close to the original for ease of implementation (oh, and a Lua refresh since my last encounter with it in Wireshark 10 years ago) and for mutual benefit in case either version should be enhanced or fixed. Otherwise, to the extent that the program logic is determined by the YT challenge mini-language (as evidenced by the pytube implementation) copyright protection would not apply despite it being a derived work. Deliberate reinvention of the wheel to comply with, or work around, the letter of a software licence benefits no-one and makes open source look bad.
Which would be fine, or just, as was my initial understanding of @linkfanel's original intervention, to confirm that a Python version of |
No, that's called fair use under copyright law. |
Indeed, I recommend study of the discussion of derived works that I linked in my first comment, in particular:
However, in this case English or French copyright law would probably apply. But the extent to which a routine, whose logic, constrained to meet a pre-existing 'method of operation', has been translated into a different language and run-time API, might be considered to infringe the copyright of the original is not, should not and need not be the issue. Although we appear to like the same sort of licences, @89z has completely failed to grasp the situation, which is that the PR was prepared on the understanding that the VLC There is no point trying to infer what my intentions are regarding this since I have none until I see @linkfanel's response to this discussion. |
Hmm, interesting I compile youtube-dl with python 3.9+ and had to set
and seems to work. |
Geez, people, please calm down: you're arguing the mergeability of a merge request to an unmaintained project that is probably not going get merged anyway. Copyright isn't rocket science, nor the exclusive prerogative of lawyers (don't play into the game of those who'd like to make you believe so because it's their vested interest). Very little of this is unclear or subject to interpretation. It's true that ideas or algorithms aren't copyrightable: copyright is about protecting the particular creative expression of such ideas. When you read this merge request, you see and recognize VLC's These differences also illustrate just how the writing of this kind of code is not constrained to the given descrambling algorithm, and where the part of coprightable creative expression lies. Now it's true that these two pieces of code are similar insofar as they do the same job, but as we said neither that nor the fact that they would be derived from the same analysis makes this fall under the purview of copyright protection; you'd rather be looking at something like patents in this case. (And the mere validity of software patents is a controversial topic, it's simply rejected under some jurisdiction. And then anyway, they have a different nature: copyright is an intellectual property right, so a more natural and inalienable kind of right, and its protection is automatic; whereas patents are a willful and deliberate contract registered with the state, that you may or may not want to enter into, for you get granted protection and remuneration for your work only in exchange of publishing and making it available to the public for the benefit and advancement of society. IIRC Coca-Cola's coke recipe is not patented: it's kept a trade secret instead.) But back to copyright, neither I guess you could assert fair use of
It's not unclear: they could not. This is a well-known issue with code reuse between software projects with differing licenses. In my original intervention I meant to put forward an alternative design, and gave the example of VLC's I actually do believe in the principles of the GPL and copyleft, and I'm not keen to relicense. But I think this is all moot anyway. If and when youtube-dl gets maintained again, and they don't fancy writing their own fix themselves and are happy to merge an existing merge request, and for some reason they choose not to merge or build on the javascript interpreter improvements, and in the meantime there has been no other merge request with an actually compatible license such as one based on pytube's code, or another original implementation of the concept that linking |
This is not entirely true. AFAIK, youtube-dl could say "the code is dual-licensed under Unlicense and GPLv3, but the nsig decryption code is only available under GPLv3". But of course that would go against the spirit of the project and could cause headaches. |
I think that just proved it ain't so simple. |
Regarding @linkfanel's response, I'm grateful for the clarification, though @rautamiekka does make a good point about it. No doubt an acceptable replacement for the problem code will be offered for merge if @linkfanel doesn't wish to bless the existing version. Even if I might be more a It was never intended to copy the work @nyuszika7h said:
Indeed, GPL has a concept of a "compatible" licence: "subordinate" would probably be a better term. This is a licence that allows its protected work to be distributed under GPL, and the Unlicense is an example. This so-called compatibility is very definitely not a reflexive relation, with GPL licenses strictly dominating all others. I would probably consider doing that if yt-dl were my project and for some reason I couldn't arrange for the JSInterp solution, but that would have to be some big reason. It might also be possible to distribute the
This section of GPLv2 addresses the case of a work that is substantially derived from a protected Program, with some additional software provided by the licensee and requires the whole thing to be distributed under GPLv2, but makes no exception allowing the reuse of a small part of a protected Program in the context of a much larger work not distributed under GPLv2, even if that should happen to be free software and delivered as source code. The Program's owner must give permission (section 10), or the reuse must count as fair use in the applicable jurisdiction (England and Wales? France? the Earth?). Excepting fair use, the To understand "at a minimum", one has to rely on the guidance around GPLv2, which like the licence itself focuses on traditional compile-link development, a bit surprising considering how important elisp was/is to the originators. A Python module comprising a single exported function might fall into the case where a "main program dynamically links plug-ins, but the communication between them is limited to invoking the ‘main’ function of the plug-in with some options and waiting for it to return", said to be a "borderline case" for applying GPLv2 to distribution of the main program as well; or it might match the case of a Perl module (after all, Python is the read-write equivalent of Perl ...), where "you must release the [calling] program in a GPL-compatible way". None of this is actually stated in the licence text itself ... hello, counsel. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This is why MPL is better than GPL, it would only ever apply to the single file that contains the nsig code and not infect others. So even commercial reuses of youtube-dl would only have to distribute any modifications they've made to nsig.py or whatever it's called. Though I suppose dual-licensing the rest of the code kind of achieves the same. |
Any progress on this PR? It would be great to have unthrottled downloads in stable youtube-dl, eh. |
Don't hold your breath, but there is reason to expect a new release sooner rather than never, and this will be at the top of the list, I guess. |
So assuming you can compute the Eg. here's one such video (or audio) URL together with its
|
We can, and we do. Read the code of the PR. Also, will algebraic cohomology be able to supply enough sheaves to relieve the wheat shortage, if topological cohomology can't do the job? |
Please follow the guide below
Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Since summer 2021, YouTube has started serving media URLs with a query parameter such as
...&n=SXiXBH-xzrjeioPN&...
. This now appears to be the default behaviour. Unless the value of this parameter is transformed according to an algorithm delivered in the site player JS, the download speed for the URL is throttled to ~50kB/s.Solutions for this include:
This PR now uses the first approach taking the enhanced JSInterpreter module from yt-dlp PR #1437, as back-ported in PR #30188.
The PR originally took a different approach derived from the successful solution used in VLC's
youtube.lua
(also implemented differently in pytube, relying on the fact that the challenge algorithm is served in a mini-language within the minified player JS and therefore the specific algorithm could be extracted and executed by interpreting the mini-language without actually running the JS itself. This version had the benefit of offering a single file update, but was unstable against regular site changes and raised licensing issues as discussed below.The PR also includes fixes for
test/test_youtube_lists.py
. This download test failed in Python 2 and contained tests that failed or were redundant because of obsolete assumptions about theyoutube.py
extractor or YouTube services.Anyone who wants a single file update to fix the 2021.06.06 (or 2012.12.17) release pending merge/release of the PR should use this version of extractor/youtube.py which is a drop-in replacement. This also includes the URL signature fix from #30366 and 2021.12.17.
Resolves #29326 (original analysis of the "n" parameter challenge)
Resolves #29790
Resolves #30004
Resolves #30024
Resolves #30052
Resolves #30088
Resolves #30097 (original reference to
n_descramble()
)Resolves #30102
Resolves #30109
Resolves #30119
Resolves #30125
Resolves #30128
Resolves #30162
Resolves #30173
Resolves #30186
Resolves #30192
Resolves #30221
Resolves #30239
Resolves #30539
Resolves #30552.