AnimeDL 0.2.4 → 1.0.5

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
- SHA1:
3
- metadata.gz: 5c597af419781934b0aba910c983bf287d16a7cc
4
- data.tar.gz: 0b00fe6433f0563b62557dc1580903422fe7aee5
2
+ SHA256:
3
+ metadata.gz: 0e5e478e8a86cb5f8215af8aad1586028288f8cc8106eacf459c48d1bd99100d
4
+ data.tar.gz: 76b3925b61f39259701df307aa9e2b46e8d6dcf034aec6576e88da15623cdc9f
5
5
  SHA512:
6
- metadata.gz: f804d2a018ff858d7a410a22b210dfc28c5c84799829244c176a4a5ffed513bee979c1f775d091ea3f7f8c53a48d3b84aedabf3c1f838a1cb1472ec273705f32
7
- data.tar.gz: 13578dffb80986c25df8a951a110340f018b05b439ff95fb0f07a5a693679b6c437c510d6c603155c6f2e206cf8acc580b2677330ec25f95306135a778090fda
6
+ metadata.gz: f5bbd47f17f794a72045563b676fa125aa9e3a45e730528fd3b5fd9ac3be7526bcf4bf7242bb1b8681b787175caf1d498e3a4c5fe3aaeffbff1873494142aecf
7
+ data.tar.gz: a9e7b929234af8b7a44e9a1cfc6af576894e5eaeaeadff3dc96a0726a8db3338d78d4e4c7a3ae6c112f27ccf730f348eb71a83a1bae9dfce253fd9f6b05aaa2c
data/.gitignore CHANGED
@@ -1 +1,4 @@
1
1
  test*
2
+ AnimeDL_Bundler
3
+ *.gem
4
+ *script*
File without changes
data/README.md CHANGED
@@ -57,8 +57,7 @@ On choosing a particular anime, the user can then choose to get links or downloa
57
57
 
58
58
  `$ anime-dl` - (downloads videos to './anime_name/')]
59
59
  `$ anime-dl -f .` - (downloads videos to './')]
60
- `$ anime-dl -f /path/to/directory` - (downloads videos to '/path/to/directory/anime_name/')]
61
- `$ anime-dl -f /path/to/directory/` - (downloads videos to '/path/to/directory/anime_name/')]
60
+ `$ anime-dl -f /path/to/directory` - (downloads videos to '/path/to/directory/')]
62
61
 
63
62
 
64
63
  ### Specifying Episodes:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "AnimeDL"
3
- spec.version = "0.2.4"
3
+ spec.version = "1.0.5"
4
4
  spec.authors = ["Anirudh Sundar"]
5
5
  spec.email = "anirudhsundar@hotmail.com"
6
6
 
@@ -6,7 +6,7 @@ require "fileutils"
6
6
  # APP OPTIONS
7
7
  options = { episode: true, file: nil, quiet: false }
8
8
  help_statements = {
9
- episode: %Q[Prevents the app from asking for an Episodes prompt. Gets detals for all episodes.],
9
+ episode: %Q[Prevents the app from asking for an Episodes prompt. Gets details for all episodes.],
10
10
  file: %Q[Provide location to store extracted details. Creates sub-directories as needed. (Usage Examples below).],
11
11
  quiet: %Q[Suppresses large, in-program help statements.],
12
12
  help: %Q[Shows this message and exits.],
@@ -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.2.4"
48
+ puts "AnimeDL: Version 1.0.5"
49
49
  exit
50
50
  end
51
51
 
@@ -63,8 +63,7 @@ ARGV.options do |opts|
63
63
  opts.separator "(If user chooses to DOWNLOAD videos)"
64
64
  opts.separator %Q[ `$ anime-dl` (downloads videos to './anime_name/')]
65
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/')]
66
+ opts.separator %Q[ `$ anime-dl -f /path/to/directory` (downloads videos to '/path/to/directory/')]
68
67
  opts.separator ""
69
68
 
70
69
  opts.separator "Specifying Episodes:"
@@ -99,11 +98,11 @@ unless (options[:quiet])
99
98
  "Or you can also provide multiple space-seperated ranges with each range having the format 'start-end'.\n" +
100
99
  "Examples (assuming anime below has more than 18 episodes):\n" +
101
100
  " `Episodes: 2 4 5` - Retrieves details for episodes 2, 4 and 5\n" +
102
- " `Episodes: 4-8` - Retrieves details for episodes 4 to 8\n" +
101
+ " `Episodes: 4-7` - Retrieves details for episodes 4, 5, 6 and 7\n" +
103
102
  " `Episodes: 8-l` - Retrieves details for episodes 8 to the last episode\n" +
104
- " `Episodes: 2 9-13 18-l` - Retrieves details for episodes 2, 9 to 13 and 18 to end\n" +
103
+ " `Episodes: 2 9-11 18-l` - Retrieves details for episodes 2, 9, 10, 11 and 18 to the end\n" +
105
104
  "(Running app with '-a' or '--all' will automatically retrieve all episodes)\n" +
106
- "(Enter empty response to get all episodes, '-1' exits)\n\n"
105
+ "(Enter empty response to get all episodes or '-1' to exit)\n\n"
107
106
  }
108
107
  else
109
108
  $user_prompts = {
@@ -231,7 +230,7 @@ begin
231
230
 
232
231
  end
233
232
  rescue => error
234
- puts "\nDirectory creation failed."
233
+ puts "\nDirectory creation failed.\n\n"
235
234
  puts error
236
235
  exit
237
236
  end
@@ -264,14 +263,14 @@ else
264
263
  end
265
264
 
266
265
  # Links
267
- links = instance.getLinks(choice, range, options[:quiet], to_print)
266
+ links = instance.getVideoLinks(choice, range, options[:quiet], to_print)
268
267
  file_write(options[:file], links, choice) if (options[:file] && scrape_option == 'l')
269
268
 
270
269
  # Downloads
271
270
  if ( scrape_option == 'd' )
272
271
  if (options[:file] == nil)
273
272
  options[:file] = choice.content.split(" | ")[0]
274
- Dir.mkdir( options[:file] )
273
+ FileUtils.mkdir_p( options[:file] )
275
274
  end
276
275
 
277
276
  AnimeDL.download(options[:file], links)
File without changes
@@ -14,7 +14,7 @@ module AnimeDL
14
14
  # Search
15
15
  def search(query)
16
16
  results_page = @agent.get("http://animeheaven.eu/search.php?q=#{query}")
17
- return results_page.search(".iepsan")
17
+ return results_page.search(".iepcon").search(".cona")
18
18
  end
19
19
 
20
20
  # Returns the total number of episodes
@@ -22,13 +22,28 @@ module AnimeDL
22
22
  @anime_page = @agent.get(option.attributes['href'].value) unless (@anime_page)
23
23
  episodes = @anime_page.search(".infoepbox").search("a")
24
24
 
25
- first = episodes.last.search(".infoept2")[0].content.to_i
26
- last = episodes.first.search(".infoept2")[0].content.to_i
25
+ # New Episodes have a different class
26
+ begin
27
+ first = episodes.last.search(".infoept2")[0].content.to_i
28
+ rescue
29
+ first = episodes.last.search(".infoept2r")[0].content.to_i
30
+ end
31
+ begin
32
+ last = episodes.first.search(".infoept2")[0].content.to_i
33
+ rescue
34
+ last = episodes.first.search(".infoept2r")[0].content.to_i
35
+ end
36
+
27
37
  return first, last
28
38
  end
29
39
 
30
40
 
31
41
  # UTILITY
42
+ def parseURL(url)
43
+ url = url.to_s[/luu1=rrl\(".*?"\)/][10...-2]
44
+ return url.tr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm")
45
+ end
46
+
32
47
  def limit_exceeded(quiet)
33
48
  return "Unfortunately \"animeheaven.eu\" only allows a certain number of page views per day (>170, <350).\n" +
34
49
  "It seems you have exceeded that limit :(.\n" +
@@ -36,7 +51,6 @@ module AnimeDL
36
51
 
37
52
  return "(Limit exceeded)"
38
53
  end
39
-
40
54
  end
41
55
 
42
56
  # Download
@@ -16,7 +16,7 @@ module AnimeDL
16
16
  end
17
17
 
18
18
  # Video Links
19
- def getLinks(option, range, quiet = false, output = false)
19
+ def getVideoLinks(option, range = [], quiet = false, output = false)
20
20
  episode_links = getPageLinks(option, range)
21
21
  episodes = []
22
22
 
@@ -37,17 +37,13 @@ module AnimeDL
37
37
 
38
38
  # Video Link Retrieval
39
39
  episode_no = episode_page.uri.to_s[/e=.+/][2..-1] # (Regex for safety)
40
- video_src = episode_page.search("script")[2].to_s[/src='http.*?'/][5...-1]
40
+ video_src = parseURL(episode_page.search("script")[3])
41
41
 
42
42
  episode = Episode.new(episode_no, video_src)
43
43
  episodes << episode
44
44
 
45
45
  # Progress Bar increment
46
- begin
47
- progress_bar.progress += 1 unless (output)
48
- rescue
49
- # Bypass InvalidProgressBar Error if raised
50
- end
46
+ progress_bar.progress += 1 unless (output) rescue nil
51
47
 
52
48
  puts episode.details if (output)
53
49
  end
@@ -9,33 +9,31 @@ class Episode
9
9
  attr_reader :number, :link
10
10
 
11
11
  def download_to(path = ".")
12
- url_base = @link.split('/')[2]
13
- url_path = '/'+@link.split('/')[3..-1].join('/')
12
+ url_base = @link.split('/')[2] # Animeheaven
13
+ url_path = '/'+@link.split('/')[3..-1].join('/') # Sub Url
14
14
 
15
15
  Net::HTTP.start(url_base) do |http|
16
16
  response = http.request_head(URI.escape(url_path))
17
17
  progress_bar = ProgressBar.create(:progress_mark => "\#", :length => 80, :total => response['content-length'].to_i)
18
- file = File.new( File.join( path, "Episode #{@number}.mp4" ), 'w')
18
+ file = File.new( File.join( path, "Episode #{@number}.mp4.tmp" ), 'w')
19
19
 
20
20
  begin
21
21
  http.get(URI.escape(url_path)) do |str|
22
22
  file.write(str)
23
-
24
- begin
25
- progress_bar.progress += str.length
26
- rescue
27
- # Bypass InvalidProgressBar Error if raised
28
- end
23
+ progress_bar.progress += str.length rescue nil
29
24
  end
30
25
  rescue Exception
31
26
  # Handle SystemExit or Interrupt
32
- puts "Download incomplete. Deleting file."
33
- File.delete(File.join( path, "Episode #{@number}.mp4" ))
27
+ puts "Download incomplete. Deleting file.\n\n"
28
+ file.close
29
+ File.delete(File.join( path, "Episode #{@number}.mp4.tmp" ))
34
30
  raise
35
31
  exit
36
32
  end
37
33
 
38
34
  progress_bar.finish
35
+ file.close
36
+ File.rename(file, File.join( path, "Episode #{@number}.mp4" ))
39
37
  end
40
38
 
41
39
  puts "\n"
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.2.4
4
+ version: 1.0.5
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-09-02 00:00:00.000000000 Z
11
+ date: 2018-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.6.8
77
+ rubygems_version: 2.7.3
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: The AnimeDL gem is used to get episode links or download episodes for a particular