<commit_before>class Bandcamp < Plugin

    def init(init)
        @bot = init
        if ( @bot[:mpd] != nil ) && ( @bot[:messages] != nil ) && ( @bot[:bandcamp] == nil )
            begin
                @bandcampfolder = @bot[:mpd_musicfolder] + @bot[:bandcamp_downloadsubdir]
                @tempbandcampfolder = @bot[:main_tempdir] + @bot[:bandcamp_tempsubdir]
                
                Dir.mkdir(@bandcampfolder) unless File.exists?(@bandcampfolder)
                Dir.mkdir(@tempbandcampfolder) unless File.exists?(@tempbandcampfolder)
            rescue
                puts "Error: bandcamp-Plugin didn't found settings for mpd music directory and/or your preferred temporary download directory"
                puts "See pluginbot_conf.rb"
            end
            begin
                @ytdloptions = @bot[:bandcamp_youtubedl_options]
            rescue
                @ytdloptions = "" 
            end
            @consoleaddition = "" 
            @consoleaddition = @bot[:bandcamp_commandlineprefixes] if @bot[:bandcamp_commandlineprefixes] != nil
            @songlist = Queue.new
            @keylist = Array.new
            @bot[:bandcamp] = self
        end
        @filetypes= ["ogg", "mp3", "mp2", "m4a", "aac", "wav", "ape", "flac"]
        return @bot
    end

    def name
        if ( @bot[:mpd] == nil ) || ( @bot[:bandcamp] == nil)
            "false"
        else    
            self.class.name
        end
    end

    def help(h)
        h += "<hr><span style='color:red;'>Plugin #{self.class.name}</span><br />"
        h += "<b>#{@bot[:controlstring]}bandcamp <i>URL</i></b> - Will try to download the music from the given URL."
    end

    def handle_chat(msg, message)
        if message.start_with?("bandcamp <a href=") || message.start_with?("<a href=") then
            link = msg.message[msg.message.index('>') + 1 .. -1]
            link = link[0..link.index('<')-1]<commit_msg>add bandwidth hint in help message<commit_after>class Bandcamp < Plugin

    def init(init)
        @bot = init
        if ( @bot[:mpd] != nil ) && ( @bot[:messages] != nil ) && ( @bot[:bandcamp] == nil )
            begin
                @bandcampfolder = @bot[:mpd_musicfolder] + @bot[:bandcamp_downloadsubdir]
                @tempbandcampfolder = @bot[:main_tempdir] + @bot[:bandcamp_tempsubdir]
                
                Dir.mkdir(@bandcampfolder) unless File.exists?(@bandcampfolder)
                Dir.mkdir(@tempbandcampfolder) unless File.exists?(@tempbandcampfolder)
            rescue
                puts "Error: bandcamp-Plugin didn't found settings for mpd music directory and/or your preferred temporary download directory"
                puts "See pluginbot_conf.rb"
            end
            begin
                @ytdloptions = @bot[:bandcamp_youtubedl_options]
            rescue
                @ytdloptions = "" 
            end
            @consoleaddition = "" 
            @consoleaddition = @bot[:bandcamp_commandlineprefixes] if @bot[:bandcamp_commandlineprefixes] != nil
            @songlist = Queue.new
            @keylist = Array.new
            @bot[:bandcamp] = self
        end
        @filetypes= ["ogg", "mp3", "mp2", "m4a", "aac", "wav", "ape", "flac"]
        return @bot
    end

    def name
        if ( @bot[:mpd] == nil ) || ( @bot[:bandcamp] == nil)
            "false"
        else    
            self.class.name
        end
    end

    def help(h)
        h += "<hr><span style='color:red;'>Plugin #{self.class.name}</span><br />"
        h += "<b>#{@bot[:controlstring]}bandcamp <i>URL</i></b> - Will try to download the music from the given URL. Be aware that due to bandwidth limitations from bandcamp the bot downloads with the a maximum speed that is slightly higher than the streaming speed. Please be patient if you let the bot download a whole album :)"
    end

    def handle_chat(msg, message)
        if message.start_with?("bandcamp <a href=") || message.start_with?("<a href=") then
            link = msg.message[msg.message.index('>') + 1 .. -1]
            link = link[0..link.index('<')-1]
{'fraction_non_alphanumeric': 0.13201561737432893, 'fraction_numerical': 0.003416300634455832, 'mean_word_length': 2.0475836431226764, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5789293', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1187, 'n_words': 295}