From d694c4eec544347f789b40688d513ea96cf2472c Mon Sep 17 00:00:00 2001 From: AlexandreHalbardier Date: Mon, 16 Dec 2019 13:49:12 +0100 Subject: [PATCH] Add an option to download all music videos from a youtube user --- README.md | 21 +++++++++++---------- youtube_dl/__init__.py | 5 +++++ youtube_dl/options.py | 4 ++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 01f975958..f9ee76c42 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo repairs broken URLs, but emits an error if this is not possible instead of searching. --ignore-config Do not read configuration files. When given - in the global configuration file - /etc/youtube-dl.conf: Do not read the user + in the global configuration file /etc + /youtube-dl.conf: Do not read the user configuration in ~/.config/youtube- dl/config (%APPDATA%/youtube-dl/config.txt on Windows) @@ -108,8 +108,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading. - --geo-bypass Bypass geographic restriction via faking - X-Forwarded-For HTTP header + --geo-bypass Bypass geographic restriction via faking X + -Forwarded-For HTTP header --no-geo-bypass Do not bypass geographic restriction via faking X-Forwarded-For HTTP header --geo-bypass-country CODE Force bypass geographic restriction with @@ -130,6 +130,8 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo specify range: "--playlist-items 1-3,7,10-13", it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13. + --user-music None Downloads all the music videos of a youtube + user (doesnt work if its a channel) --match-title REGEX Download only matching titles (regex or caseless sub-string) --reject-title REGEX Skip download for matching titles (regex or @@ -258,12 +260,11 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo jar in --cache-dir DIR Location in the filesystem where youtube-dl can store some downloaded information - permanently. By default - $XDG_CACHE_HOME/youtube-dl or - ~/.cache/youtube-dl . At the moment, only - YouTube player files (for videos with - obfuscated signatures) are cached, but that - may change. + permanently. By default $XDG_CACHE_HOME + /youtube-dl or ~/.cache/youtube-dl . At the + moment, only YouTube player files (for + videos with obfuscated signatures) are + cached, but that may change. --no-cache-dir Disable filesystem caching --rm-cache-dir Delete all filesystem cache files diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 9a659fc65..2af462500 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -80,6 +80,11 @@ def _real_main(argv=None): write_string(std_headers['User-Agent'] + '\n', out=sys.stdout) sys.exit(0) + # When usermusic option is activated, no need for url + if opts.usermusic is not None: + url = "https://www.youtube.com/user/"+opts.usermusic+"/videos?view=64&flow=grid" + args.append(url) + # Batch file verification batch_urls = [] if opts.batchfile is not None: diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 1ffabc62b..1086f2a44 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -267,6 +267,10 @@ def parseOpts(overrideArguments=None): '--playlist-items', dest='playlist_items', metavar='ITEM_SPEC', default=None, help='Playlist video items to download. Specify indices of the videos in the playlist separated by commas like: "--playlist-items 1,2,5,8" if you want to download videos indexed 1, 2, 5, 8 in the playlist. You can specify range: "--playlist-items 1-3,7,10-13", it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13.') + selection.add_option( + '--user-music', + dest='usermusic', + help='Downloads all the music videos of a youtube user (doesnt work if its a channel)') selection.add_option( '--match-title', dest='matchtitle', metavar='REGEX',