peerflixrb 1.0.1 → 1.1.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: 541977a7d125abcf67ac35b820aa519a809c513e
4
- data.tar.gz: 1e8db5bb3e31e481d5e9633aac73677761cb8ed8
3
+ metadata.gz: 2a46bcd58ffb923ac652451cbdd9181d957400d7
4
+ data.tar.gz: 9dddfae0d38c1e8ee2b10987d485fc900c0be23c
5
5
  SHA512:
6
- metadata.gz: 3b8023b8dd56a0574454e7ed016122ad489878ae89284f8f03e420dec162a8776651093632349554625d9590bf85eb42dc824c05d37908666926a089e4e40e33
7
- data.tar.gz: 6bd1356c70ac152ce6b0c199f514a6af3baaa29d40c976de0f3fc4107efa739d10aa84fd53a36f6c48a27c63540e35f362858dbc897ca51420110972dc693521
6
+ metadata.gz: ef2424c24d06c4c0f5b432b7ba0c1307d78ef810769dcd6a23ae5e91351ddd343c8efc3b08e559b00921ab48b795f532819297db27c41c1a198816fb95c0aaa0
7
+ data.tar.gz: b41f6184a40dc268c29eb58636bd0b3215363b6a81a54f39b218cfea05c46bf384e44f7688e5cb91dc137265fd701a69d733547252245f454b637df4b3d9a41d
@@ -11,8 +11,9 @@ module Peerflixrb
11
11
  HighLine.colorize_strings
12
12
 
13
13
  def self.select_link(kat_search)
14
+ cli.say "Choose file (#{'seeders'.green}/#{'leechers'.red}):"
15
+
14
16
  cli.choose(*kat_search.links) do |menu|
15
- menu.header = 'Choose file'
16
17
  menu.default = '1'
17
18
  menu.select_by = :index
18
19
  end
@@ -34,8 +34,14 @@ module Peerflixrb
34
34
  def generate_links
35
35
  links = []
36
36
  crawled_links = page.css('.iaconbox > div')
37
- crawled_links[0..NUMBER_OF_LINKS - 1].each do |link|
38
- links << Link.new(YAML.load(link['data-sc-params']))
37
+ seeders = page.css('td.green')
38
+ leechers = page.css('td.red')
39
+
40
+ crawled_links[0..NUMBER_OF_LINKS - 1].each_with_index do |link, i|
41
+ params = YAML.load(link['data-sc-params'])
42
+ params['seeders'] = seeders[i].text
43
+ params['leechers'] = leechers[i].text
44
+ links << Link.new(params)
39
45
  end
40
46
 
41
47
  return links
@@ -5,12 +5,21 @@ module Peerflixrb
5
5
  ##
6
6
  # Object that contains the info for a torrent file
7
7
  class Link
8
+ @@max_length_name ||= 0
9
+
10
+ attr_reader :seeders, :leechers
11
+
8
12
  def initialize(params)
9
13
  @params = params
14
+ @seeders = params['seeders']
15
+ @leechers = params['leechers']
16
+
17
+ # Get the longest filename for pretty print
18
+ set_max_length_name(filename.length)
10
19
  end
11
20
 
12
21
  def to_s
13
- filename
22
+ "#{filename.ljust(@@max_length_name + 2)} (#{@seeders.green}/#{@leechers.red})"
14
23
  end
15
24
 
16
25
  def filename
@@ -32,5 +41,9 @@ module Peerflixrb
32
41
  magnet_params = CGI.parse(URI.parse(magnet).query)
33
42
  magnet_params['xt'].first.match(/[0-9A-Fa-f]{20,}/).to_s.downcase
34
43
  end
44
+
45
+ def set_max_length_name(length)
46
+ @@max_length_name = length if @@max_length_name < length
47
+ end
35
48
  end
36
49
  end
@@ -1,3 +1,3 @@
1
1
  module Peerflixrb
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peerflixrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Marchante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  requirements: []
239
239
  rubyforge_project:
240
- rubygems_version: 2.6.3
240
+ rubygems_version: 2.6.4
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: Wrapper for peerflix with automatic search through KAT and Addic7ed.