AnimeDL 0.1.8 → 0.2.0
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 +4 -4
- data/README.md +1 -1
- data/anime_dl.gemspec +2 -1
- data/bin/anime-dl +3 -2
- data/lib/anime_dl.rb +2 -2
- data/lib/episode.rb +28 -11
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c9967bbc613e96f3743aec08e6e709218812503
|
4
|
+
data.tar.gz: 3cc7ea3f1c60a4c8b84f80c37332bd99243ed777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d336a0edf42a10c004f3c03c8331e893908628d53dd872fc80ecba76e6dcce53b3a63475c17200be80b0307f6137f88b023089a543abcc15c9304a6f77beddf8
|
7
|
+
data.tar.gz: 1087afb790cdbb6d6bb588fa3e8d4b5ead3ed8879b02f1cc720737076d8b7ae57c20e3183593cfcb0c7c62f6f66d3ed0221a16fa323d2e18c62d336c94632a35
|
data/README.md
CHANGED
data/anime_dl.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "AnimeDL"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.2.0"
|
4
4
|
spec.authors = ["Anirudh Sundar"]
|
5
5
|
spec.email = "anirudhsundar@hotmail.com"
|
6
6
|
|
@@ -13,4 +13,5 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
14
14
|
|
15
15
|
spec.add_runtime_dependency 'mechanize', '~> 2.7'
|
16
|
+
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.8'
|
16
17
|
end
|
data/bin/anime-dl
CHANGED
@@ -45,7 +45,7 @@ ARGV.options do |opts|
|
|
45
45
|
|
46
46
|
|
47
47
|
opts.on( "-v", "--version", help_statements[:version]) do
|
48
|
-
puts "AnimeDL: Version 0.
|
48
|
+
puts "AnimeDL: Version 0.2.0"
|
49
49
|
exit
|
50
50
|
end
|
51
51
|
|
@@ -71,7 +71,7 @@ ARGV.options do |opts|
|
|
71
71
|
opts.separator "(Run the app WITHOUT the '--quiet' option to allow it to provide explanations and examples for specifying episodes)"
|
72
72
|
opts.separator ""
|
73
73
|
opts.separator "NOTE: "
|
74
|
-
opts.separator "The page being scraped from, \"animeheaven.eu\", only allows a certain number of page views per day (>
|
74
|
+
opts.separator "The page being scraped from, \"animeheaven.eu\", only allows a certain number of page views per day (>170, <350)."
|
75
75
|
opts.separator "Once that limit is exceeded, you will have to change networks or try again the next day."
|
76
76
|
|
77
77
|
begin
|
@@ -255,6 +255,7 @@ end
|
|
255
255
|
|
256
256
|
|
257
257
|
# Data Retrieval
|
258
|
+
puts "\n"
|
258
259
|
|
259
260
|
if ( scrape_option == 'l' && !options[:file])
|
260
261
|
to_print = true
|
data/lib/anime_dl.rb
CHANGED
@@ -30,9 +30,9 @@ module AnimeDL
|
|
30
30
|
|
31
31
|
# UTILITY
|
32
32
|
def limit_exceeded(quiet)
|
33
|
-
return "Unfortunately \"animeheaven.eu\" only allows a certain number of page views per day.\n" +
|
33
|
+
return "Unfortunately \"animeheaven.eu\" only allows a certain number of page views per day (>170, <350).\n" +
|
34
34
|
"It seems you have exceeded that limit :(.\n" +
|
35
|
-
"Please change networks or try again
|
35
|
+
"Please change networks or try again tomorrow." if (!quiet)
|
36
36
|
|
37
37
|
return "(Limit exceeded)"
|
38
38
|
end
|
data/lib/episode.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'net/http'
|
2
|
+
require 'ruby-progressbar'
|
2
3
|
|
3
4
|
class Episode
|
4
5
|
def initialize(episode_no, link)
|
@@ -8,20 +9,36 @@ class Episode
|
|
8
9
|
attr_reader :number, :link
|
9
10
|
|
10
11
|
def download_to(path = ".")
|
11
|
-
|
12
|
-
|
13
|
-
puts @link
|
14
|
-
return -1
|
15
|
-
end
|
12
|
+
url_base = @link.split('/')[2]
|
13
|
+
url_path = '/'+@link.split('/')[3..-1].join('/')
|
16
14
|
|
17
|
-
|
15
|
+
Net::HTTP.start(url_base) do |http|
|
16
|
+
response = http.request_head(URI.escape(url_path))
|
17
|
+
progress_bar = ProgressBar.create(:progress_mark => "\#", :length => 80, :total => response['content-length'].to_i)
|
18
18
|
file = File.new( File.join( path, "Episode #{@number}.mp4" ), 'w')
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
|
20
|
+
begin
|
21
|
+
http.get(URI.escape(url_path)) do |str|
|
22
|
+
file.write(str)
|
23
|
+
|
24
|
+
begin
|
25
|
+
progress_bar.progress += str.length
|
26
|
+
rescue
|
27
|
+
# Bypass InvalidProgressBar Error if raised
|
28
|
+
end
|
29
|
+
end
|
30
|
+
rescue Exception
|
31
|
+
# Handle SystemExit or Interrupt
|
32
|
+
puts "Download incomplete. Deleting file."
|
33
|
+
File.delete(File.join( path, "Episode #{@number}.mp4" ))
|
34
|
+
raise
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
progress_bar.finish
|
22
39
|
end
|
23
40
|
|
24
|
-
|
41
|
+
puts "\n"
|
25
42
|
end
|
26
43
|
|
27
44
|
def details
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: AnimeDL
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anirudh Sundar
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-progressbar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
27
41
|
description:
|
28
42
|
email: anirudhsundar@hotmail.com
|
29
43
|
executables:
|