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
130.08k stars 9.81k forks source link

Bandcamp and Youtube-dl #6231

Open NickWinston123 opened 9 years ago

NickWinston123 commented 9 years ago

Is there any way to do youtube-dl username.bandcamp.com and it download all of the albums? Is that supported yet?

When I tried it gave me this error.

nicks-mac-mini:~ nick$ youtube-dl http://liluglymane.bandcamp.com --verbose flag [debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'http://liluglymane.bandcamp.com', u'--verbose', u'flag'] [debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2015.07.07 [debug] Python version 2.7.10 - Darwin-13.3.0-x86_64-i386-64bit [debug] exe versions: ffmpeg 2.7.1, ffprobe 2.7.1 [debug] Proxy map: {} [Bandcamp:album] liluglymane: Downloading webpage ERROR: The page doesn't contain any tracks; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output. Traceback (most recent call last): File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 654, in extract_info ie_result = ie.extract(url) File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 273, in extract return self._real_extract(url) File "/usr/local/bin/youtube-dl/youtube_dl/extractor/bandcamp.py", line 169, in _real_extract raise ExtractorError('The page doesn\'t contain any tracks') ExtractorError: The page doesn't contain any tracks; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output. nicks-mac-mini:~ nick$

dstftw commented 9 years ago

That is not supported. Only per album.

djvs commented 7 years ago

A quick ruby script to hack this - requires curb and nokogiri gems. I named it "bandcamp-dl" on my system, although that name does refer to someone else's program, which is unfortunately not working for me...invoke like bandcamp-dl "http://whoever.bandcamp.com/link-with-multiple-albums-on-it" and it'll just create a folder for each one in the current directory and then call youtube-dl in each dir for each album it finds.

#!/usr/bin/env ruby

require 'curb'
require 'nokogiri'

targetdir = Dir.pwd
url = ARGV[0]
yta = 'youtube-dl --no-mtime -o "%(autonumber)s-%(title)s.%(ext)s"'
unless url.match(/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix)
  puts "Url is invalid!"
  raise ArgumentError 
end
bcsubdmn = url.split("/")[2].split('.').first

puts "Saving into #{targetdir}..."

result = Curl.get(url)
noko = Nokogiri::HTML.parse(result.body_str)
bandcampalbums = noko.css("a[href*='bandcamp.com/album'], a[href^='/album/']").map{|x|x.attr('href')}.uniq.map{|y| y.match(/^\//) ? "http://#{bcsubdmn}.bandcamp.com#{y}" : y }.map{|x| [x, x.split("/").last.gsub('-',' ') ]}
bandcampalbums.each do |al|
  puts "Downloading \"#{al.last}\" (#{al.first})..."
  newtarget = "#{targetdir}/#{al.last}"
  puts "  into #{newtarget} ..."
  `mkdir -p "#{newtarget}"; cd "#{newtarget}"; #{yta} "#{al.first}"; cd #{targetdir}` 
end

Edit: keeping this here: https://github.com/djvs/bandcamp-dl

stefanos82 commented 6 years ago

@djvs well, those who are under Linux are quite privileged to use a set of tools, pipeline them together, and produce the desired result in no time.

My way of downloading Bandcamp albums is rather silly, yet so convenient.

All I do is to extract the links (thanks to elinks, a nice text web browser), clean the unnecessary duplicates, and save them in a file.

Then I use that file with -a flag and that would be it.

Step 01

elinks --dump --no-numbering <URL> | 
grep -e '.com/album' -e '.com/track' | 
sed 's/.*https/https/g' |
uniq > links.txt

Step 02

youtube-dl \
    -o "Your artist's name - %(playlist)s/%(playlist_index)s. %(title)s.%(ext)s" 
    -a links.txt

UPDATE

No need to save the extracted links to a file; just run the following updated command and will do:

youtube-dl -x --audio-format mp3 \
    -o "<Foo-artist-name>/%(playlist)s/%(playlist_index)s. %(title)s.%(ext)s" \
    $(elinks --dump --no-numbering https://<foo-artist-name>.bandcamp.com | \
    grep -e '.com/album' -e '.com/track' | \
    sed 's/.*https/https/g' | uniq)
chimmel commented 6 years ago

@dstftw I cannot download per album nor track:

machine:Downloads superuser$ youtube-dl https://kingephraiim.bandcamp.com/album/osiris [Bandcamp:album] osiris: Downloading webpage [download] Downloading playlist: Osiris [Bandcamp:album] playlist Osiris: Collected 21 video ids (downloading 21 of them) [download] Downloading video 1 of 21 [Bandcamp] start: Downloading webpage ERROR: unable to download video data: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)> machine:Downloads superuser$ youtube-dl https://kingephraiim.bandcamp.com/track/start [Bandcamp] start: Downloading webpage ERROR: unable to download video data: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)>

@stefanos82 when I tried your method links.txt came out blank.

stefanos82 commented 6 years ago

@chimmel I have just tried my suggestion and I can download the entire discography of your band.

What exactly did you do if I may ask?

virtualbeck commented 6 years ago

@stefanos82

Made your script a bashrc function.


function getBandCampMusic() {
  cd ~/Music/
  elinks --dump --no-numbering https://$1.bandcamp.com/ | 
  grep -e '.com/album' -e '.com/track' | 
  sed 's/.*https/https/g' |
  uniq > links.txt
  youtube-dl -o $1" - %(playlist)s/%(playlist_index)s. %(title)s.%(ext)s" -a links.txt
  rm links.txt
}
lyz-code commented 4 years ago

If anyone needs this extractor, I've incorporated the #20207 PR into the master branch of my fork and I try to periodically rebase the new changes of the upstream master.

v-fox commented 3 years ago

I've been trying to download from this with and without the aforementioned PR but it always ends up with:

[debug] System config: []
[debug] User config: ['-f', 'mkv[vcodec=av01,height<=1080]+bestaudio/webm[vcodec=av01,height<=1080]+bestaudio/bestvideo[vcodec=hevc,height<=1080]+bestaudio/bestvideo[vcodec=vp9,height<=1080]+bestaudio/best[height<=1080]', '--no-cache-dir', '--add-metadata', '--sub-format', 'best', '--write-sub', '--embed-subs', '--sub-lang', 'en,en-CA,ru', '-c', '-R', 'infinite', '--http-chunk-size', '2097152', '--buffer-size', '16K', '--socket-timeout', '30', '--yes-playlist', '--no-check-certificate']
[debug] Custom config: []
[debug] Command-line args: ['https://bandcamp.materiacollective.com/album/resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.8.5 (CPython) - Linux-5.8.10-1932.g33939e8-HSF-x86_64-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[generic] resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night: Requesting header
WARNING: Falling back on generic information extractor.
[generic] resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night: Downloading webpage
[generic] resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night: Extracting information
[Bandcamp:album] resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night: Downloading webpage
WARNING: unable to extract title; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
[download] Downloading playlist: resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night
[Bandcamp:album] playlist resurrection-of-the-night-alucards-elegy-music-from-castlevania-symphony-of-the-night: Collected 13 video ids (downloading 13 of them)
[download] Downloading video 1 of 13
[Bandcamp] the-nightmare: Downloading webpage
ERROR: No video formats found; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 532, in extract
    ie_result = self._real_extract(url)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/bandcamp.py", line 196, in _real_extract
    self._sort_formats(formats)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 1359, in _sort_formats
    raise ExtractorError('No video formats found')
youtube_dl.utils.ExtractorError: No video formats found; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Removing format directive from config or overriding it to anything (like '-f best', '-f bestaudio' or '--format none --audio-format best') doesn't change anything.

Otiel commented 3 years ago

Bandcamp has changed their metadata formatting recently (in the last day-ish). That's probably the cause and would need a fix on youtube-dl part.

gilou commented 3 years ago

This was reported in #26681 and might be fixed by #26684

lyz-code commented 3 years ago

I've updated both the PR #20207 and my master branch with @gilou's contribution, thanks!

ghost commented 3 years ago

@lyz-code how do I convert this into an exe

lyz-code commented 3 years ago

Hi @mjlee2003 , I have no idea on how to convert python code to exe (I only use Linux), but probably the youtube-dl documentation tells you how.

Once you've discovered how to convert python code to an exe file, clone or download the feature/bandcamp_user_support branch of my repository and convert it.

Sorry for not being able to give you more help :(

RFGMM commented 1 year ago

bc-dl.sh

! /bin/bash

if ! [[ $1 =~ https?://..bandcamp.com. ]]; then echo "Use a valid bandcamp's URL..." else AAName=$(yt-dlp --get-filename --playlist-items 1 -o '%(artist)s-%(album)s' --output-na-placeholder '' $1) FixedAAName=${AAName// /-} echo $FixedAAName mkdir $FixedAAName

yt-dlp -o "$FixedAAName/%(artist)s-%(album)s-%(playlist_index)s-%(track)s.%(ext)s" $1

yt-dlp -o "$FixedAAName/%(playlist_index)s-%(track)s.%(ext)s" $1 fi

mdbc-dl.sh

! /bin/bash

listfilename=$(date +%F%H%M) finalfilename=$(echo $RANDOM) url=$1 if ! [[ $1 =~ https?://..bandcamp.com. ]]; then echo "Use a valid bandcamp's URL..." else wget --convert-links $url -O /tmp/$listfilename.txt cat /tmp/$listfilename.txt | grep -e "/album" -e "/track/" |sed -n 's/.href="([^"]).*/\1/p' > /tmp/$finalfilename.txt wc -l /tmp/$listfilename.txt rm /tmp/$listfilename.txt wc -l /tmp/$finalfilename.txt LINES=$(cat /tmp/$finalfilename.txt) for LINE in $LINES do bc-dl $LINE done rm /tmp/$finalfilename.txt fi