peerflixrb 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -8
- data/bin/peerflixrb +32 -28
- data/lib/peerflixrb.rb +29 -4
- data/lib/peerflixrb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be0fd92f01b850ea44badcb38422e6c68c4e6c5
|
4
|
+
data.tar.gz: 866101d388447ad1b22034a39980854625398ad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b219e41fa771fcca740a82e682c1435e787d0027242d592bc36e8af310007818bb86a8318773ffd73017bafc624727c1e9e01c976bbf5e14ed49fa2637564bd0
|
7
|
+
data.tar.gz: 9609223d1a4b787afff08c045b1fca142d059263ff27491a37261fec1750c1fda3145e01ccf25b033adcfca535aa32310720e24132746e219e02c83c70801f5e
|
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) 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) and [Addic7ed](http://www.addic7ed.com/) (with [gem addic7ed](https://github.com/michaelbaudino/addic7ed-ruby)).
|
6
6
|
|
7
7
|
|
8
8
|
## Requirements
|
@@ -11,8 +11,6 @@ Make sure you have **peerflix** installed:
|
|
11
11
|
|
12
12
|
$ npm install -g peerflix
|
13
13
|
|
14
|
-
It currently supports VLC only as the media player (more to come in future releases).
|
15
|
-
|
16
14
|
|
17
15
|
## Installation
|
18
16
|
Install the gem:
|
@@ -28,7 +26,7 @@ Pass a string with what you want to watch and it will try to fetch the file and
|
|
28
26
|
|
29
27
|
You can play the video with subtitles with the ```-s``` option (Default: English). It will try and find the best match in [Addic7ed](http://www.addic7ed.com/).
|
30
28
|
|
31
|
-
$ peerflixrb -s Game Of Thrones S05E01
|
29
|
+
$ peerflixrb -s Game Of Thrones S05E01 1080p
|
32
30
|
|
33
31
|
Choose the language with ```-l LANGUAGE``` ([Available Languages](https://github.com/michaelbaudino/addic7ed-ruby/blob/master/lib/addic7ed/common.rb))
|
34
32
|
|
@@ -36,14 +34,17 @@ Choose the language with ```-l LANGUAGE``` ([Available Languages](https://github
|
|
36
34
|
|
37
35
|
If you prefer to use your own subtitles file, you can do that with the ```-t SUBTITLE_FILE``` option.
|
38
36
|
|
39
|
-
$
|
37
|
+
$ peerflixrb better call saul s02e04 -t subtitle_file.srt
|
38
|
+
|
39
|
+
You can autoplay in VLC or MPlayer with the corresponding option.
|
40
40
|
|
41
|
+
$ peerflixrb --vlc the big bang theory s09e16 hdtv
|
41
42
|
|
42
|
-
## Future plans
|
43
43
|
|
44
|
-
|
45
|
-
- Choose player (currently VLC).
|
44
|
+
## Cache
|
46
45
|
|
46
|
+
The original peerflix takes care of cache so you can resume your downloads or watch them again.
|
47
|
+
peerflixrb will tell you where they are located so you can do as you like or leave them there till your OS takes care of it (it's stored in /tmp).
|
47
48
|
|
48
49
|
## Contributing
|
49
50
|
|
data/bin/peerflixrb
CHANGED
@@ -1,18 +1,25 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby -w
|
2
2
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib ))
|
3
3
|
|
4
|
-
require 'addic7ed'
|
5
4
|
require 'optparse'
|
6
5
|
require 'peerflixrb'
|
7
6
|
|
8
7
|
options = {}
|
9
|
-
OptionParser.new do |opts|
|
8
|
+
optparse = OptionParser.new do |opts|
|
10
9
|
opts.banner = 'Usage: peerflixrb [options] <search>'
|
11
10
|
|
12
11
|
opts.on('-s', '--find-subtitles', 'Find subtitles on Addic7ed') do |s|
|
13
12
|
options[:find_subtitles] = s
|
14
13
|
end
|
15
14
|
|
15
|
+
opts.on('-m', '--mplayer', 'Autoplay in mplayer*') do
|
16
|
+
options[:video_player] = 'mplayer'
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on('-v', '--vlc', 'Autoplay in vlc*') do
|
20
|
+
options[:video_player] = 'vlc'
|
21
|
+
end
|
22
|
+
|
16
23
|
opts.on('-t SUBTITLE_FILE', '--subtitles SUBTITLE_FILE', 'Use local subtitles') do |t|
|
17
24
|
options[:subtitles] = t
|
18
25
|
end
|
@@ -23,47 +30,44 @@ OptionParser.new do |opts|
|
|
23
30
|
|
24
31
|
opts.on_tail('-h', '--help', 'Show this message') do
|
25
32
|
puts opts
|
33
|
+
puts '* Autoplay can take several seconds to start since it needs to wait for the first piece'
|
26
34
|
exit
|
27
35
|
end
|
28
|
-
end
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
options[:language] ||= 'en'
|
38
|
+
optparse.parse!
|
32
39
|
|
33
40
|
# Join arguments to create the search term
|
34
|
-
options[:search] = ARGV.join
|
35
|
-
|
41
|
+
options[:search] = ARGV.join(' ')
|
42
|
+
if options[:search].empty?
|
43
|
+
puts optparse # Show usage if no search
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
# Default language: English
|
48
|
+
options[:language] ||= 'en'
|
36
49
|
|
37
50
|
# main
|
38
51
|
# TODO: handle failing and invalid searches
|
39
52
|
kat = Peerflixrb::KAT.new(options[:search])
|
53
|
+
cache_dir = "/tmp/torrent-stream/#{kat.info_hash}"
|
40
54
|
|
41
55
|
# Subtitle search
|
42
|
-
if options[:find_subtitles]
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
puts "Episode not found on Addic7ed : #{ep.video_file.filename}."
|
48
|
-
rescue Addic7ed::ShowNotFound
|
49
|
-
puts "Show not found on Addic7ed : #{ep.video_file.filename}."
|
50
|
-
rescue Addic7ed::NoSubtitleFound
|
51
|
-
puts "No (acceptable) subtitle has been found on Addic7ed for #{ep.video_file.filename}."
|
52
|
-
rescue Addic7ed::InvalidFilename
|
53
|
-
puts "Addic7ed gem doesn't like the format passed. Skipping subtitles."
|
54
|
-
end
|
55
|
-
end
|
56
|
+
sub_file = if options[:find_subtitles]
|
57
|
+
Peerflixrb.find_subtitles(kat.filename, options[:language])
|
58
|
+
elsif options[:subtitles]
|
59
|
+
options[:subtitles]
|
60
|
+
end
|
56
61
|
|
57
62
|
# Peerflix command build
|
58
63
|
command = "peerflix '#{kat.magnet}'"
|
59
|
-
command << " --subtitles '#{sub_file}'"
|
60
|
-
command << "
|
61
|
-
# TODO: choose video player (default: VLC)
|
62
|
-
command << ' --vlc'
|
63
|
-
# TODO: pipe options and leave these as default
|
64
|
+
command << " --subtitles '#{sub_file}'" if sub_file
|
65
|
+
command << " --#{options[:video_player]}" if options[:video_player]
|
64
66
|
command << ' -- --fullscreen'
|
65
67
|
|
66
68
|
system command
|
67
69
|
|
68
70
|
# Cleaning up
|
69
|
-
|
71
|
+
video_file = Dir["#{cache_dir}/**/*.{mkv,mp4,avi,wmv,mpg,flv,mov}"].first
|
72
|
+
FileUtils.cp(sub_file, File.dirname(video_file)) if sub_file
|
73
|
+
puts "Your downloads will be in #{cache_dir} for 3 days :)"
|
data/lib/peerflixrb.rb
CHANGED
@@ -1,15 +1,30 @@
|
|
1
|
-
require '
|
1
|
+
require 'addic7ed'
|
2
|
+
require 'cgi'
|
3
|
+
require 'erb'
|
2
4
|
require 'nokogiri'
|
3
5
|
require 'open-uri'
|
4
|
-
require '
|
6
|
+
require 'peerflixrb/version'
|
5
7
|
require 'yaml'
|
6
8
|
|
7
9
|
module Peerflixrb
|
10
|
+
def self.find_subtitles(video_file, language)
|
11
|
+
episode = Addic7ed::Episode.new(video_file)
|
12
|
+
return File.basename episode.download_best_subtitle!(language)
|
13
|
+
rescue Addic7ed::EpisodeNotFound
|
14
|
+
puts "Episode not found on Addic7ed : #{episode.video_file.filename}."
|
15
|
+
rescue Addic7ed::ShowNotFound
|
16
|
+
puts "Show not found on Addic7ed : #{episode.video_file.filename}."
|
17
|
+
rescue Addic7ed::NoSubtitleFound
|
18
|
+
puts "No (acceptable) subtitle has been found on Addic7ed for #{episode.video_file.filename}."
|
19
|
+
rescue Addic7ed::InvalidFilename
|
20
|
+
puts "Addic7ed gem doesn't like the format passed. Skipping subtitles."
|
21
|
+
end
|
22
|
+
|
8
23
|
##
|
9
24
|
# Extract file info and magnet link from the first match of your search
|
10
25
|
# KAT.new("Suits s05e16 1080p")
|
11
26
|
class KAT
|
12
|
-
attr_accessor :url
|
27
|
+
attr_accessor :url
|
13
28
|
|
14
29
|
def initialize(search)
|
15
30
|
@url = "https://kat.cr/usearch/#{ERB::Util.url_encode(search)}/"
|
@@ -20,17 +35,27 @@ module Peerflixrb
|
|
20
35
|
end
|
21
36
|
|
22
37
|
def filename
|
23
|
-
@filename ||= CGI.unescape(params['name'])
|
38
|
+
@filename ||= "#{CGI.unescape(params['name'])}.#{params['extension']}"
|
24
39
|
end
|
25
40
|
|
26
41
|
def magnet
|
27
42
|
@magnet ||= params['magnet']
|
28
43
|
end
|
29
44
|
|
45
|
+
def info_hash
|
46
|
+
@info_hash ||= extract_hash
|
47
|
+
end
|
48
|
+
|
30
49
|
private
|
31
50
|
|
32
51
|
def params
|
33
52
|
@params ||= YAML.load page.at_css('.iaconbox > div')['data-sc-params']
|
34
53
|
end
|
54
|
+
|
55
|
+
def extract_hash
|
56
|
+
# Extract magnet properties to a Hash
|
57
|
+
magnet_params = CGI.parse(URI.parse(magnet).query)
|
58
|
+
magnet_params['xt'].first.match(/[0-9A-F]+/).to_s.downcase
|
59
|
+
end
|
35
60
|
end
|
36
61
|
end
|
data/lib/peerflixrb/version.rb
CHANGED