rg3/youtube-dl — pull request #3618 by aivarsk (2014-08-29 23:31:21+00:00)
Title: Add --bind-ip

When making client TCP/IP connections, bind to IP on the local machine. This option can be useful if your machine is bound to multiple IPs.

Should fix issue#721 and others that are marked as duplicates. Other tools have it as well: wget has --bind-address option and I think curl --interface does the same.
Issue#2379 with proposal to change socket.socket() had a comment that "We would prefer not to meddle with the global Python socket's settings." This approach (hopefully) changes behaviour of TCP/IP client sockets that call connect() and does not call bind for UDP and server sockets.
Once support for Python 2.6 is dropped, it can be replaced with HTTPConnection's source_address (since 2.7)