ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
129.94k stars 9.8k forks source link

request: Per service configuration #3101

Open gh0stl4b opened 10 years ago

gh0stl4b commented 10 years ago

I love having the option to configure youtube-dl globaly, but it would be great to be able to specify options per service, so like one directory for YouTube, another for SoundCloud and another for Twitch.
I would presume it should look something like this:

[all]
--no-part

[youtube]
-o "%(uploader)s\%(title)s.%(ext)s"

[youtube:playlists]
-o "%(uploader)s\%(playlist)s\%(title)s.%(ext)s"
--ignore-errors

[soundcloud]
--audio-format m4a

[udemy]
--username MyUsername
--password MyPassword

[twitch]
--username MyUsername
--password MyPassword

I hope you get the basic gist.
Thank you :)

yan12125 commented 8 years ago

Would it be a good idea to use a Python script as the configuration file? For example:

# file ~/.config/youtube-dl/config.py

def YoutubeDLFlags(url, ie_key, other_flags):
    flags = []
    if ie_key == 'YouTube':
        flags.extend(['-f', 'bestvideo[ext!=webm]+bestaudio[ext!=webm]'])
    elif ie_key == 'Youku':
        flags.extend(['--proxy', 'hostname:port'])
    return flags

There are indeed lots of implementation issues, but I think it's a good start. A fixed set of flags is simply not flexible enough.

jaimeMF commented 8 years ago

@yan12125 Could you explain why a simple config file with sections is not enough? For the example you posted all you would need is:

[YouTube]
format = bestvideo[ext!=webm]+bestaudio[ext!=webm]

[Youku]
proxy = hostname:port

(I like not using leading dashes, but it could be made optional to support the old format).

yan12125 commented 8 years ago

Sorry for a bad example. Python scripts could solve #6745 as well. In my case, I use a different set of flags when developing youtube-dl. For example:

import os.path

def YoutubeDLFlags(url, ie_key, other_flags):
    if os.path.exists('./youtube_dl/__main__.py'):
        return ['-v', '--write-pages']
    flags = []
    if ie_key == 'YouTube':
        flags.extend(['-f', 'bestvideo[ext!=webm]+bestaudio[ext!=webm]'])
    elif ie_key == 'Youku':
        flags.extend(['--proxy', 'hostname:port'])
    return flags
jaimeMF commented 8 years ago

I think that adding a --include-config to read an specific file would be enough. Even even if we added support for a python script, supporting the simple config would be easier to create for users.

gh0stl4b commented 8 years ago

Any news on whether this is actually gonna get made? Or should I start to learn python and make pull requests? :sweat_smile:

Macellatore commented 4 years ago

Any updates on this? The feature would come in handy, expecially when dealing with different services on a regular basis.

allanlaal commented 3 years ago

the --username and --password config flags are basically useless without this feature implemented