peerflixrb 5.2.2 → 6.0.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: f05196d64c582760467611d5748d579767a5981d
4
- data.tar.gz: ea7d85e3a42883fb74a71b653bf018150831de84
3
+ metadata.gz: 601e90feab0054afdc5e67f5105ab704b7b7b0f7
4
+ data.tar.gz: d6eeffe48387fef754ed3ac4948a54a4cb79d016
5
5
  SHA512:
6
- metadata.gz: b9453044a369dc7f78d8f8740623d227a061e636c4903a5bf51b26e17824eeb500a050bd85f78f1a3429d32ac43dc849520fbba1a4926819751f07d8fb4e07f6
7
- data.tar.gz: 5e74301391183a32143a641f1ba05bff46e9de2ce7aa6ddecc088566813fe2fde9963b49fe0a4a4a266ef4c38860be9f3306495362ba8af58314c93aa5e4854f
6
+ metadata.gz: a2c051960245f97b5a75de7121c0a264fe237dec1c323c7c6e3954f647237e048d627c264e224e11c1844def866a1fb787aaf76757e81eb99c6255a8560640b1
7
+ data.tar.gz: 65aa8eca938b268425f7c9c9b2d53237085c06a3d347a205065852b7aa71e47a7851e4463a3e2d5b6e721eb444cf91b610af11c1558cff58b845559bde4e7c62
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in peerflixrb.gemspec
4
2
  gemspec
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Peerflixrb
4
4
 
5
- Wrapper for [webtorrent-cli](https://github.com/feross/webtorrent-cli) with automatic search through [Zooqle](https://zooqle.com), [YifySubtitles](http://www.yifysubtitles.com/) and [Addic7ed](http://www.addic7ed.com/).
5
+ Wrapper for [webtorrent-cli](https://github.com/feross/webtorrent-cli) with automatic search through [Popcorn Time](https://github.com/popcorn-official/popcorn-api), [YifySubtitles](http://www.yifysubtitles.com/) and [Addic7ed](http://www.addic7ed.com/).
6
6
 
7
7
 
8
8
  ## Installation
Binary file
Binary file
Binary file
data/exe/peerflixrb CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'highline/import'
3
4
  require 'optparse'
4
5
  require 'peerflixrb'
5
- require 'zooqle_search'
6
+ require 'popcorntime_search'
6
7
 
7
8
  options = {
8
9
  language: 'en',
@@ -85,23 +86,40 @@ end
85
86
  # main program
86
87
  begin
87
88
  commands = Peerflixrb::Commands.new
88
- cli = commands.cli
89
89
 
90
90
  # Check requirements
91
91
  webtorrent = commands.webtorrent
92
92
 
93
- # Torrent Search
94
- cli.say "Searching torrent for #{options[:search].blue}".yellow
95
- torrent_search = ZooqleSearch::Search.new(options[:search])
93
+ # Search
94
+ say "Searching torrent for #{options[:search].blue}".yellow
95
+ search = PopcorntimeSearch::Search.new(options[:search])
96
96
 
97
97
  # Did it find results?
98
- unless torrent_search.results_found?
99
- cli.say "No results found for #{options[:search].blue}".red
98
+ unless search.results_found?
99
+ say "No results found for #{options[:search].blue}".red
100
+ exit
101
+ end
102
+
103
+ # If 'auto' or only one result, pick the first/only one
104
+ if options[:auto] || search.results.one?
105
+ search_result = search.results.first
106
+ else
107
+ # If there are several matches, choose the appropriate one
108
+ say "Search results for #{options[:search].blue}:".yellow
109
+ search_result = choose(*search.results) do |menu|
110
+ menu.default = '1'
111
+ menu.select_by = :index
112
+ end
113
+ end
114
+
115
+ if search_result.links.empty?
116
+ say 'No results found'.red
100
117
  exit
101
118
  end
102
119
 
103
120
  # Choose link and subtitles
104
- link, sub_file = commands.choose_video_and_subtitles(torrent_search, options)
121
+ options[:kind] = search_result.kind
122
+ link, sub_file = commands.choose_video_and_subtitles(search_result, options)
105
123
 
106
124
  # Webtorrent command build
107
125
  command = "#{webtorrent} '#{link.magnet}'"
@@ -109,13 +127,13 @@ begin
109
127
  command << " --#{options[:video_player]}" if options[:video_player]
110
128
 
111
129
  # Execute webtorrent
112
- cli.say "Executing webtorrent with #{link.filename.blue} ".yellow
113
- cli.say "and #{sub_file.blue}".yellow if sub_file
130
+ say "Executing webtorrent with #{link.title.blue} ".yellow
131
+ say "and #{sub_file.blue}".yellow if sub_file
114
132
  system command
115
133
  rescue Interrupt, EOFError
116
- cli.say 'Interrupted!'.red
134
+ say 'Interrupted!'.red
117
135
  rescue SocketError
118
- cli.say "Couldn't perform action. Are you online?".red
136
+ say "Couldn't perform action. Are you online?".red
119
137
  ensure
120
138
  # Cleaning up
121
139
  if link
@@ -128,6 +146,6 @@ ensure
128
146
 
129
147
  video_file = Dir["#{cache_dir}/**/*.{mkv,mp4,avi,wmv,mpg,flv,mov}"].first
130
148
  FileUtils.mv(sub_file, File.dirname(video_file)) if sub_file && video_file
131
- cli.say "Your downloads will be in #{cache_dir.blue} #{'for 3 days :)'.yellow}".yellow
149
+ say "Your downloads will be in #{cache_dir.blue} #{'for 3 days :)'.yellow}".yellow
132
150
  end
133
151
  end
data/lib/peerflixrb.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  require 'peerflixrb/commands'
2
- require 'peerflixrb/imdb'
3
2
  require 'peerflixrb/version'
4
3
  require 'peerflixrb/yify'
@@ -1,25 +1,22 @@
1
1
  require 'addic7ed_downloader'
2
- require 'highline'
2
+ require 'highline/import'
3
3
 
4
4
  BINARY_PATH = File.join(File.dirname(__FILE__), %w(.. .. bin))
5
5
 
6
6
  module Peerflixrb
7
7
  class Commands
8
- attr_reader :cli
9
-
10
8
  def initialize
11
- @cli = HighLine.new
12
9
  HighLine.colorize_strings
13
10
  end
14
11
 
15
12
  def check_requirements
16
13
  unless system('node --version > /dev/null 2>&1')
17
- cli.say 'Nodejs is required to make it work.'.red
14
+ say 'Nodejs is required to make it work.'.red
18
15
  exit
19
16
  end
20
17
 
21
18
  unless system('webtorrent --version > /dev/null 2>&1')
22
- cli.say 'webtorrent is required. Type "npm install -g webtorrent-cli" in your shell to install it.'.red
19
+ say 'webtorrent is required. Type "npm install -g webtorrent-cli" in your shell to install it.'.red
23
20
  exit
24
21
  end
25
22
  end
@@ -29,26 +26,28 @@ module Peerflixrb
29
26
  return 'webtorrent' if check_requirements
30
27
  end
31
28
 
32
- def choose_video_and_subtitles(torrent_search, options)
29
+ def choose_video_and_subtitles(search_result, options)
33
30
  # Proactively declare them because they would be lost in the block scope
34
- link = nil
31
+ link = nil
32
+ links = search_result.links.sort.reverse
35
33
  sub_file = nil
36
34
 
37
35
  loop do
38
36
  # Choose file
39
- link = options[:auto_select] ? torrent_search.links.first : select_link(torrent_search)
37
+ link = options[:auto_select] ? links.first : select_link(links)
40
38
 
41
39
  # Subtitle search
42
40
  sub_file = if options[:find_subtitles]
43
- cli.say "Searching subtitles for #{link.filename.blue}".yellow
44
- find_subtitles(link.filename, options)
41
+ # TODO
42
+ say "Searching subtitles for #{link.title.blue}".yellow
43
+ find_subtitles(link, options)
45
44
  elsif options[:subtitles]
46
45
  options[:subtitles]
47
46
  end
48
47
 
49
48
  # Was there a problem with the subtitle?
50
49
  if options[:find_subtitles] && sub_file.nil?
51
- continue = cli.agree "Could not find subtitles. Do you want to continue? #{'[y/n]'.yellow}".blue
50
+ continue = agree "Could not find subtitles. Do you want to continue? #{'[y/n]'.yellow}".blue
52
51
 
53
52
  unless continue
54
53
  # If :auto_select, exit program
@@ -71,39 +70,33 @@ module Peerflixrb
71
70
 
72
71
  private
73
72
 
74
- def select_link(torrent_search)
75
- cli.say "Choose file (#{'seeders'.green}/#{'leechers'.red}):"
76
-
77
- cli.choose(*torrent_search.links) do |menu|
73
+ def select_link(links)
74
+ say "Choose file (#{'seeders'.green}/#{'leechers'.red}):"
75
+ choose(*links) do |menu|
78
76
  menu.default = '1'
79
77
  menu.select_by = :index
80
78
  end
81
79
  end
82
80
 
83
- def find_subtitles(video_file, options)
84
- # Matches format 's06e02'? => TV Show
85
- if options[:search][/s\d{1,2}e\d{1,2}/i]
86
- find_tv_subtitles(video_file, options)
87
- else
88
- movie = Imdb.find(options[:search])
89
- YifySubtitles.download(movie.imdb_id, 'english')
90
- end
91
- end
92
-
93
- def find_tv_subtitles(video_file, options)
94
- # TV Show search based on video filename
95
- search = Addic7edDownloader::Search.by_filename options[:search],
96
- lang: options[:language]
97
- search.extract_tags(video_file)
98
- return search.download_best unless options[:choose_subtitles]
81
+ def find_subtitles(link, options)
82
+ case options[:kind]
83
+ when :movie
84
+ YifySubtitles.download(link.imdb_id, 'english')
85
+ when :show
86
+ filename = link.filename || link.title
87
+ search = Addic7edDownloader::Search.by_filename(filename, lang: options[:language])
88
+
89
+ return search.download_best unless options[:choose_subtitles]
90
+
91
+ # Choose subtitle
92
+ say "Choose subtitles for #{filename.blue}:".yellow
93
+ subtitle = choose(*search.results) do |menu|
94
+ menu.default = '1'
95
+ menu.select_by = :index
96
+ end
99
97
 
100
- # Choose subtitle
101
- subtitle = cli.choose(*search.results) do |menu|
102
- menu.default = '1'
103
- menu.select_by = :index
98
+ search.download_subtitle(subtitle)
104
99
  end
105
-
106
- search.download_subtitle(subtitle)
107
100
  end
108
101
 
109
102
  def os
@@ -1,3 +1,3 @@
1
1
  module Peerflixrb
2
- VERSION = '5.2.2'.freeze
2
+ VERSION = '6.0.0'.freeze
3
3
  end
data/peerflixrb.gemspec CHANGED
@@ -20,17 +20,17 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.add_runtime_dependency 'addic7ed_downloader', '~> 1.0'
23
- spec.add_runtime_dependency 'zooqle_search', '~> 1.0'
24
- spec.add_runtime_dependency 'nokogiri', '~> 1.6'
23
+ spec.add_runtime_dependency 'popcorntime_search', '~> 0.0'
24
+ spec.add_runtime_dependency 'nokogiri', '~> 1.8'
25
25
  spec.add_runtime_dependency 'highline', '~> 1.7'
26
- spec.add_runtime_dependency 'httparty', '~> 0.13'
26
+ spec.add_runtime_dependency 'httparty', '~> 0.15'
27
27
  spec.add_runtime_dependency 'rubyzip', '~> 1.2'
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.12'
30
- spec.add_development_dependency 'rake', '~> 11.3'
29
+ spec.add_development_dependency 'bundler', '~> 1.15'
30
+ spec.add_development_dependency 'rake', '~> 12.0'
31
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
32
  spec.add_development_dependency 'guard-rspec', '~> 4.6'
33
- spec.add_development_dependency 'pry', '~> 0.10'
34
- spec.add_development_dependency 'pry-byebug', '~> 3.4'
33
+ spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'pry-byebug'
35
35
  spec.add_development_dependency 'awesome_print'
36
36
  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: 5.2.2
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Marchante
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-25 00:00:00.000000000 Z
11
+ date: 2017-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addic7ed_downloader
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: zooqle_search
28
+ name: popcorntime_search
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '0.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '0.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.6'
47
+ version: '1.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.6'
54
+ version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: highline
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.13'
75
+ version: '0.15'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.13'
82
+ version: '0.15'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubyzip
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.12'
103
+ version: '1.15'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.12'
110
+ version: '1.15'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '11.3'
117
+ version: '12.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '11.3'
124
+ version: '12.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -154,30 +154,30 @@ dependencies:
154
154
  name: pry
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "~>"
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '0.10'
159
+ version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - "~>"
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: '0.10'
166
+ version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: pry-byebug
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '3.4'
173
+ version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '3.4'
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: awesome_print
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -218,7 +218,6 @@ files:
218
218
  - exe/peerflixrb
219
219
  - lib/peerflixrb.rb
220
220
  - lib/peerflixrb/commands.rb
221
- - lib/peerflixrb/imdb.rb
222
221
  - lib/peerflixrb/version.rb
223
222
  - lib/peerflixrb/yify.rb
224
223
  - peerflixrb.gemspec
@@ -242,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
241
  version: '0'
243
242
  requirements: []
244
243
  rubyforge_project:
245
- rubygems_version: 2.6.12
244
+ rubygems_version: 2.6.13
246
245
  signing_key:
247
246
  specification_version: 4
248
247
  summary: Wrapper for peerflix with automatic search through KickAss Torrents, Yifysubtitles
@@ -1,29 +0,0 @@
1
- require 'httparty'
2
- require 'json'
3
-
4
- module Peerflixrb
5
- module Imdb
6
- def self.find(title)
7
- params = { 'json' => '1', 'nr' => 1, 'tt' => 'on', 'q' => title }
8
- query = HTTParty.get('http://www.imdb.com/xml/find', query: params)
9
- results = JSON.load(query)['title_popular']
10
-
11
- # Return the most popular for that search
12
- Movie.new(results.first) if results
13
- end
14
-
15
- class Movie
16
- attr_accessor :imdb_id, :title, :year
17
-
18
- def initialize(params)
19
- @imdb_id = params['id']
20
- @title = params['title']
21
- @year = params['description'].match(/\A\d+/).to_s
22
- end
23
-
24
- def to_s
25
- "#{title} (#{year})"
26
- end
27
- end
28
- end
29
- end