reddit_junkie 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bf9332f49d111893f8c801b93cf60f79a2088c8a620fa64e1361694f782083e
4
- data.tar.gz: bc19ef859e507fd81f087024171cc94add4cf650285ffb8f3d887f1474a90940
3
+ metadata.gz: 71920776834b7262d6b3b0cf592182003a567d15f83559999f8f99c24801dcbb
4
+ data.tar.gz: 831af04ddea38a9b74785f9bc6fe0f4453a60456346cd1cf6ffa863d69630a46
5
5
  SHA512:
6
- metadata.gz: 8e50f8f4c71c85bf5dc6e95383e9dfa89c06ebd2b206e95467d55536421528bdff44ba28f54fb01f9eb9e5210f0f365da96ffef96c3cfed88454c04bcdb04953
7
- data.tar.gz: 4c7e31570882d3e412e3942732fd49656eca7613b9344d5d4bff709f5389f19b641c9521564e0ad0db41de1e6d25601817914812abe6c6576c96a52834d3c581
6
+ metadata.gz: a3310ef9a57516b653040fc0716badb935556a4a96135dbd0981a47acacc6efcf2ba6c1f452dce8b1ec09837dab5c50804b1581a4e2da3f7ff2df2062b50fd58
7
+ data.tar.gz: 4502f95c1b14e75c6c20f0440cd6dbd05a7bd99fe3f66dada47f8b031e21183b520852441d195fd7904a879c5da3ee9fdc6999a23d61bc51ad6b33014756aae9
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require_relative '../lib/reddit_junkie.rb'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+
8
+ OptionParser.new do |option|
9
+ option.on("--subreddit SUB")
10
+ option.on("--directory DIR")
11
+ option.on("--count COUNT")
12
+ option.on("--endpoint ENDPOINT")
13
+ end.parse!(into: options)
14
+
15
+ if options[:subreddit] && options[:count] && options[:directory]
16
+ count = options[:count].to_i
17
+ if count%100 == 0
18
+ count_max = count / 100
19
+ count_min = 0
20
+ r = RedditImage.new(options[:subreddit], options[:count].to_i, options[:directory])
21
+ while count_min < count_max do
22
+ puts "Iteration No. #{count_min + 1}"
23
+ r.download_images
24
+ r.get_info
25
+ r.update_data
26
+ count_min += 1
27
+ end
28
+ else
29
+ r = RedditImage.new(options[:subreddit], options[:count].to_i, options[:directory])
30
+ r.download_images
31
+ end
32
+ elsif options[:subreddit] && options[:count]
33
+ count = options[:count].to_i
34
+ if count%100 == 0
35
+ count_max = count / 100
36
+ count_min = 0
37
+ r = RedditImage.new(options[:subreddit], options[:count].to_i)
38
+ while count_min < count_max do
39
+ puts "Iteration No. #{count_min + 1}"
40
+ r.download_images
41
+ r.get_info
42
+ r.update_data
43
+ count_min += 1
44
+ end
45
+ else
46
+ r = RedditImage.new(options[:subreddit], options[:count].to_i)
47
+ r.download_images
48
+ end
49
+ elsif options[:subreddit]
50
+ r = RedditImage.new(options[:subreddit])
51
+ r.download_images
52
+ end
@@ -77,7 +77,7 @@ class RedditImage
77
77
 
78
78
  links.each do |link|
79
79
  if link != nil
80
- file_name = "#{file_name_base}"
80
+ file_name = "#{file_name_base}.jpg"
81
81
  final_image = File.open(file_name, "wb")
82
82
  final_image.write(HTTParty.get(link))
83
83
  puts "Wrote on #{file_name}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_junkie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muhammadreza Haghiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -42,11 +42,13 @@ description: This little library helps people download images from different sub
42
42
  much easier. It's actually like a crawler for the images posted on a subreddit.
43
43
  Actually, it's a great tool to have your favorite memes locally!
44
44
  email: haghiri75@gmail.com
45
- executables: []
45
+ executables:
46
+ - reddit_junkie
46
47
  extensions: []
47
48
  extra_rdoc_files: []
48
49
  files:
49
50
  - Gemfile
51
+ - bin/reddit_junkie
50
52
  - lib/reddit_junkie.rb
51
53
  homepage: http://github.com/prp-e/reddit_image_downloader
52
54
  licenses: