-
Notifications
You must be signed in to change notification settings - Fork 0
/
hiDownloader.rb
79 lines (57 loc) · 1.78 KB
/
hiDownloader.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require("JSON")
require("net/http")
require 'open-uri'
require 'colorize'
def Hiribe
def Hiribe.downloader
#Menu
puts 'Cherry NSFW Tools| Hiribe Downloader'.red
#Ask the user for the tags
puts 'Introduzca a continuacion los tags a descargar:'
tags = gets.chomp
tags = tags.gsub(' ', '%20')
#Ask the user for the initial page
puts 'Introduzca a continuacion la pagina donde empezar a descargar:'
page = gets.chomp
if page == '0'
page == '1'
end
puts 'Se iniciara a descargar desde la pagina ' + page
#Ask the user for the initial post limit
puts 'Introduzca a continuacion el limite de posts a descargar:'
limit = gets.chomp
if limit == '0'
limit == '1'
end
puts 'Limite establecido en ' + limit
#Obtencion de datos
url = 'https://hijiribe.donmai.us/posts.json' + '?limit=' + limit + 'page=' + page + '?tags=' + tags + '&json=1'
puts url
uri = URI(url)
response = Net::HTTP.get(uri, {'User-Agent' => 'tag_downloader'})
json_hash = JSON.parse(response)
#puts json_hash[0]["id"]
#puts json_hash.length
for i in (0..json_hash.length()-1)
id = json_hash[i]["id"].to_s
puts"Iniciando la descarga del post #" + id
#puts the number of the image starting by 0
puts i
#Gets the url of the image
url = json_hash[i]["file_url"]
puts 'Link del archivo: ' + url
#gets the extension
extension = url.split('.')[3]
destination = '/downloads/other/Hiribe/' + id + '.' + extension
open(Dir.pwd() + destination, 'wb') do |fo|
fo.write URI.open(url).read
end
#download the file
puts 'Post descargado satisfactoriamente'.green
end
puts 'presiona [ENTER] para volver a CherryCMD'
gets
system ('cls')
require('.\Cherry.rb')
end
end