Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bandcamp and Youtube-dl #6231

Open
NickWinston123 opened this issue Jul 14, 2015 · 13 comments
Open

Bandcamp and Youtube-dl #6231

NickWinston123 opened this issue Jul 14, 2015 · 13 comments

Comments

@NickWinston123
Copy link

@NickWinston123 NickWinston123 commented Jul 14, 2015

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
Copy link
Collaborator

@dstftw dstftw commented Jul 14, 2015

That is not supported. Only per album.

@djvs
Copy link

@djvs djvs commented Sep 10, 2016

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
Copy link

@stefanos82 stefanos82 commented Aug 28, 2017

@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
Copy link

@chimmel chimmel commented Jan 26, 2018

@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
Copy link

@stefanos82 stefanos82 commented Jan 26, 2018

@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
Copy link

@virtualbeck virtualbeck commented Feb 8, 2018

@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
Copy link

@lyz-code lyz-code commented Apr 7, 2020

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
Copy link

@v-fox v-fox commented Sep 23, 2020

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
Copy link

@Otiel Otiel commented Sep 23, 2020

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
Copy link

@gilou gilou commented Sep 23, 2020

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

@lyz-code
Copy link

@lyz-code lyz-code commented Sep 24, 2020

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

@mjlee2003
Copy link

@mjlee2003 mjlee2003 commented Oct 19, 2020

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

@lyz-code
Copy link

@lyz-code lyz-code commented Oct 20, 2020

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 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.