AnimeDL 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52febf6fdb8981cf896a688f8c64076b4cd761aa
4
- data.tar.gz: 518aa6c64b9eb087522df785223ceaea46349365
3
+ metadata.gz: 4c9967bbc613e96f3743aec08e6e709218812503
4
+ data.tar.gz: 3cc7ea3f1c60a4c8b84f80c37332bd99243ed777
5
5
  SHA512:
6
- metadata.gz: 4dc8edc0b2f5d402b40a1643dfe2504a3d66d6c4b4f00b2ee6a4d4545de7eb3418cdedcdc0c7f44a4b3e6733601cfe50fbe24fa3319732438fb649dd5f65a1d5
7
- data.tar.gz: 996c68554bab7013574b518a90562bb4024fb58cdd3590ff3d6c5337fe4f647ec11a4cf3068ccd68fd13c92de2fa8e39893dd319e64f7780c7321be11768c717
6
+ metadata.gz: d336a0edf42a10c004f3c03c8331e893908628d53dd872fc80ecba76e6dcce53b3a63475c17200be80b0307f6137f88b023089a543abcc15c9304a6f77beddf8
7
+ data.tar.gz: 1087afb790cdbb6d6bb588fa3e8d4b5ead3ed8879b02f1cc720737076d8b7ae57c20e3183593cfcb0c7c62f6f66d3ed0221a16fa323d2e18c62d336c94632a35
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AnimeDL
2
2
 
3
- <p align='center'>
3
+ <p align='center' style="width: 75%">
4
4
  <img src='https://github.com/anirudhsundar98/AnimeDL/raw/master/fmab_anime_dl.jpg' alt='FMAB Stone'>
5
5
  </p>
6
6
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "AnimeDL"
3
- spec.version = "0.1.8"
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
@@ -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.1.8"
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 (>150, <300)."
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
@@ -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 in 24 hours." if (!quiet)
35
+ "Please change networks or try again tomorrow." if (!quiet)
36
36
 
37
37
  return "(Limit exceeded)"
38
38
  end
@@ -1,4 +1,5 @@
1
- require "open-uri"
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
- # Limit Check
12
- unless @number
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
- open("#{@link}") do |video|
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
- puts "Writing"
20
- file.write(video.read)
21
- file.close
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
- return 1
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.1.8
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: