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

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


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

Mensajes: 9.818



Ver Perfil
[APORTE] [RUBY] Shack (Imageshack Uploader)
« en: 19 Marzo 2012, 15:18 pm »

SHACK
An Imageshack commandline uploader.

By Elektro H@cker.


Todas las tools y scripts que conozco para subir una imagen, como por ejemplo "shag" ya no funcionan por culpa de la developer key, Así que debido a la falta de un uploader para imageshack por línea de comandos he querido hacer este útil script.

Espero que os guste y si encontrais fallos o mejoras hagánmelo saber, Gracias.



IMPORTANTE:
Para usar este script necesitan obtener una developer key (No es un capricho mio), Simplemente rellenen este formulario y enseguida recibiran un email con la clave:
http://stream.imageshack.us/api/

Luego hay que introducirla (Una única vez) usando el script de tal forma:
Código:
shack.rb -k "CLAVE"

Y ya podrán disfrutar del libre uso de este script.  ;D



Citar
Modo de empleo:
 shack.rb [Opción] [Imagen]

Ejemplo:
 shack.rb -d C:\Test.jpg

Opciones:
 -a --all
      Devuelve el enlace de la imagen en todos los formatos.
 -b --bb
      Devuelve el enlace de la imagen en formato BB.
 -d --directo
      Devuelve el enlace directo a la imagen.
 -h --html
      Devuelve el enlace de la imagen en formato HTML.
 -t --thumb
      Devuelve el thumb de la imagen.
 -k --key
      Establece su Developer key.
 /?   Muestra esta ayuda.





Código
  1. # -*- coding: UTF-8 -*-
  2.  
  3.  
  4.  
  5. # Modulos
  6.  
  7. require 'rest_client'
  8. exit if Object.const_defined?(:Ocra)
  9.  
  10.  
  11.  
  12. # Metodos
  13.  
  14. def logo()
  15.  print "
  16.     @@
  17.    @   @                  
  18.   @    @      @@@   @@@  @   @
  19.    @   @         @ @   @ @  @
  20.     @  @ @@      @ @     @ @
  21.      @ @@  @  @@@@ @     @@
  22.      @ @   @ @   @ @     @ @
  23.  @  @  @   @ @   @ @   @ @  @
  24.   @@   @   @  @@@@  @@@  @   @
  25.  
  26.  
  27.                                By Elektro H@cker\n\n"
  28. end
  29.  
  30. def help()
  31.  print "\n Modo de empleo:\n\n"
  32.  print "  " + __FILE__.split('/').last + " [Opci\u00F3n] [Imagen]\n\n"
  33.  print "\n Ejemplo:\n\n"
  34.  print "  " + __FILE__.split('/').last + " -d C:\\Test.jpg \n\n"
  35.  print "\n Opciones: \n\n"
  36.  print "  -a --all \n       Devuelve el enlace de la imagen en todos los formatos. \n\n"
  37.  print "  -b --bb \n       Devuelve el enlace de la imagen en formato BB. \n\n"
  38.  print "  -d --directo \n       Devuelve el enlace directo a la imagen. \n\n"
  39.  print "  -h --html \n       Devuelve el enlace de la imagen en formato HTML. \n\n"
  40.  print "  -t --thumb \n       Devuelve el thumb de la imagen. \n\n"
  41.  print "  -k --key \n       Establece su Developer key. \n\n"
  42.  print "  /?   Muestra esta ayuda. \n\n"
  43.  Process.exit
  44. end
  45.  
  46. def keycode(imput)
  47. if ARGV[1] == () or not imput.length.eql? 40
  48.   puts "\n Porfavor introduzca una developer key válida..."
  49.   puts "\n Ejemplo:\n\n " + __FILE__.split('/').last + " --key 148CAPSV9465b858a45dc1b4cdb32dee95ff6f59 \n\n"
  50.   puts "\n Para más información, Visite: http://stream.imageshack.us/api/"
  51.   Process.exit
  52.  end # length
  53.  
  54. if File.exist?("key")
  55.   oldkey = File.read('key')
  56.   print "\n ¿Desea reemplazar el archivo que contiene su developer key?\n\n"
  57.   print " Clave anterior: " + oldkey
  58.   print "\n Clave nueva   : " + imput
  59.   print  "\n\n [SI/NO] \n\n>> "
  60.   $sino = STDIN.gets
  61.    if $sino[/si/i]
  62.      keyfile = File.new("key", "w")
  63.      keyfile.print(imput)
  64.      print "\nClave reemplazada correctamente.\n"
  65.    elsif $sino[/no/i]
  66.      Process.exit
  67.    elsif
  68.      keycode(imput)
  69.    end # Reemplazar
  70.  else
  71.      keyfile = File.new("key", "w")
  72.      keyfile.print(imput)
  73.      print "\nClave configurada correctamente.\n"
  74. end # File exist
  75. end
  76.  
  77. def subir(file)
  78. print "\n Subiendo la imagen, Espere...\n\n"
  79. $Imagen = RestClient.post('http://www.imageshack.us/upload_api.php',
  80.   :key => $devkey,
  81. #  :a_username => "USUARIO",
  82. #  :a_password => "PASSWORD",
  83.   :fileupload => File.new(file)
  84. )
  85. end
  86.  
  87. def show(opcion)
  88.  if opcion == "-d" or opcion == "--directo"
  89.    print $Imagen.split("<image_link>").last.split("</image_link>").first + "\n"
  90.  elsif opcion == "-b" or opcion == "--bb"
  91.    print $Imagen.split("<image_bb>").last.split("</image_bb>").first + "\n"
  92.  elsif opcion == "-h" or opcion == "--html"
  93.    print $Imagen.split("<image_html>").last.split("</image_html>").first.gsub("&gt;", ">").gsub("&lt;", "<").gsub("&quot;", "'") + "\n"
  94.  elsif opcion == "-t" or opcion == "--thumb"
  95.    print $Imagen.split("<thumb_link>").last.split("</thumb_link>").first + "\n"
  96.  elsif opcion == "-a" or opcion == "--all"
  97.    print "\nDirecto: \n" + $Imagen.split("<image_link>").last.split("</image_link>").first + "\n\n"
  98.    print "BB Forum: \n" + $Imagen.split("<image_bb>").last.split("</image_bb>").first + "\n\n"
  99.    print "HTML: \n" + $Imagen.split("<image_html>").last.split("</image_html>").first.gsub("&gt;", ">").gsub("&lt;", "<").gsub("&quot;", "'") + "\n\n"
  100.    print "Thumb: \n" + $Imagen.split("<thumb_link>").last.split("</thumb_link>").first + "\n"
  101.  end
  102. Process.exit
  103. end
  104.  
  105.  
  106.  
  107. # Control de errores
  108.  
  109. logo()
  110.  
  111. if ARGV[0] == "-k" or ARGV[0] == "--key"
  112.  keycode(ARGV[1])
  113.  Process.exit
  114. end
  115.  
  116. if not File.exist?("key")
  117.  print "\n ERROR.   Debe configurar su developer key para usar este programa...\n"
  118.  puts "\n Ejemplo:\n\n " + __FILE__.split('/').last + " --key 148CAPSV9465b858a45dc1b4cdb32dee95ff6f59 \n\n"
  119.  puts "\n Para más información, Visite: http://stream.imageshack.us/api/"
  120.  Process.exit
  121. elsif
  122.  $devkey = File.read('key')
  123. end
  124.  
  125. if (ARGV.empty?) or ARGV[0] == "/?"
  126.  help()
  127. end
  128.  
  129. if (ARGV[1])==()
  130.  print "\n ERROR.   Debe introducir la ruta local de la imagen...\n"
  131.  Process.exit
  132. end
  133.  
  134. if not File.exist?(ARGV[1])
  135.  print "\n ERROR.   La imagen no existe...\n"
  136.  Process.exit
  137. elsif not (ARGV[1].split('.').last)[/bmp\z/i] and not (ARGV[1].split('.').last)[/bmp\z/i] and not (ARGV[1].split('.').last)[/gif\z/i] and not (ARGV[1].split('.').last)[/ico\z/i] and not (ARGV[1].split('.').last)[/jpg\z/i] and not (ARGV[1].split('.').last)[/jpeg\z/i] and not (ARGV[1].split('.').last)[/png\z/i] and not (ARGV[1].split('.').last)[/tif\z/i] and not (ARGV[1].split('.').last)[/tiff\z/i]
  138.    print "\n ERROR.   Archivo de imagen no soportado...\n"
  139.    print "\n Formatos soportados: .BMP, .GIF, .ICO, .JPG, .JPEG, .PNG, .TIF, .TIFF\n"
  140.  Process.exit
  141. end
  142.  
  143. if not ARGV[0] == "-d" and not ARGV[0] == "--directo" and not ARGV[0] == "-a" and not ARGV[0] == "--all" and not ARGV[0] == "-b" and not ARGV[0] == "--bb" and not ARGV[0] == "-h" and not ARGV[0] == "--html" and not ARGV[0] == "-t" and not ARGV[0] == "--thumb"
  144.  print "\n ERROR.   Opcion incorrecta...\n\n"
  145.  print " Use la opcion [/?] para mostrar la ayuda. \n\n"
  146.  print " " +__FILE__.split('/').last +  " /?  \n"
  147.  Process.exit
  148. end
  149.  
  150.  
  151.  
  152. # Proceso
  153.  
  154. subir(ARGV[1])
  155. show(ARGV[0])


« Última modificación: 21 Marzo 2012, 16:05 pm 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
[APORTE] [BATCH] Shack (Imageshack Uploader)
Scripting
Eleкtro 5 3,971 Último mensaje 18 Octubre 2012, 04:34 am
por Eleкtro
[RUBY] [WINDOWS] IShack v1.4 (ImagesHack Uploader) ...(24/10/2012)
Scripting
Eleкtro 6 5,426 Último mensaje 27 Octubre 2012, 00:33 am
por Garcad
[Perl] Imageshack Uploader 0.1
Scripting
BigBear 0 1,569 Último mensaje 14 Mayo 2013, 20:11 pm
por BigBear
[Delphi] ImageShack Uploader 0.1
Programación General
BigBear 2 1,836 Último mensaje 12 Octubre 2013, 01:43 am
por BigBear
[Delphi] ImageShack Uploader 0.3
Programación General
BigBear 0 1,493 Último mensaje 2 Mayo 2014, 23:01 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines