GitHub has restored the code of a project that the RIAA demanded it take down last month after finding that the group’s DMCA complaint was meritless. YouTube-dl, a tool that lets videos from the streaming site be downloaded for offline viewing, is back in action — and GitHub is changing its policy and earmarking a million dollars for a legal defense fund against future importunities.

The controversy began in mid-October when the RIAA sent a DMCA complaint to GitHub claiming that YouTube -dl violated the law no only by providing a tool for circumventing DRM, but by promoting the piracy of several popular songs in its documentation.

GitHub, like many tech companies, tends to assume the veracity of a complaint like this if it’s from a known entity like the RIAA, and it seems to have done so here, taking down YouTube-dl and publishing the complaint.

As many pointed out at the time, saying this project is a tool for circumventing DRM is like saying a tape recorder is a tool for music piracy. It’s used for far more than that, from research and accessibility purposes to integration with other apps for watch-later features and so on.

After a fork of YouTube-dl was created that lacked the references to popular YouTube videos as examples for use, the project was largely back online. But then GitHub received a letter from the internet freedom advocates at the Electronic Frontier Foundation and realized they’d been had.

As the EFF letter explains (and as the technically savvy GitHub must surely have suspected from the start), the YouTube-dl project was never in violation of the DMCA. In the first place, what the RIAA described as a suggestion in the documentation to pirate certain songs is only a test that streams a few seconds of those videos to show that the software is working — well within fair use rights.

More importantly, the RIAA misconstrues the way YouTube and YouTube-dl’s code works, mistaking a bit of code on the video site for encryption and concluding that the tool unlawfully circumvents it, violating section 1201 of the DMCA. They also refer to a court case supporting this interpretation.

In fact, as the EFF explains patiently in its letter, the code does nothing of the sort and the way YouTube-dl’s agent “watches” a video is indistinguishable to YouTube from a normal user. Everything is conducted in the clear and using no secret codes or back doors. And the court case, the EFF notes, is mistaken and at any rate German and not applicable under U.S. laws.

GitHub, perhaps feeling a bit ashamed for having folded so quickly and completely in the face of a shabbily argued nastygram from the RIAA, announced several changes to prevent such occurrences in the future.

First, all copyright claims under section 1201 — which are fundamentally dubious — will receive a technical and legal review, and an independent one if necessary, to evaluate the truth of their assertions. If the findings aren’t decisive, the project will be left up instead of taken down while the proceedings continue. Should the project seem to be in violation, they will be given a chance to amend it before takedown. And if a takedown occurs, the developers will still be able to access important data like pull requests and bug reports.

Second, GitHub is establishing a $1M developer defense fund that will be used to protect developers on the platform from bad section 1201 claims. After all, faced with the possibility of a court battle, many a poor or hobby developer will simply abandon their work, which is one of the outcomes being counted on by abusers of the DMCA.

And third, the company will be continuing its lobbying work to amend the DMCA and equivalents around the world, with a specific focus on section 1201 it plans to announce soon.

It’s a happy ending for this little saga, and while DMCA abuse is a serious and ongoing issue, at least the bullies didn’t get their way this time. Until the law changes this will continue to be an issue, but vigilance and strongly worded letters will do in the meantime.