cinema 2.1.0 → 2.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/lib/cinema.rb +34 -14
- data/lib/cinema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 40198843fe3c5d3b28ff47d8f262003c8a31ff97
|
|
4
|
+
data.tar.gz: bd9fe004867afdb96c052cdc3c92f7ef52f33474
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b00d6cbcb7b576bcad702bf33aa4822633151706117b6b949c9b4bf6b6501f0bd9c99436cae180cebe02b87c70cb814012a7fe98e4f2eeb0d304975cf401262
|
|
7
|
+
data.tar.gz: 3244358108007330ec72320b8398204b028e3c1126bb9cea806b0e9922362a7c961c97c360bd4dfa9ed78871fa021cf6ec352b07519adb2576ecdb1ce24c9e70
|
data/lib/cinema.rb
CHANGED
|
@@ -11,19 +11,23 @@ module Cinema
|
|
|
11
11
|
APP_ID="69f18bbaff859f035d934888f846b7ae3653e223a2b0f15629bcc9b836d3996b"
|
|
12
12
|
APP_SECRET="077edf5024fca4102295263e802631f52f8cebd404f612194279f059bc5d9b8d"
|
|
13
13
|
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
def get_sorting_options(sample)
|
|
15
|
+
sample.reduce([]) do |result, (k,v)|
|
|
16
|
+
if v.is_a? Hash
|
|
17
|
+
child_sorting_options = get_sorting_options(v).map do |name, accessor|
|
|
18
|
+
["#{k} #{name}", ->(x){ accessor.(x[k]) }]
|
|
19
|
+
end
|
|
20
|
+
result.concat child_sorting_options
|
|
21
|
+
else
|
|
22
|
+
result << [k.to_s, ->(x){ x[k] }]
|
|
23
|
+
end
|
|
21
24
|
end
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def run_torrent(downloader, torrent)
|
|
24
28
|
case downloader
|
|
25
29
|
when 'peerflix'
|
|
26
|
-
player = select("Select player", ["mplayer","vlc"]
|
|
30
|
+
player = select("Select player", ["mplayer","vlc"])
|
|
27
31
|
system downloader, torrent, "--#{player}"
|
|
28
32
|
when 'qbittorrent'
|
|
29
33
|
system "sh", "-c", "#{downloader} #{torrent} &"
|
|
@@ -32,20 +36,36 @@ module Cinema
|
|
|
32
36
|
end
|
|
33
37
|
end
|
|
34
38
|
|
|
35
|
-
def
|
|
36
|
-
|
|
39
|
+
def ask_and_play
|
|
40
|
+
watchlist = get_watchlist
|
|
41
|
+
sorting_options = get_sorting_options(watchlist.first)
|
|
42
|
+
sort_getter = select("Order movie list by", sorting_options, &:first).last
|
|
43
|
+
|
|
44
|
+
imdb_id = select("Select movie", watchlist.sort_by{|x| sort_getter.(x)}){ |x|
|
|
45
|
+
"#{sort_getter.(x)}: #{x["movie"]["title"]}"
|
|
46
|
+
}["movie"]["ids"]["imdb"]
|
|
47
|
+
|
|
48
|
+
torrent = select("Select quality", torrents(imdb_id)){|x| x["quality"] }["url"]
|
|
49
|
+
downloader = select("Select downloader", ["peerflix", "qbittorrent", "wget", "echo"])
|
|
50
|
+
run_torrent(downloader, torrent)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def select(title, items, &title_proc)
|
|
54
|
+
menu_items = items.each_with_index.map do |x,i|
|
|
55
|
+
[i.to_s, (title_proc ? title_proc.(x) : x)]
|
|
56
|
+
end
|
|
37
57
|
index = capture_stderr do
|
|
38
58
|
success = system 'dialog', '--title', title,
|
|
39
59
|
'--menu', '', '0', '0', '0',
|
|
40
60
|
*menu_items.flatten
|
|
41
61
|
unless success
|
|
42
|
-
|
|
62
|
+
exit 0
|
|
43
63
|
end
|
|
44
64
|
end
|
|
45
65
|
items[index.to_i] if index
|
|
46
66
|
end
|
|
47
67
|
|
|
48
|
-
def
|
|
68
|
+
def get_watchlist
|
|
49
69
|
with_unreliable_api do
|
|
50
70
|
puts "Requesting watchlist..."
|
|
51
71
|
trakt_request(:get, "sync/watchlist/movies")
|
data/lib/cinema/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cinema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ales Guzik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-07-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|