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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c4c190239b5baf100c07ba7b8dc5336f63b3dc4
4
- data.tar.gz: d518e8d14fc44ce129bdd6aa979a088f098059ad
3
+ metadata.gz: 9ed33589583c32700b94c52b0947779ce5f5499c
4
+ data.tar.gz: c7dad8d8e516cc827c830b0407e655189d3a3772
5
5
  SHA512:
6
- metadata.gz: b77ba04c27f78adf3e3d82afa411c8034bec2807d875ef14aebf650a6a5297825a197ccbee94565e6ce37705dbd9ed9e100298e6a413e76066bdb58d9634fe42
7
- data.tar.gz: 012745fb00c81368242a35217c49cbb13ef940eb71db6a2777407cf33508b1529b6b8ddc8ae593f6588630fcd703307a130e5c9763cd2cbfd2308d4bb6f3b61f
6
+ metadata.gz: 046ed9451c7a4003adf2fcd3fafab964eb26f911d7c6df7d5959548dcead92d8ab09f5aa081995eaeac492247d6181caf3fcb56484c60c49a7701524e2992623
7
+ data.tar.gz: e9a2f98e294e0b8c995d380a72244e8a4c7d71a3be03aa6f9e4d6152b9d7ba26d7f951647224dd3daeb63e99d4506e1d4488e5ca48f56c1967fd3685fca98dee
@@ -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 = "#{NYAA_SEARCH_DEFAULT}#{CGI.escape(title)}&offset="
31
+ url = "#{base_url}#{CGI.escape(title)}&offset="
30
32
  offset = 1
31
33
  loop do
32
34
  begin
@@ -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]*(.+?)[_\s]*(\[\w{8,}\])?[_\s]*(\.\w+)*\z/)
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
@@ -30,8 +30,8 @@ end
30
30
 
31
31
  require 'nyaa_anime'
32
32
 
33
- TORRENTS_BY_DISTRO = NyaaAnime.downloaded_torrents_by_distro
34
- distros = TORRENTS_BY_DISTRO.keys.sort!
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.downloaded_torrents.map { |t| "#{NyaaAnime::NYAA_DL_DIR}#{t}" }
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 = TORRENTS_BY_DISTRO[distro].map { |t| "#{NyaaAnime::NYAA_DL_DIR}#{t}" }
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 = TORRENTS_BY_DISTRO.keys.select { |distro| !!distro[/#{term}/i] }
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
@@ -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
- colorized_entries = NyaaAnime.colorized_entries NyaaAnime.search(search_term).sort!
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]
@@ -1,3 +1,3 @@
1
1
  class NyaaAnime
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.4"
3
3
  end
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.2
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-03-23 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel