peerflixrb 1.2.2 → 2.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: 3d5bfd2e6e48a703fab7ab9eff2e8c9d4960275b
4
- data.tar.gz: bb4a9d85db39f8a1ee04f73e64d7ff0c3f1c261f
3
+ metadata.gz: f0cb0f583c7db883a7ef20d98d274ccb5a6ee2e1
4
+ data.tar.gz: fa20922a85386110a328491309384981b382c684
5
5
  SHA512:
6
- metadata.gz: b8410d0412899e51698842a27cdb90eb4fc0304d37dfbc1fa16f01783f3722a5c85185fa32a05e6e784337e1feab509eea1f719c9ebee74b834ac6113c0e26b9
7
- data.tar.gz: fff747bbe765928ab2569aeeb6f307f9542e9d508e7b350a9da277e7c55115dba05340ce64c11216cd9f42040c476fe0d2c8f88cfe1312a85bf62616a24b8efe
6
+ metadata.gz: 421edc242e606f3fbc959470b672fc46775773676199b7a4545d73f898b84581a9c1545cb3c9e86115459020d997cca2343c2091376df820cd9e629899d87e8e
7
+ data.tar.gz: a4540f142630c2df0fb95703627224ee4c3ec4d735a4fe097fcbfac1e975d731d580bb25574471cf6e26f8349619149b1686614093f1be877d8d1720a8b81c71
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.3.1
4
4
  before_install: gem install bundler -v 1.11.2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Peerflixrb
4
4
 
5
- Wrapper for [peerflix](https://github.com/mafintosh/peerflix) with automatic search through [Kickass Torrents](kat.cr), [YifySubtitles](http://www.yifysubtitles.com/) and [Addic7ed](http://www.addic7ed.com/) (with [gem addic7ed](https://github.com/michaelbaudino/addic7ed-ruby)).
5
+ Wrapper for [peerflix](https://github.com/mafintosh/peerflix) with automatic search through [Kickass Torrents](kat.cr), [YifySubtitles](http://www.yifysubtitles.com/) and [Addic7ed](http://www.addic7ed.com/) (with [gem addic7ed_downloader](https://github.com/iovis9/addic7ed_downloader)).
6
6
 
7
7
 
8
8
  ## Requirements
@@ -20,7 +20,7 @@ Install the gem:
20
20
 
21
21
  ## Usage
22
22
 
23
- Pass a string with what you want to watch and it will search KAT with your query and present you with the first 5 results for you to choose. The file selected will then be sent to **peerflix**.
23
+ Pass a string with what you want to watch and it will search KAT with your query and present you with the first 5 results for you to choose. The file selected will then be sent to **peerflix**. For **TV Shows** use the format S01E01.
24
24
 
25
25
  $ peerflixrb Suits s05e12
26
26
  $ peerflixrb The Godfather II
@@ -34,6 +34,8 @@ You can play the video with subtitles with the ```-s``` option (Default: English
34
34
  $ peerflixrb -s Birdman
35
35
  $ peerflixrb -s The Wire s04e05
36
36
 
37
+ You can choose from a list which subtitle file to use with TV Shows with the option ```-S```.
38
+
37
39
  Choose the language with ```-l LANGUAGE``` ([Available Languages](https://github.com/michaelbaudino/addic7ed-ruby/blob/master/lib/addic7ed/common.rb)). Currently only for TV Shows (Choosing movie subtitles language will come soon!)
38
40
 
39
41
  $ peerflixrb -sl es-es Breaking Bad s05e03
@@ -42,9 +44,9 @@ If you prefer to use your own subtitles file, you can do that with the ```-t SUB
42
44
 
43
45
  $ peerflixrb Better Call Saul s02e04 -t subtitle_file.srt
44
46
 
45
- You can autoplay in VLC or MPlayer with the corresponding option (Default: VLC).
47
+ You can autoplay in VLC or mpv with the corresponding option (Default: VLC).
46
48
 
47
- $ peerflixrb --mplayer The Big Bang Theory s09e16 HDTV
49
+ $ peerflixrb --mpv The Big Bang Theory s09e16 HDTV
48
50
 
49
51
  Or you can just let it download without autoplaying with ```-n``` or ```--no-player```.
50
52
 
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'peerflixrb'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require 'pry'
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -13,10 +13,15 @@ options = {
13
13
  optparse = OptionParser.new do |opts|
14
14
  opts.banner = 'Usage: peerflixrb [options] <search>'
15
15
 
16
- opts.on('-s', '--find-subtitles', 'Find subtitles on Addic7ed') do
16
+ opts.on('-s', '--find-subtitles', 'Find subtitles') do
17
17
  options[:find_subtitles] = true
18
18
  end
19
19
 
20
+ opts.on('-S', '--choose-subtitles', 'Choose subtitles from Addic7ed') do
21
+ options[:find_subtitles] = true
22
+ options[:choose_subtitles] = true
23
+ end
24
+
20
25
  opts.on('-n', '--no-player', "Don't autoplay") do
21
26
  options[:video_player] = nil
22
27
  end
@@ -38,6 +43,7 @@ optparse = OptionParser.new do |opts|
38
43
  end
39
44
 
40
45
  opts.on('-l LANGUAGE', '--language LANGUAGE', 'Language code to look subtitles for (default: English)') do |l|
46
+ options[:find_subtitles] = true
41
47
  options[:language] = l
42
48
  end
43
49
 
@@ -67,7 +73,8 @@ end
67
73
 
68
74
  # main program
69
75
  begin
70
- cli = Peerflixrb::Commands::cli
76
+ commands = Peerflixrb::Commands.new
77
+ cli = commands.cli
71
78
 
72
79
  # KAT Search
73
80
  cli.say "Searching KAT for #{options[:search].blue}".yellow
@@ -80,7 +87,7 @@ begin
80
87
  end
81
88
 
82
89
  # Choose link and subtitles
83
- link, sub_file = Peerflixrb::Commands.choose_video_and_subtitles(kat_search, options)
90
+ link, sub_file = commands.choose_video_and_subtitles(kat_search, options)
84
91
 
85
92
  # Peerflix command build
86
93
  command = "peerflix '#{link.magnet}'"
@@ -1,25 +1,16 @@
1
- require 'addic7ed'
1
+ require 'addic7ed_downloader'
2
2
  require 'highline'
3
3
 
4
4
  module Peerflixrb
5
- module Commands
6
- class << self
7
- attr_accessor :cli
8
- end
9
-
10
- self.cli = HighLine.new
11
- HighLine.colorize_strings
12
-
13
- def self.select_link(kat_search)
14
- cli.say "Choose file (#{'seeders'.green}/#{'leechers'.red}):"
5
+ class Commands
6
+ attr_accessor :cli
15
7
 
16
- cli.choose(*kat_search.links) do |menu|
17
- menu.default = '1'
18
- menu.select_by = :index
19
- end
8
+ def initialize
9
+ @cli = HighLine.new
10
+ HighLine.colorize_strings
20
11
  end
21
12
 
22
- def self.choose_video_and_subtitles(kat_search, options)
13
+ def choose_video_and_subtitles(kat_search, options)
23
14
  # Proactively declare them because they would be lost in the block scope
24
15
  link = nil
25
16
  sub_file = nil
@@ -38,7 +29,7 @@ module Peerflixrb
38
29
 
39
30
  # Was there a problem with the subtitle?
40
31
  if options[:find_subtitles] && sub_file.nil?
41
- continue = cli.agree "Do you want to continue? #{'[y/n]'.yellow}".blue
32
+ continue = cli.agree "Could not find subtitles. Do you want to continue? #{'[y/n]'.yellow}".blue
42
33
 
43
34
  unless continue
44
35
  # If :auto_select, exit program
@@ -59,37 +50,44 @@ module Peerflixrb
59
50
  [link, sub_file]
60
51
  end
61
52
 
62
- # Helper methods (private)
63
- def self.find_subtitles(video_file, options)
64
- # Imdb search based on initial command input
65
- movie = Imdb.find(options[:search])
53
+ private
66
54
 
67
- if movie
68
- # TODO Choose language
69
- find_movie_subtitles(movie, 'english')
70
- else
71
- find_tv_subtitles(video_file, options[:language])
55
+ def select_link(kat_search)
56
+ cli.say "Choose file (#{'seeders'.green}/#{'leechers'.red}):"
57
+
58
+ cli.choose(*kat_search.links) do |menu|
59
+ menu.default = '1'
60
+ menu.select_by = :index
72
61
  end
73
62
  end
74
63
 
75
- def self.find_movie_subtitles(movie, language)
76
- sub_file = YifySubtitles.download(movie.imdb_id, language)
77
- return sub_file unless sub_file.nil?
78
- cli.say "Could not find subtitles for #{movie}".red
64
+ def find_subtitles(video_file, options)
65
+ # Matches format 's06e02'? => TV Show
66
+ if options[:search][/s\d{1,2}e\d{1,2}/i]
67
+ find_tv_subtitles(video_file, options)
68
+ else
69
+ movie = Imdb.find(options[:search])
70
+ find_movie_subtitles(movie, 'english')
71
+ end
79
72
  end
80
73
 
81
- def self.find_tv_subtitles(video_file, language)
74
+ def find_tv_subtitles(video_file, options)
82
75
  # TV Show search based on video filename
83
- episode = Addic7ed::Episode.new(video_file)
84
- return File.basename episode.download_best_subtitle!(language)
85
- rescue Addic7ed::EpisodeNotFound
86
- cli.say 'Episode not found on Addic7ed'.red
87
- rescue Addic7ed::ShowNotFound
88
- cli.say 'Show not found on Addic7ed'.red
89
- rescue Addic7ed::NoSubtitleFound
90
- cli.say 'No (acceptable) subtitle has been found on Addic7ed'.red
91
- rescue Addic7ed::InvalidFilename
92
- cli.say 'Addic7ed gem could not parse the filename correctly'.red
76
+ search = Addic7edDownloader::Search.by_string(options[:search], lang: options[:language], filename: video_file)
77
+ return search.download_best unless options[:choose_subtitles]
78
+
79
+ # Choose subtitle
80
+ subtitle = cli.choose(*search.results) do |menu|
81
+ menu.default = '1'
82
+ menu.select_by = :index
83
+ end
84
+
85
+ search.download_subtitle(subtitle)
86
+ end
87
+
88
+ def find_movie_subtitles(movie, language)
89
+ sub_file = YifySubtitles.download(movie.imdb_id, language)
90
+ return sub_file unless sub_file.nil?
93
91
  end
94
92
  end
95
93
  end
@@ -1,3 +1,3 @@
1
1
  module Peerflixrb
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -44,6 +44,7 @@ module Peerflixrb
44
44
  end
45
45
  end
46
46
 
47
+ # return subtitle filename
47
48
  sub_file
48
49
  end
49
50
  end
data/lib/peerflixrb.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'peerflixrb/version'
1
+ require 'peerflixrb/imdb'
2
2
  require 'peerflixrb/kat'
3
3
  require 'peerflixrb/link'
4
- require 'peerflixrb/imdb'
4
+ require 'peerflixrb/version'
5
5
  require 'peerflixrb/yify'
data/peerflixrb.gemspec CHANGED
@@ -15,17 +15,17 @@ Gem::Specification.new do |spec|
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'bin'
18
+ spec.bindir = 'exe'
19
19
  spec.executables = 'peerflixrb'
20
20
  spec.require_paths = ['lib']
21
21
 
22
+ spec.add_runtime_dependency 'addic7ed_downloader', '~> 0.1'
22
23
  spec.add_runtime_dependency 'nokogiri', '~> 1.6'
23
- spec.add_runtime_dependency 'addic7ed', '~> 2.0'
24
24
  spec.add_runtime_dependency 'highline', '~> 1.7'
25
25
  spec.add_runtime_dependency 'httparty', '~> 0.13'
26
26
  spec.add_runtime_dependency 'rubyzip', '~> 1.2'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.11'
28
+ spec.add_development_dependency 'bundler', '~> 1.12'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
31
31
  spec.add_development_dependency 'guard-rspec', '~> 4.6'
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peerflixrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Marchante
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2016-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: addic7ed_downloader
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '0.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '0.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: addic7ed
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '1.6'
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: '2.0'
40
+ version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: highline
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.11'
89
+ version: '1.12'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.11'
96
+ version: '1.12'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,9 @@ files:
208
208
  - LICENSE.txt
209
209
  - README.md
210
210
  - Rakefile
211
- - bin/peerflixrb
211
+ - bin/console
212
+ - bin/setup
213
+ - exe/peerflixrb
212
214
  - lib/peerflixrb.rb
213
215
  - lib/peerflixrb/commands.rb
214
216
  - lib/peerflixrb/imdb.rb