AnimeDL 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 4c4ab79d1ef8cdd5e1358c92ea756e281050ca61
4
- data.tar.gz: 1d3a2171a534122c4d2c6a3f62b2cf6cc4112f7e
3
+ metadata.gz: 52febf6fdb8981cf896a688f8c64076b4cd761aa
4
+ data.tar.gz: 518aa6c64b9eb087522df785223ceaea46349365
5
5
  SHA512:
6
- metadata.gz: c8f5495fb0dbe795148c8ba90986607eae29105c1e497d79e11c1e62465531a9972d83093db6502704b1faf18105c5b340f1dff057ac3ad69b0c4785506be130
7
- data.tar.gz: 552eeff77729d8797cc6995d162db669ff5513664c1036360b272727ff4040a5300c3a7a0b880e993a58a8e6211dcd5c03aed01bae23b6c3fc384743dd594cf3
6
+ metadata.gz: 4dc8edc0b2f5d402b40a1643dfe2504a3d66d6c4b4f00b2ee6a4d4545de7eb3418cdedcdc0c7f44a4b3e6733601cfe50fbe24fa3319732438fb649dd5f65a1d5
7
+ data.tar.gz: 996c68554bab7013574b518a90562bb4024fb58cdd3590ff3d6c5337fe4f647ec11a4cf3068ccd68fd13c92de2fa8e39893dd319e64f7780c7321be11768c717
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AnimeDL
2
2
 
3
- <p align='center' style="width: 75%">
3
+ <p align='center'>
4
4
  <img src='https://github.com/anirudhsundar98/AnimeDL/raw/master/fmab_anime_dl.jpg' alt='FMAB Stone'>
5
5
  </p>
6
6
 
@@ -8,11 +8,12 @@ An app used to download anime episodes or get links to video sources of episodes
8
8
 
9
9
  ## Installation
10
10
 
11
-
12
11
  Install the application with:
13
12
 
14
13
  $ gem install AnimeDL
15
14
 
15
+ and run `anime-dl` on the command line.
16
+
16
17
 
17
18
  <br>
18
19
 
@@ -29,63 +30,49 @@ And then execute:
29
30
  ## Usage
30
31
 
31
32
  On running the command the program prompts the user for a search query and prints a list of search results.
32
- The user can then choose a particular anime. Details for all episodes are scraped.
33
- To select particular episodes call the app with the '-e' option.
33
+ On choosing a particular anime, the user can then choose to get links or download videos and choose which episodes to scrape.
34
34
 
35
35
 
36
36
  #### Links:
37
- To output links to a file, provide the path to a file as the last argument.
37
+ To output links to a file, provide the path to a file with '--file'.
38
38
  If argument is a directory, a new text file will be created in that directory.
39
+ If '--file' is not provided, links are printed on the command line.
39
40
 
40
41
  #### Downloads:
41
- To download videos to particular directory, specify the directory as the last argument.
42
- If no directory is specified the videos are downloaded to ./anime_name/
43
-
44
- ### Examples:
45
- `$ anime_dl` - (outputs link urls on the terminal)
46
- `$ anime_dl -f rel/path/to/filename.txt` - (outputs link urls to 'rel/path/to/filename.txt')
47
- `$ anime_dl -o link -f rel/path/to/directory/` - (outputs link urls to 'rel/path/to/directory/anime\_name.txt')
48
- `$ anime_dl -o download` - (downloads videos to './anime\_name/')
49
- `$ anime_dl -o download -f .` - (downloads videos to './')
50
- `$ anime_dl -o d -f /abs/path/to/directory` - (downloads videos to '/abs/path/to/directory/anime\_name/')
51
- `$ anime_dl -o download -f /abs/path/to/directory/` - (downloads videos to '/abs/path/to/directory/anime\_name/')
52
-
53
- ### Example App Usage:
54
- ```
55
- $ anime_dl -q
56
- Enter Search Query: fullmetal alchemist b
42
+ To download videos to particular directory, specify the directory with '--file'.
43
+ If no directory is specified the videos are downloaded to ./anime_name/
57
44
 
58
- 0. (Exit)
59
- 1. Fullmetal Alchemist Brotherhood Dubbed | Hagane no Renkinjutsushi (2009) Dubbed
60
- 2. Fullmetal Alchemist Brotherhood | Hagane no Renkinjutsushi (2009)
61
- 3. (Enter new Search Query)
45
+ ### Example Usage:
46
+ (If user chooses to scrape LINKS)
62
47
 
63
- Choice: 4
48
+ `$ anime-dl` - (outputs link urls on the terminal)]
49
+ `$ anime-dl -f path/to/filename.txt` - (outputs link urls to './path/to/filename.txt')]
50
+ `$ anime-dl -f path/to/directory/` - (outputs link urls to './path/to/directory/anime_name.txt')]
64
51
 
65
- (Empty response gets all episodes, '-1' exits)
52
+ (If user chooses to DOWNLOAD videos)
66
53
 
67
- Total number of Episodes - 64 (1-64)
68
- Episodes: -1
69
- ```
54
+ `$ anime-dl` - (downloads videos to './anime_name/')]
55
+ `$ anime-dl -f .` - (downloads videos to './')]
56
+ `$ anime-dl -f /path/to/directory` - (downloads videos to '/path/to/directory/anime_name/')]
57
+ `$ anime-dl -f /path/to/directory/` - (downloads videos to '/path/to/directory/anime_name/')]
70
58
 
71
59
 
72
60
  ### Specifying Episodes:
73
61
  When the '-a' option is not provided, the app asks for 'Episodes' after retrieving the user's anime choice.
74
62
  The user can provide induvidual space-seperated episodes.
75
63
  The user can also provide multiple space-seperated ranges with each range having the format 'start-end'.
76
- Below are a few examples (assuming anime has more than 18 episodes).
64
+ Below are a few examples (assuming anime below has more than 18 episodes).
77
65
  `Episodes: 2 4 5` - Retrieves details for episodes 2, 4 and 5
78
66
  `Episodes: 4-8` - Retrieves details for episodes 4 to 8
79
67
  `Episodes: 8-l` - Retrieves details for episodes 8 to the last episode
80
68
  `Episodes: 2 9-13 18-l` - Retrieves details for episodes 2, 9 to 13 and 18 to end
81
69
 
82
70
  ### Other options
83
- Run `$ anime_dl -h` for the list of all options.
71
+ Run `$ anime-dl -h` for the list of all options.
84
72
 
85
73
  ## Limitations
86
74
  The page being scraped from, "animeheaven.eu", only allows a certain number of page views per day (>150, <300).
87
- Once that limit is exceeded, you will have to change networks or try again in 24 hours.
88
-
75
+ Once that limit is exceeded, you will have to change networks or try again the next day.
89
76
 
90
77
 
91
78
  ## License
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "AnimeDL"
3
- spec.version = "0.1.7"
3
+ spec.version = "0.1.8"
4
4
  spec.authors = ["Anirudh Sundar"]
5
5
  spec.email = "anirudhsundar@hotmail.com"
6
6
 
@@ -4,11 +4,10 @@ require "optparse"
4
4
  require "fileutils"
5
5
 
6
6
  # APP OPTIONS
7
- options = { option: "link", episode: true, file: nil, quiet: false }
7
+ options = { episode: true, file: nil, quiet: false }
8
8
  help_statements = {
9
- option: %Q[Option (default: "link"). Values: "l" (or) "link", "d" (or) "download"],
10
9
  episode: %Q[Prevents the app from asking for an Episodes prompt. Gets detals for all episodes.],
11
- file: %Q[Provide location to store extracted details. Exits if path does not exist. (Usage Examples below).],
10
+ file: %Q[Provide location to store extracted details. Creates sub-directories as needed. (Usage Examples below).],
12
11
  quiet: %Q[Suppresses large, in-program help statements.],
13
12
  help: %Q[Shows this message and exits.],
14
13
  version: %Q[Prints version and exits.]
@@ -20,27 +19,18 @@ ARGV.options do |opts|
20
19
  opts.separator ""
21
20
  opts.separator "User can either download episodes or get links to video sources of episodes of a particular anime."
22
21
  opts.separator "On running the command the program prompts the user for a search query and prints a list of search results."
23
- opts.separator "The user can then choose a particular anime and choose which episodes to scrape."
22
+ opts.separator "On choosing a particular anime, the user can then choose to get links or download videos and choose which episodes to scrape."
24
23
  opts.separator ""
25
24
  opts.separator "Links: "
26
- opts.separator " To output links to a file, provide the path to a file as the last argument."
25
+ opts.separator " To output links to a file, provide the path to a file with '--file'."
27
26
  opts.separator " If argument is a directory, a new text file will be created in that directory."
27
+ opts.separator " If '--file' is not provided, links are printed on the command line."
28
28
  opts.separator "Downloads: "
29
- opts.separator " To download videos to particular directory, specify the directory as the last argument."
30
- opts.separator " If no directory is specified the videos are downloaded to ~/AnimeDL/anime_name/"
29
+ opts.separator " To download videos to particular directory, specify the directory with '--file'."
30
+ opts.separator " If no directory is specified the videos are downloaded to ./anime_name/"
31
31
  opts.separator ""
32
32
  opts.separator "Options:"
33
33
 
34
- opts.on("-o option", "--option=option", help_statements[:option]) do |option|
35
- unless (['l', 'link', 'd', 'download'].include? option)
36
- puts "Invalid argument to --option"
37
- puts %Q[Valid options: "l" (or) "link", "d" (or) "download"]
38
- exit
39
- end
40
-
41
- options[:option] = option
42
- end
43
-
44
34
  opts.on("-a", "--all", help_statements[:episode]) do
45
35
  options[:episode] = false
46
36
  end
@@ -55,7 +45,7 @@ ARGV.options do |opts|
55
45
 
56
46
 
57
47
  opts.on( "-v", "--version", help_statements[:version]) do
58
- puts "AnimeDL: 0.1.5"
48
+ puts "AnimeDL: Version 0.1.8"
59
49
  exit
60
50
  end
61
51
 
@@ -65,82 +55,35 @@ ARGV.options do |opts|
65
55
  end
66
56
 
67
57
  opts.separator ""
68
- opts.separator "Examples:"
69
- opts.separator %Q[ `$ anime_dl` (outputs link urls on the terminal)]
70
- opts.separator %Q[ `$ anime_dl -f rel/path/to/filename.txt` (outputs link urls to 'rel/path/to/filename.txt')]
71
- opts.separator %Q[ `$ anime_dl -o link -f rel/path/to/directory/` (outputs link urls to 'rel/path/to/directory/anime_name.txt')]
72
- opts.separator %Q[ `$ anime_dl -o download` (downloads videos to './anime_name/')]
73
- opts.separator %Q[ `$ anime_dl -o download -f .` (downloads videos to './')]
74
- opts.separator %Q[ `$ anime_dl -o d -f /abs/path/to/directory` (downloads videos to '/abs/path/to/directory/anime_name/')]
75
- opts.separator %Q[ `$ anime_dl -o download -f /abs/path/to/directory/` (downloads videos to '/abs/path/to/directory/anime_name/')]
58
+ opts.separator "Example Usage:"
59
+ opts.separator "(If user chooses to scrape LINKS)"
60
+ opts.separator %Q[ `$ anime-dl` (outputs link urls on the terminal)]
61
+ opts.separator %Q[ `$ anime-dl -f path/to/filename.txt` (outputs link urls to './path/to/filename.txt')]
62
+ opts.separator %Q[ `$ anime-dl -f path/to/directory/` (outputs link urls to './path/to/directory/anime_name.txt')]
63
+ opts.separator "(If user chooses to DOWNLOAD videos)"
64
+ opts.separator %Q[ `$ anime-dl` (downloads videos to './anime_name/')]
65
+ opts.separator %Q[ `$ anime-dl -f .` (downloads videos to './')]
66
+ opts.separator %Q[ `$ anime-dl -f /path/to/directory` (downloads videos to '/path/to/directory/anime_name/')]
67
+ opts.separator %Q[ `$ anime-dl -f /path/to/directory/` (downloads videos to '/path/to/directory/anime_name/')]
76
68
  opts.separator ""
77
69
 
78
- opts.separator "Example App Usage:"
79
- opts.separator "`anime_dl -q`"
80
- opts.separator " Enter Search Query: fullmetal alchemist b"
81
- opts.separator " 0. (Exit)"
82
- opts.separator " 1. Fullmetal Alchemist Brotherhood Dubbed | Hagane no Renkinjutsushi (2009) Dubbed"
83
- opts.separator " 2. Fullmetal Alchemist Brotherhood | Hagane no Renkinjutsushi (2009)"
84
- opts.separator " 3. (Enter new Search Query)"
85
- opts.separator ""
86
- opts.separator " Choice: 4"
87
- opts.separator " (Empty response gets all episodes, '-1' to exit)."
88
- opts.separator " Total number of Episodes - 20 (0-19)"
89
- opts.separator " Episodes: -1"
90
-
91
- opts.separator ""
92
- opts.separator ""
93
- opts.separator "When the '-a' option is not provided, the app asks for 'Episodes' after retrieving the user's anime choice."
94
- opts.separator "The user can provide induvidual space-seperated episodes."
95
- opts.separator "The user can also provide multiple space-seperated ranges with each range having the format 'start-end'."
96
- opts.separator "Below are a few examples (assuming anime has more than 18 episodes)."
97
- opts.separator %Q[ `Episodes: 2 4 5` - Retrieves details for episodes 2, 4 and 5]
98
- opts.separator %Q[ `Episodes: 4-8` - Retrieves details for episodes 4 to 8]
99
- opts.separator %Q[ `Episodes: 8-l` - Retrieves details for episodes 8 to the last episode]
100
- opts.separator %Q[ `Episodes: 2 9-13 18-l` - Retrieves details for episodes 2, 9 to 13 and 18 to end]
70
+ opts.separator "Specifying Episodes:"
71
+ opts.separator "(Run the app WITHOUT the '--quiet' option to allow it to provide explanations and examples for specifying episodes)"
101
72
  opts.separator ""
102
73
  opts.separator "NOTE: "
103
74
  opts.separator "The page being scraped from, \"animeheaven.eu\", only allows a certain number of page views per day (>150, <300)."
104
- opts.separator "Once that limit is exceeded, you will have to change networks or try again in 24 hours."
75
+ opts.separator "Once that limit is exceeded, you will have to change networks or try again the next day."
105
76
 
106
77
  begin
107
78
  opts.parse!
108
- rescue OptionParser::MissingArgument, OptionParser::InvalidArgument => error
109
- puts "Error: #{error}"
110
- puts "Enter `anime_dl - h` for usage options"
111
- exit
112
79
  rescue => error
113
80
  puts "Error: #{error}"
114
- puts "Enter `anime_dl - h` for usage options"
81
+ puts "Enter `anime-dl - h` for usage options"
115
82
  exit
116
83
  end
117
84
  end
118
85
 
119
-
120
- # File Check
121
- if (options[:file])
122
-
123
- if (options[:option][0] == "l")
124
- if ( File.directory?(options[:file]) )
125
- unless (File.exists?(options[:file]))
126
- puts "Directory does not exist"
127
- exit
128
- end
129
- elsif ( !File.exists?( File.split(options[:file])[0] ) )
130
- puts "Location does not exist"
131
- exit
132
- end
133
-
134
- elsif ( File.file?(options[:file]) )
135
- puts "Argument is not a directory"
136
- puts "For --option=download , argument to --file must be a directory"
137
- exit
138
- elsif ( !File.exists?(options[:file]) )
139
- puts "Creating New Directory #{options[:file]}"
140
- FileUtils.mkdir_p(options[:file])
141
- end
142
-
143
- end
86
+ ARGV.clear
144
87
 
145
88
 
146
89
  # New Instance
@@ -149,20 +92,25 @@ instance = AnimeDL::AnimeHeaven.new
149
92
  # App Prompts/Help Text
150
93
  unless (options[:quiet])
151
94
  $user_prompts = {
95
+ quiet: "(Note: Run app with '-q' or '--quiet' to suppress help messages)\n(Run anime-dl -h for more options)\n\n",
96
+ scrape_option: "\nShould the app get links or download episodes? (Empty response will download episodes)\n",
152
97
  search: "\nNo Results Found. Please check your search query.\n(Its worth noting that AnimeHeaven does not have some old anime)\n",
153
98
  episodes: "\nEnter the desired episodes.\nYou can provide induvidual space-seperated episodes.\n" +
154
99
  "Or you can also provide multiple space-seperated ranges with each range having the format 'start-end'.\n" +
155
- "Examples (assuming anime has more than 18 episodes):\n" +
100
+ "Examples (assuming anime below has more than 18 episodes):\n" +
156
101
  " `Episodes: 2 4 5` - Retrieves details for episodes 2, 4 and 5\n" +
157
102
  " `Episodes: 4-8` - Retrieves details for episodes 4 to 8\n" +
158
103
  " `Episodes: 8-l` - Retrieves details for episodes 8 to the last episode\n" +
159
104
  " `Episodes: 2 9-13 18-l` - Retrieves details for episodes 2, 9 to 13 and 18 to end\n" +
105
+ "(Running app with '-a' or '--all' will automatically retrieve all episodes)\n" +
160
106
  "(Enter empty response to get all episodes, '-1' exits)\n\n"
161
107
  }
162
108
  else
163
109
  $user_prompts = {
110
+ quiet: nil,
111
+ scrape_option: "\nLinks/Downloads?\n",
164
112
  search: "No Results Found.\n",
165
- episodes: "\n(Empty response gets all episodes, '-1' exits).\n"
113
+ episodes: "\nSelect Episodes. (Empty response gets all episodes, '-1' exits).\n"
166
114
  }
167
115
  end
168
116
 
@@ -182,18 +130,16 @@ def output(results)
182
130
  end
183
131
 
184
132
 
185
- # Option Check
186
- def check(input, max)
187
- exit if (input == "0")
188
- return 1 if ( (1..(max + 1)).include? input.to_i )
189
-
133
+ # Choice Check
134
+ def check(input, arr)
135
+ return 1 if ( arr.include? input )
190
136
  puts "Invalid input.\n\n"
191
137
  end
192
138
 
193
139
 
194
140
  # Write links to file
195
141
  def file_write(file, links, choice)
196
- details = ""
142
+ details = choice.content.split(" | ")[0] + "\n\n"
197
143
  puts links.pop.link if (links.last.number == nil)
198
144
  exit if links.empty?
199
145
 
@@ -204,11 +150,11 @@ def file_write(file, links, choice)
204
150
  puts "Writing"
205
151
  if ( File.directory?(file) )
206
152
  file = File.new( File.join(file, choice.content.split(" | ")[0] + ".txt"), "a+" )
207
- file.write(details + "\n")
153
+ file.write(details + "\n\n")
208
154
  file.close
209
155
  else
210
156
  file = File.new(file, "a+")
211
- file.write(details + "\n")
157
+ file.write(details + "\n\n")
212
158
  file.close
213
159
  end
214
160
  end
@@ -216,6 +162,9 @@ end
216
162
 
217
163
 
218
164
  # APP LOGIC
165
+ # Quiet Prompt
166
+ print $user_prompts[:quiet]
167
+
219
168
  # Search
220
169
  while true
221
170
  print "Enter Search Query: "
@@ -229,7 +178,8 @@ while true
229
178
  while true
230
179
  print "Choice: "
231
180
  input = gets.strip
232
- break if (check(input, results.length) == 1)
181
+ exit if (input == "0")
182
+ break if (check(input.to_i, 1..(results.length + 1)) == 1)
233
183
  end
234
184
 
235
185
  # Re-enter search query
@@ -239,15 +189,62 @@ end
239
189
 
240
190
  # Choice as Nokogiri Element
241
191
  choice = results[input.to_i - 1]
192
+ puts "Anime: " + choice.content + "\n"
193
+
194
+ # Choice for link or download
195
+ puts $user_prompts[:scrape_option]
196
+ while true
197
+ print "Option (l/d): "
198
+ scrape_option = gets.strip
199
+ break if ( check(scrape_option, ['l', 'd', ""]) == 1 )
200
+ end
201
+
202
+ scrape_option == 'd' if (scrape_option == "")
203
+
204
+ # File Check
205
+ begin
206
+ if (options[:file])
207
+
208
+ if (scrape_option == "l")
209
+ if ( !File.exists?(options[:file]) )
210
+ puts "\n"
211
+
212
+ if ( options[:file][-1] == "/" )
213
+ puts "Creating directory '#{options[:file]}'"
214
+ FileUtils.mkdir_p(options[:file])
215
+ else
216
+ puts "Creating directory '#{ File.split(options[:file])[0] }'"
217
+ FileUtils.mkdir_p( File.split(options[:file])[0] )
218
+ end
219
+ end
220
+
221
+ elsif ( File.file?(options[:file]) )
222
+ puts "\n"
223
+ puts "Argument is not a directory"
224
+ puts "For --option=download , argument to --file must be a directory"
225
+ exit
226
+ elsif ( !File.exists?(options[:file]) )
227
+ puts "\n"
228
+ puts "Creating directory '#{options[:file]}'"
229
+ FileUtils.mkdir_p(options[:file])
230
+ end
231
+
232
+ end
233
+ rescue => error
234
+ puts "\nDirectory creation failed."
235
+ puts error
236
+ exit
237
+ end
242
238
 
243
239
  # Range
244
240
  range = []
245
241
  if (options[:episode])
242
+ first, last = instance.getTotal(choice)
243
+
246
244
  puts "\n"
247
245
  print $user_prompts[:episodes]
248
246
  puts "\n"
249
247
 
250
- first, last = instance.getTotal(choice)
251
248
  puts "Total number of Episodes - #{last - first + 1} (#{first}-#{last})"
252
249
  print "Episodes: "
253
250
  range = gets.strip
@@ -258,9 +255,8 @@ end
258
255
 
259
256
 
260
257
  # Data Retrieval
261
- puts "Scraping: " + choice.content + "\n\n"
262
258
 
263
- if ( options[:option][0] == 'l' && !options[:file])
259
+ if ( scrape_option == 'l' && !options[:file])
264
260
  to_print = true
265
261
  else
266
262
  to_print = false
@@ -268,10 +264,10 @@ end
268
264
 
269
265
  # Links
270
266
  links = instance.getLinks(choice, range, options[:quiet], to_print)
271
- file_write(options[:file], links, choice) if (options[:file] && options[:option][0] == 'l')
267
+ file_write(options[:file], links, choice) if (options[:file] && scrape_option == 'l')
272
268
 
273
269
  # Downloads
274
- if ( options[:option][0] == 'd' )
270
+ if ( scrape_option == 'd' )
275
271
  if (options[:file] == nil)
276
272
  options[:file] = choice.content.split(" | ")[0]
277
273
  Dir.mkdir( options[:file] )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: AnimeDL
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anirudh Sundar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -27,7 +27,7 @@ dependencies:
27
27
  description:
28
28
  email: anirudhsundar@hotmail.com
29
29
  executables:
30
- - anime_dl
30
+ - anime-dl
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
@@ -35,7 +35,7 @@ files:
35
35
  - LICENSE.txt
36
36
  - README.md
37
37
  - anime_dl.gemspec
38
- - bin/anime_dl
38
+ - bin/anime-dl
39
39
  - fmab_anime_dl.jpg
40
40
  - lib/anime_dl.rb
41
41
  - lib/anime_dl/anime_heaven.rb