Quantcast
Channel: Comunidad Underground Hispana
Viewing all articles
Browse latest Browse all 11602

[RUBY] SoundCloud Leecher v0.1 (Manten al día tu colección de música!)

$
0
0
SoundCloud Leecher v0.3
By Elektro H@cker









SoundCloud Leecher es una herramienta que te ayudará a mantener al día tu colección de música.

Esta utilidad está pensada para un uso (casi) diario o semanal.

El script obtiene todos los enlaces descargables de las primeras "X" páginas de "X" grupo de Soundcloud, y guarda esos enlaces en un archivo de texto para usarlos más tarde con un gestor de descargas como por ejemplo "JDownloader".

Además, todos los enlaces se listan también en un archivo log para que queden excluidos en el próximo uso del script, esa es la razón de porqué está pensado para el uso diario.

Es muy fácil de configurar, mirar la información dentro del script.

Espero que a alguien más que a mi le sirva de ayuda. ::)

Un saludo!





Executable: Exoshare - Download - SoundCloud Leecher.rar


Soundcloud Leecher.rb:
Código:

# -*- coding: UTF-8 -*-


# SoundCloud Leecher v0.3
#
# By Elektro H@cker


# Description:
# -----------
#
# SoundCloud Leecher it's a tool that helps you to keep updated your music collection.
#
# This tool is intended for (almost) daily use.
#
# The script retreives all the downloadable links of the first "X" pages from a "X" group of SoundCloud,
# And then list the links into a text file for use it with a download magaer like "JDownloader".
#
# All the links are listed too into a log file to be excluded at the next use,
# that's the reason why this tool is intended for daily use.


# Info:
# ----
#
# SoundCloud unfortunately do not have a date search mode,
# which would be much easier to search/sort by "music style + today's date" than "groups + first sorted pages",
# The site has an advanced search engine that can search by "release date" but that is not the same than "uploaded date",
# So i think the only way to sort by date is by entering a group page because it shows the content sorted by the last date.


# How to use:
# ----------
#
# Configure your favorite groups and the max pages by entering into the configuration menu.
#
# end #


require 'net/http'
require 'win32/registry'
require "highline/system_extensions"
include HighLine::SystemExtensions


exit if Object.const_defined?(:Ocra)


def logo()
    puts '

 SoundCloud Leecher v0.3

 By Elektro H@cker
 '
end


def config()

    puts "
--------------------------------------------------------------º
 [1] Set the log file path  | [3] Set the leecher file path  |
 [2] Delete the log file    | [4] Delete today's leeched file |
----------------------------|---------------------------------|
 [A] Add a group name      | [P] Set the max pages to parse  |
 [D] Delete a group name    |---------------------------------|
 [L] List the groups        | [Z] Backup all the settings    |
--------------------------------------------------------------º

"

    keystr = "NOTHING"
    until keystr =~ /^49$|^50$|^51$|^52$|^65$|^97$|^68$|^80$|^112$|^100$|^121$|^90$|^122$|^76$|^108$/
            print "\nChoose an option >> "
            key = get_character
            keystr = key.to_s
    end



    # Log file path
    if key == 49
        logfilepath = "NOTHING"
        until File.directory?(logfilepath)
            print "\n\nEnter a existing directory for the logfile: "
            logfilepath = STDIN.gets.chomp
        end
        regwrite("LOGFILEPATH", logfilepath + "\\Soundcloud LOG.txt")
        puts "ok"
    end

    # Delete log file
    if key == 50
        logfiledel = "NOTHING"
        while not logfiledel =~ /^78$|^89$|^110$|^121$/
            print "\n\nAre you sure? [Y/N]: "
            logfiledel = get_character.to_s
        end
        begin
            if logfiledel =~ /^89$|^121$/ then File.delete($logfile) end
            puts "ok"
        rescue
            puts "\n\nERROR\n\nCan't find the logfile."
        end
    end

    # Leecher file path
    if key == 51
        leecherfile = "NOTHING"
        until File.directory?(leecherfile)
            print "\n\nEnter a existing directory for the leecher file: "
            leecherfile = STDIN.gets.chomp
        end
        regwrite("LEECHERFILEPATH", leecherfile)
        puts "ok"
    end

    # delete leecher file
    if key == 52
        leecherfiledel = "NOTHING"
        while not leecherfiledel =~ /^78$|^89$|^110$|^121$/
            print "\n\nAre you sure? [Y/N]: "
            leecherfiledel = get_character.to_s
        end
        begin
            if leecherfiledel =~ /^89$|^121$/ then File.delete($leecherfile) end
            puts "ok"
        rescue
            puts "\n\nERROR\n\nCan't find the leecher file."
        end
    end

    # Add groupname
    if key == 65 or key == 97
        addname = "NOTHING"
        until not addname == "NOTHING"
            print "\n\nEnter a group name to add: "
            addname = STDIN.gets.chomp
        end
        begin
            groups=regread("GROUPS")
        rescue
            groups=""
        end
        regwrite("GROUPS", "#{groups};#{addname}")
        puts "ok"
    end

    # delete groupname
    if key == 68 or key == 100
        delname = "NOTHING"
        until not delname == "NOTHING"
            print "\n\nEnter a group name to delete: "
            delname = STDIN.gets.chomp
        end
        begin
            groups=regread("GROUPS")
        rescue
            groups=""
        end
        for groupname in regread("GROUPS").split(";") do
            finalgroups="#{finalgroups};#{groupname}" if not groupname =~ /^#{Regexp.escape(delname)}$/i   
        end
        regwrite("GROUPS", finalgroups[1..-1])
        puts "ok"
    end

    # list groupnames
    if key == 76 or key == 108
        puts "\n\n"
        for name in $groups.split(";").each do puts name end
    end

    # Max pages
    if key == 80 or key == 112
        maxpages = "NOTHING"
        until not maxpages[/[a-z]/i]
            print "\n\nEnter a number for the max pages value: "
            maxpages = STDIN.gets.chomp
        end
        regwrite("MAXPAGES", maxpages)
        puts "ok"
    end

    # backup the settings
    if key == 90 or key == 122
        system %[ regedit /e \"%USERPROFILE%\\Desktop\\Soundcloud settings %DATE:/=-%.reg\" \"HKEY_CURRENT_USER\\Software\\Soundcloud Leecher\" ]
        puts "\n\n[+] Settings stored in #{ENV['USERPROFILE']}\\Desktop\\SoundCloud settings.reg"
    end

    Process.exit
end


def regread(keyname)
    Win32::Registry::HKEY_CURRENT_USER.open("SOFTWARE\\Soundcloud Leecher\\") do |reg| reg[keyname] end
end


def regwrite(keyname, value)
    Win32::Registry::HKEY_CURRENT_USER.create("SOFTWARE\\Soundcloud Leecher\\") do |reg| reg[keyname, Win32::Registry::REG_SZ] = value end
end


def filewrite(group)
    if not File.exist?($logfile) then File.open($logfile, "w") do |write| write.puts "SoundCloud downloaded URLs - log" end end
    if not File.open($logfile, "r").read[@download_url]
        File.open($logfile,    "a+") do |write| write.puts @download_url end
        File.open($leecherfile, "a+") do |write| write.puts "Added at #{Time.new.strftime("%H:%M")}: #{@download_url}" end
    end
end


def get_downloads_list()
    for name in $groups.split(";").each do
        @group = name.chomp
        @page  = 0
        print "\n\n[+] Group: #{@group}\n[+] Leeching pages "
        for i in 1..$max_pages.to_i do
            @page  = @page+1
            @url  = "http://soundcloud.com/groups/#{@group}/tracks?page=#{@page}"
            print "#{@page}/#{$max_pages}..."
            Net::HTTP.get_response(URI.parse(@url)).body.each_line do |line|
                if (line["button download"]) and not (line[/session/i]) and not (line[/preview/i])
                    @download_url = "http://soundcloud.com#{line.split('href="').last.split('"').first}\n"
                    filewrite(@group)
                end
            end
        end
    end
end


begin
  $max_pages=regread("MAXPAGES")
rescue
  $max_pages=5
end

begin
  $logfile=regread("LOGFILEPATH")
rescue
  $logfile="#{ENV['WINDIR']}\\Soundcloud LOG.txt"
end

begin
  $leecherfile=regread("LEECHERFILEPATH") +  "\\Soundcloud Leecher #{Time.new.strftime("%Y-%m-%d")}.txt"
rescue
  $leecherfile="#{ENV['USERPROFILE']}\\Desktop\\Soundcloud Leecher #{Time.new.strftime("%Y-%m-%d")}.txt"
end

begin
    $groups=regread("GROUPS")
rescue
    $groups=""
end


logo()
puts "\n[+] Press \"C\" to config or press any other key to start leeching..."
key = get_character
if key == 67 or key == 99 then config() end
get_downloads_list()
puts "\n\n\n[+] All links are stored in: #{$leecherfile}"


__END__


Viewing all articles
Browse latest Browse all 11602

Trending Articles