elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [RUBY] MP3Crank Leecher v0.2
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [RUBY] MP3Crank Leecher v0.2  (Leído 2,724 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
[RUBY] MP3Crank Leecher v0.2
« en: 18 Noviembre 2012, 08:27 am »

MP3Crank es una página web que actualizan constantemente con albums de muchos estilos... pop, rock, dance, electro, heavy metal, indie, folk, hiphop, r&b etc...
Yo personalmente descargo musica casi todos los días en esta página porque los enlaces están en "potload" y se descargan enseguida usando JDownloader.

La cuestión es que para acceder a un link de descarga primer hay que pasar por 3 páginas, así que para evitar ese tiempo de espera tán incómodo he decidido hacer este pequeño script que parsea las "X" primeras páginas de la página web y guarda los links en un archivo de texto...

Los enlaces que se listen se registran en un archivo log para que no se vuelvan a listar en el próximo uso del script.











- Se puede configurar el máximo de páginas a parsear.
- Se pueden excluir los albumes por "tags", en la configuración del script. por ejemplo si excluimos el tag "pop" no se listará ningún album de estilo pop.
NOTA: Tener en cuenta que muchos albumes de la página tienen varios tags, por ejemplo "pop, rock, indie", si el tag "pop" lo hemos excluido, ese album se omitirá tenga los otros tags que tenga.

- El archivo de salida que obtendremos es algo parecido a este:

Código:
Title   : Layo & Bushwacka! - Rising & Falling
Genre   : House, Techno
Year    : 2012
Page    : http://www.mp3crank.com/layo-bushwacka/rising-falling.htm
Download: http://potload.com/w34j2fem2bra


Title   : Press Gang Metropol - Checkpoint
Genre   : New Wave, Post-punk
Year    : 2012
Page    : http://www.mp3crank.com/press-gang-metropol/checkpoint.htm
Download: http://potload.com/dizvwuf3m3sy


Title   : Porcupine Tree - Octane Twisted (Live) (2CD)
Genre   : Progressive, Rock
Year    : 2012
Page    : http://www.mp3crank.com/porcupine-tree/octane-twisted-live-2cd.htm
Download: http://potload.com/7h1rld0rfz03


Title   : Nightwish - Imaginaerum (The Score)
Genre   : Symphonic Metal
Year    : 2012
Page    : http://www.mp3crank.com/nightwish/imaginaerum-the-score.htm
Download: http://potload.com/eqznab8d44uk


EXECUTABLE: http://exoshare.com/download.php?uid=1Z1TPBQO

MP3Crank.rb:
Código
  1. # -*- coding: UTF-8 -*-
  2.  
  3.  
  4. # MP3Crank Leecher v0.2
  5. #
  6. # By Elektro H@cker
  7.  
  8.  
  9. # Description:
  10. # -----------
  11. #
  12. # MP3Crank Leecher it's a tool that helps you to keep updated your music collection.
  13. #
  14. # This tool is intended for (almost) daily use.
  15. #
  16. # The script retreives all the downloadable links of the first "X" pages from the MP3Crank website,
  17. # And then list the links into a text file for use it with a download managaer like "JDownloader".
  18. #
  19. # All the links are stored permanently into a log file to be excluded at the next use,
  20. # (that's the reason why this tool is intended for daily use).
  21. #
  22. #
  23. # The pass for the links is: mp3crank.com
  24.  
  25.  
  26. require 'net/http'
  27. require 'win32/registry'
  28. require "highline/system_extensions"
  29. include HighLine::SystemExtensions
  30.  
  31.  
  32. exit if Object.const_defined?(:Ocra)
  33.  
  34.  
  35. def logo()
  36. puts "
  37. MP3CRANK Leecher v0.2
  38. By Elektro H@cker"
  39. end
  40.  
  41.  
  42. def main()
  43. puts "\n\n(Remember, the password for the links is: \"mp3crank.com\")\n\n[+] Press \"C\" to config or press any other key to start leeching..."
  44. key = get_character
  45. config("") if key.to_s =~ /^67$|^99$/
  46. get_downloads_list()
  47. puts "\n\n\n[+] All links are stored in: #{$mp3crank_leecherfile}\n\n(Remember, the password for the links is: \"mp3crank.com\")"
  48. exit
  49. end
  50.  
  51.  
  52. def get_settings()
  53. begin
  54. $mp3crank_logfile = regread("LOGFILEPATH")
  55. rescue
  56. $mp3crank_logfile = "#{ENV['WINDIR']}\\MP3Crank Leecher LOG.txt"
  57. end
  58.  
  59. begin
  60. $mp3crank_leecherfile = regread("LEECHERFILEPATH") +  "MP3Crank Leecher #{Time.new.strftime("%Y-%m-%d")}.txt"
  61. rescue
  62. $mp3crank_leecherfile = "#{ENV['USERPROFILE']}\\Desktop\\MP3Crank Leecher #{Time.new.strftime("%Y-%m-%d")}.txt"
  63. end
  64.  
  65. begin
  66. $max_pages = regread("MAXPAGES")
  67. $max_pages = $max_pages.to_i
  68. rescue
  69. $max_pages = 10
  70. end
  71.  
  72. begin
  73. $excluded_tags = regread("EXCLUDED TAGNAMES")
  74. rescue
  75. $excluded_tags = ""
  76. end
  77.  
  78. end
  79.  
  80.  
  81. def config(errorcode)
  82.  
  83. puts "
  84. º---------------------------------º---------------------------------º
  85. | [1] Set the log file path       | [S] Show the current settings   |
  86. | [2] Set the leecher file path   | [R] Reset the settings          |
  87. | [3] Delete the log file         | [Z] Backup all the settings     |
  88. |---------------------------------|---------------------------------|
  89. | [M] Max. Pages to parse         |                                 |
  90. | [T] Tagnames to exclude         | [E] Exit                        |
  91. º---------------------------------º---------------------------------º
  92. "
  93. get_settings()
  94. puts errorcode
  95.  
  96. keystr = "NOTHING"
  97. until keystr =~ /^49$|^50$|^51$|^69$|^80$|^82|^83$|^84$|^90$|^101$|^112$|^114$|^115$|^116$|^122$/
  98. print "\nChoose an option >> "
  99. key = get_character
  100. keystr = key.to_s
  101. end
  102.  
  103. # Log file path
  104. if key == 49
  105. logfilepath = "NOTHING"
  106. until File.directory?(logfilepath)
  107. print "\n\nEnter the path to an existing directory for the logfile: "
  108. logfilepath = STDIN.gets.chomp
  109. end
  110. if logfilepath[-1] == '\\' then logfilepath = logfilepath[0..-2] end
  111. regwrite("LOGFILEPATH", logfilepath + "\\MP3Crank Leecher LOG.txt")
  112. config("[+] Operation completed.")
  113. end
  114.  
  115. # Leecher file path
  116. if key == 50
  117. leecherfile = "NOTHING"
  118. until File.directory?(leecherfile)
  119. print "\n\Enter the path to an existing directory for the leecher file: "
  120. leecherfile = STDIN.gets.chomp
  121. end
  122. if not leecherfile[-1] == '\\' then leecherfile = leecherfile+"\\" end
  123. regwrite("LEECHERFILEPATH", leecherfile)
  124. config("[+] Operation completed.")
  125. end
  126.  
  127. # delete log file
  128. if key == 51
  129. filedel = "NOTHING"
  130. while not filedel =~ /^78$|^89$|^110$|^121$/
  131. print "\n\nWant to delete the log file, Are you sure? [Y/N]: "
  132. filedel = get_character.to_s
  133. end
  134. begin
  135. if filedel =~ /^89$|^121$/ then File.delete($mp3crank_logfile) end
  136. config("[+] Operation completed.")
  137. rescue
  138. config("\n\nERROR\n\nCan't find the logfile.")
  139. end
  140. end
  141.  
  142. # Max pages
  143. if key == 80 or key == 112
  144. maxpages = "NOTHING"
  145. puts "\n\nThis option lets you configure the maximum pages to leech..."
  146. until not maxpages[/[a-z]/i]
  147. print "\nEnter a number for the max pages value: "
  148. maxpages = STDIN.gets.chomp
  149. end
  150. regwrite("MAXPAGES", maxpages)
  151. config("[+] Operation completed.")
  152. end
  153.  
  154. # exclude tagnames
  155. if key == 84 or key == 116
  156. addtag = "NOTHING"
  157. puts "\n\nThis option lets you exclude albums by their genre tagnames..."
  158. until not addtag == "NOTHING"
  159. print "\n\nEnter a tagname (Example: \"Hip Hop\") \nor enter the word \"none\" to reset the exclusions: "
  160. addtag = STDIN.gets.chomp
  161. end
  162. begin
  163. tags=regread("EXCLUDED TAGNAMES")
  164. rescue
  165. tags=""
  166. end
  167. if addtag =~ /^none$/i then regwrite("EXCLUDED TAGNAMES", "") else regwrite("EXCLUDED TAGNAMES", "#{tags};#{addtag}") end
  168. config("[+] Operation completed.")
  169. end
  170.  
  171. # show the current settings
  172. if key == 83 or key == 115
  173. config("
  174.  
  175. Log file path       : #{$mp3crank_logfile}
  176.  
  177. Leecher file path   : #{$mp3crank_leecherfile}
  178.  
  179. Max. pages to parse : #{$max_pages} pages
  180.  
  181. Excluded tagnames   : #{$excluded_tags.gsub(";","|")}
  182.  
  183. ")
  184. end
  185.  
  186. # reset the settings
  187. if key == 114 or key == 82
  188. resetkey = "NOTHING"
  189. while not resetkey =~ /^78$|^89$|^110$|^121$/
  190. print "\n\nWant to reset all the settings, Are you sure? [Y/N]: "
  191. resetkey = get_character.to_s
  192. end
  193. if resetkey =~ /^89$|^121$/
  194. Win32::Registry::HKEY_CURRENT_USER.open("SOFTWARE\\MP3Crank Leecher\\", Win32::Registry::KEY_ALL_ACCESS) do |reg|
  195. reg['LOGFILEPATH'] = 'DELETE'
  196. reg.delete_value("LOGFILEPATH")
  197. reg['LEECHERFILEPATH'] = 'DELETE'
  198. reg.delete_value("LEECHERFILEPATH")
  199. reg['MAXPAGES'] = 'DELETE'
  200. reg.delete_value("MAXPAGES")
  201. reg['EXCLUDED TAGNAMES'] = 'DELETE'
  202. reg.delete_value("EXCLUDED TAGNAMES")
  203. end
  204. config("[+] Operation completed.")
  205. end
  206. end
  207.  
  208. # backup the settings
  209. if key == 90 or key == 122
  210. system %[ regedit /e \"%USERPROFILE%\\Desktop\\MP3Crank Leecher settings %DATE:/=-%.reg\" \"HKEY_CURRENT_USER\\Software\\MP3Crank Leecher\" ]
  211. config("\n\n[+] Settings stored in #{ENV['USERPROFILE']}\\Desktop\\MP3Crank Leecher settings.reg")
  212. end
  213.  
  214. # exit
  215. if key == 69 or key == 101 then main() end
  216.  
  217. end
  218.  
  219.  
  220. def show_info()
  221.  @info = "
  222.  
  223. Title   : #{@album_title}
  224. Genre   : #{@album_tags.to_s.gsub('\\t','').gsub(']','').gsub('[','').gsub('"','').gsub('nil','').gsub(', , ','')}
  225. Year    : #{@year}
  226. Page    : #{@album_page}
  227. Download: #{@potload_url}
  228.  
  229. "
  230.  puts @info
  231. end
  232.  
  233.  
  234. def get_downloads_list()
  235. @page = 0
  236. print "\n\n[+] Leeching pages "
  237. for i in 1..$max_pages do
  238. @page = @page+1
  239. @url  = "http://www.mp3crank.com/page/#{@page}"
  240. print "#{@page}/#{$max_pages}..."
  241. Net::HTTP.get_response(URI.parse(@url)).body.split('<!--/centercol -->').first.split('<div id="centercol">').last.each_line do |line|
  242.  
  243. if (line['class="release"']) then @downloadable = "yes" end
  244.  
  245. if line['class="year"'] then @year = line.split('</').first.split('>').last end
  246.  
  247. if line['class="genres"']
  248. for tag in line.split('rel="tag">').each do
  249. @album_tags = @album_tags, tag.split('<').first.gsub('&amp;','&')
  250. for excluded_tag in $excluded_tags.split(";").each do
  251. if not excluded_tag == "" and tag.split('<').first.to_s.chomp[/^#{Regexp.escape(excluded_tag)}$/i] then @downloadable = "no" end
  252. end
  253. end
  254. end
  255.  
  256. if line['class="album"']
  257. @album_title   = line.split('title="').last.split('">').first.gsub('Free MP3 download ','').gsub('&amp;','&')
  258. @album_page    = line.split('" rel=').first.split('"').last
  259. @download_page = Net::HTTP.get_response(URI.parse(@album_page)).body[/http:\/\/www.mp3crank.com\/download\/album\/[0-9]+/i]
  260. @potload_url   = Net::HTTP.get_response(URI.parse(@download_page)).body[/http:\/\/potload.com\/[a-z0-9]+/i]
  261. if @downloadable == "yes"
  262. filewrite()
  263. end
  264. @album_tags  = nil
  265. end
  266.  
  267. end
  268. end
  269. end
  270.  
  271.  
  272. def regread(keyname)
  273. Win32::Registry::HKEY_CURRENT_USER.open("SOFTWARE\\MP3Crank Leecher\\") do |reg| reg[keyname] end
  274. end
  275.  
  276.  
  277. def regwrite(keyname, value)
  278. Win32::Registry::HKEY_CURRENT_USER.create("SOFTWARE\\MP3Crank Leecher\\") do |reg| reg[keyname, Win32::Registry::REG_SZ] = value end
  279. end
  280.  
  281.  
  282. def filewrite()
  283. if not File.exist?($mp3crank_logfile) then File.open($mp3crank_logfile, "w") do |write| write.puts "MP3Crack leeched URLs\n\n(Remember, the password for the links is: \"mp3crank.com\")\n\n" end end
  284. if not File.open($mp3crank_logfile, "r").read[@album_page]
  285. show_info()
  286. File.open($mp3crank_logfile,     "a+") do |write| write.puts @album_page end
  287. File.open($mp3crank_leecherfile, "a+") do |write| write.puts @info end
  288. end
  289. end
  290.  
  291.  
  292. logo()
  293. get_settings()
  294. main()
  295.  
  296.  
  297.  


« Última modificación: 18 Noviembre 2012, 09:00 am por EleKtro H@cker » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ruby
Programación General
¡Micronet! 2 3,088 Último mensaje 18 Octubre 2010, 22:49 pm
por ¡Micronet!
[RUBY] SoundCloud Leecher v0.5 (Manten al día tu colección de música!)
Scripting
Eleкtro 6 4,995 Último mensaje 17 Noviembre 2012, 08:44 am
por Eleкtro
[SOURCE] Post-Hardcore.ru Leecher
.NET (C#, VB.NET, ASP)
Eleкtro 8 5,523 Último mensaje 29 Abril 2015, 00:29 am
por Eleкtro
[SOURCE] MP3Crank Leecher
.NET (C#, VB.NET, ASP)
Eleкtro 7 5,602 Último mensaje 15 Diciembre 2013, 18:58 pm
por Eleкtro
[SOURCE] Plixid Leecher
.NET (C#, VB.NET, ASP)
Eleкtro 3 3,993 Último mensaje 29 Abril 2015, 00:29 am
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines