nyaa_anime 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nyaa_anime.rb +4 -2
- data/lib/nyaa_anime/entry.rb +4 -1
- data/lib/nyaa_anime/remove.rb +5 -5
- data/lib/nyaa_anime/search.rb +5 -1
- data/lib/nyaa_anime/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed33589583c32700b94c52b0947779ce5f5499c
|
4
|
+
data.tar.gz: c7dad8d8e516cc827c830b0407e655189d3a3772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046ed9451c7a4003adf2fcd3fafab964eb26f911d7c6df7d5959548dcead92d8ab09f5aa081995eaeac492247d6181caf3fcb56484c60c49a7701524e2992623
|
7
|
+
data.tar.gz: e9a2f98e294e0b8c995d380a72244e8a4c7d71a3be03aa6f9e4d6152b9d7ba26d7f951647224dd3daeb63e99d4506e1d4488e5ca48f56c1967fd3685fca98dee
|
data/lib/nyaa_anime.rb
CHANGED
@@ -14,6 +14,7 @@ class NyaaAnime
|
|
14
14
|
NYAA_URI = "http://nyaa.se"
|
15
15
|
NYAA_SEARCH = "#{NYAA_URI}/?page=rss"
|
16
16
|
NYAA_SEARCH_DEFAULT = "#{NYAA_SEARCH}&cats=1_37&filter=2&term="
|
17
|
+
NYAA_SEARCH_BACKUP = "#{NYAA_SEARCH}&cats=1_37&filter=0&term="
|
17
18
|
NYAA_DL_DIR = "#{Dir.home}/Downloads/nyaa/"
|
18
19
|
NYAA_ENTRIES_PER_PAGE = 100
|
19
20
|
MAX_PAGES = 20
|
@@ -24,9 +25,10 @@ class NyaaAnime
|
|
24
25
|
|
25
26
|
FileUtils.mkdir_p NYAA_DL_DIR
|
26
27
|
|
27
|
-
def self.search(title)
|
28
|
+
def self.search(title, filter=true)
|
29
|
+
base_url = filter ? NYAA_SEARCH_DEFAULT : NYAA_SEARCH_BACKUP
|
28
30
|
entries = []
|
29
|
-
url = "#{
|
31
|
+
url = "#{base_url}#{CGI.escape(title)}&offset="
|
30
32
|
offset = 1
|
31
33
|
loop do
|
32
34
|
begin
|
data/lib/nyaa_anime/entry.rb
CHANGED
@@ -7,7 +7,10 @@ class Entry
|
|
7
7
|
def initialize(title, link=nil)
|
8
8
|
@title = title
|
9
9
|
@link = link
|
10
|
-
match = @title.scan(/\A(\[[^\[\]]+\])?[_\s]*(.+?)[_\s]*-?[_\s]*(\d+(\.\d+)?(v\d+)?|\d+-\d+)[_\s]
|
10
|
+
match = @title.scan(/\A(\[[^\[\]]+\])?[_\s]*(.+?)[_\s]*-?[_\s]*(\d+(\.\d+)?(v\d+)?|\d+-\d+)[_\s]+((?!-).+?)[_\s]*(\[\w{8,}\])?[_\s]*(\.\w+)*\z/)
|
11
|
+
if match[0].nil?
|
12
|
+
match[0] = ['undefined', 'undefined', 'undefined', nil, nil, 'undefined']
|
13
|
+
end
|
11
14
|
@subber, @series, @episode, @meta = match[0].values_at(0, 1, 2, 5)
|
12
15
|
@episode, @last_ep = @episode.split("-").map { |ep| ep.to_i }
|
13
16
|
@last_ep ||= @episode
|
data/lib/nyaa_anime/remove.rb
CHANGED
@@ -30,8 +30,8 @@ end
|
|
30
30
|
|
31
31
|
require 'nyaa_anime'
|
32
32
|
|
33
|
-
|
34
|
-
distros =
|
33
|
+
ENTRIES_BY_DISTRO = NyaaAnime.downloaded_entries_by_distro
|
34
|
+
distros = ENTRIES_BY_DISTRO.keys.sort!
|
35
35
|
|
36
36
|
if distros.size == 0
|
37
37
|
puts "No files in #{NyaaAnime::NYAA_DL_DIR}."
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
require 'highline/import'
|
41
41
|
|
42
42
|
if options[:remove_all]
|
43
|
-
ts = NyaaAnime.
|
43
|
+
ts = NyaaAnime.downloaded_entries.map { |entry| "#{NyaaAnime::NYAA_DL_DIR}#{entry.title}" }
|
44
44
|
if agree "Delete all #{ts.size} torrent files? (y/n) "
|
45
45
|
File.delete(*ts)
|
46
46
|
end
|
@@ -48,7 +48,7 @@ if options[:remove_all]
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def delete_distro(distro)
|
51
|
-
ts =
|
51
|
+
ts = ENTRIES_BY_DISTRO[distro].map { |entry| "#{NyaaAnime::NYAA_DL_DIR}#{entry.title}" }
|
52
52
|
if agree "Delete all #{ts.size} torrent files for #{distro}? (y/n) "
|
53
53
|
File.delete(*ts)
|
54
54
|
end
|
@@ -66,7 +66,7 @@ if options[:number]
|
|
66
66
|
end
|
67
67
|
|
68
68
|
term = ARGV[1..-1].join " "
|
69
|
-
distros =
|
69
|
+
distros = ENTRIES_BY_DISTRO.keys.select { |distro| !!distro[/#{term}/i] }
|
70
70
|
if distros.count == 0
|
71
71
|
warn "Error: No torrent files matching \"#{term}\"."
|
72
72
|
exit 1
|
data/lib/nyaa_anime/search.rb
CHANGED
@@ -24,6 +24,9 @@ option_parser = OptionParser.new do |opts|
|
|
24
24
|
opts.on("-i", "--individual", "List all results individually") do
|
25
25
|
options[:list_individually] = true
|
26
26
|
end
|
27
|
+
opts.on("-F", "--no-filter", "Do not filter") do
|
28
|
+
options[:no_filter] = true
|
29
|
+
end
|
27
30
|
|
28
31
|
opts.on("-n", "--new", "Find all new episodes of",
|
29
32
|
"previously downloaded anime") do
|
@@ -100,7 +103,8 @@ else
|
|
100
103
|
exit 1
|
101
104
|
end
|
102
105
|
puts "Searching for \"#{search_term}\"..." unless options[:quiet]
|
103
|
-
|
106
|
+
entries = options[:no_filter] ? NyaaAnime.search(search_term, false) : NyaaAnime.search(search_term)
|
107
|
+
colorized_entries = NyaaAnime.colorized_entries entries.sort!
|
104
108
|
new_entries = colorized_entries[:new]
|
105
109
|
entries = colorized_entries.values.flatten!
|
106
110
|
if options[:list_individually]
|
data/lib/nyaa_anime/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyaa_anime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Tsubaki Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|