imdb-terminal 0.3 → 0.5
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/bin/imdb +73 -23
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a157e3f4954b72f59329e6ce485b34e3ca49a0b38ec1b2d4340427cf206134a6
|
4
|
+
data.tar.gz: 3dce0f77bb85d3c5ad98ea7d36fdfb84bb24d1c7d64f06ae9d9aa191487f2d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f2b6af0c5eef9f3f5158319e3377891005b3e854d0ebc9d5ce28ee88202a5762f9a4428877293b7aa12753536fca24f6fdcd9fdf255ef616d66e8ea2c24f4cb
|
7
|
+
data.tar.gz: f31e0de6386c7960203fdc256f112f2fd38fae342de3e9036bf5205670ccd98778cc871b45886cf09f14ce1f92072d9a7b5a3f4cb30ebd334d06c14616f2a08a
|
data/bin/imdb
CHANGED
@@ -117,40 +117,87 @@ end
|
|
117
117
|
|
118
118
|
# CLASSES
|
119
119
|
class Curses::Window # CLASS EXTENSION
|
120
|
-
attr_accessor :fg, :bg, :attr, :text, :index, :list, :update
|
121
120
|
# General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
|
122
|
-
|
121
|
+
# This is a class extension to Ruby Curses - a class in dire need of such.
|
122
|
+
# self.pair keeps a registry of colors as they are encountered - defined with:
|
123
|
+
# init_pair(index, foreground, background)
|
124
|
+
# self.fg is set for the foreground color
|
125
|
+
# self.bg is set for the background color
|
126
|
+
# self.attr is set for text attributes like Curses::A_BOLD
|
127
|
+
# self.update can be used to indicate if a window should be updated (true/false)
|
128
|
+
# self.index can be used to keep track of the current list item in a window
|
129
|
+
attr_accessor :fg, :bg, :attr, :text, :update, :index, :list
|
130
|
+
def self.pair(fg, bg)
|
131
|
+
@p = [[]] if @p == nil
|
132
|
+
fg = fg.to_i; bg = bg.to_i
|
133
|
+
if @p.include?([fg,bg])
|
134
|
+
@p.index([fg,bg])
|
135
|
+
else
|
136
|
+
@p.push([fg,bg])
|
137
|
+
cp = @p.index([fg,bg])
|
138
|
+
init_pair(cp, fg, bg)
|
139
|
+
@p.index([fg,bg])
|
140
|
+
end
|
141
|
+
end
|
142
|
+
def clr # Clears the whole window
|
123
143
|
self.setpos(0, 0)
|
124
144
|
self.maxy.times {self.deleteln()}
|
125
145
|
self.refresh
|
126
146
|
self.setpos(0, 0)
|
127
147
|
end
|
128
|
-
def fill # Fill window with color as set by
|
148
|
+
def fill # Fill window with color as set by self.color (or self.bg if not set)
|
149
|
+
self.setpos(0, 0)
|
150
|
+
self.fill_from_cur_pos
|
151
|
+
end
|
152
|
+
def fill_to_cur_pos # Fills the window up to current line
|
153
|
+
x = self.curx
|
154
|
+
y = self.cury
|
129
155
|
self.setpos(0, 0)
|
130
156
|
self.bg = 0 if self.bg == nil
|
131
157
|
self.fg = 255 if self.fg == nil
|
132
|
-
xor = self.fg ^ self.bg
|
133
|
-
init_pair(xor, self.fg, self.bg)
|
134
158
|
blank = " " * self.maxx
|
135
|
-
self.
|
159
|
+
cp = Curses::Window.pair(self.fg, self.bg)
|
160
|
+
y.times {self.attron(color_pair(cp)) {self << blank}}
|
136
161
|
self.refresh
|
137
|
-
self.setpos(
|
162
|
+
self.setpos(y, x)
|
138
163
|
end
|
139
|
-
def
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
164
|
+
def fill_from_cur_pos # Fills the rest of the window from current line
|
165
|
+
x = self.curx
|
166
|
+
y = self.cury
|
167
|
+
self.setpos(y, 0)
|
168
|
+
self.bg = 0 if self.bg == nil
|
169
|
+
self.fg = 255 if self.fg == nil
|
170
|
+
blank = " " * self.maxx
|
171
|
+
cp = Curses::Window.pair(self.fg, self.bg)
|
172
|
+
self.maxy.times {self.attron(color_pair(cp)) {self << blank}}
|
173
|
+
self.refresh
|
174
|
+
self.setpos(y, x)
|
175
|
+
end
|
176
|
+
def write
|
144
177
|
self.attr = 0 if self.attr == nil
|
145
|
-
self.
|
178
|
+
self.bg = 0 if self.bg == nil
|
179
|
+
self.fg = 255 if self.fg == nil
|
180
|
+
cp = Curses::Window.pair(self.fg, self.bg)
|
181
|
+
self.attron(color_pair(cp) | self.attr) { self << self.text }
|
146
182
|
self.refresh
|
147
|
-
self.text = ""
|
148
183
|
end
|
149
|
-
def p(
|
150
|
-
|
151
|
-
self.
|
184
|
+
def p(text) # Puts text to window
|
185
|
+
self.attr = 0 if self.attr == nil
|
186
|
+
self.bg = 0 if self.bg == nil
|
187
|
+
self.fg = 255 if self.fg == nil
|
188
|
+
cp = Curses::Window.pair(self.fg, self.bg)
|
189
|
+
self.attron(color_pair(cp) | attr) { self << text }
|
190
|
+
self.refresh
|
191
|
+
end
|
192
|
+
def pa(fg = self.fg, bg = self.bg, attr = self.attr, text) # Puts text to window with full set of attributes
|
193
|
+
cp = Curses::Window.pair(fg, bg)
|
194
|
+
self.attron(color_pair(cp) | attr) { self << text }
|
152
195
|
self.refresh
|
153
196
|
end
|
197
|
+
def format_text(text) # Format text so that it linebreaks neatly inside window
|
198
|
+
return "\n" + text.gsub(/(.{1,#{self.maxx}})( +|$\n?)|(.{1,#{self.maxx}})/, "\\1\\3\n")
|
199
|
+
end
|
200
|
+
alias :puts :p
|
154
201
|
end
|
155
202
|
|
156
203
|
# GENERIC FUNCTIONS
|
@@ -504,8 +551,10 @@ end
|
|
504
551
|
|
505
552
|
# BASIC WINDOW FUNCTIONS
|
506
553
|
def w_t # SHOW INFO IN @w_t
|
554
|
+
@w_t.clr
|
507
555
|
@movies ? @w_t.text = " MOVIES :: " : @w_t.text = " SERIES :: "
|
508
556
|
@w_t.text += "Rating MIN: #{@rating} - Year MIN: #{@yearMin} - Year MAX: #{@yearMax} :: Selection = #{@imdbsel.size}"
|
557
|
+
@w_t.text += " " * (@w_t.maxx - @w_t.text.length) if @w_t.text.length < @w_t.maxx
|
509
558
|
@w_t.write
|
510
559
|
end
|
511
560
|
def w_list(win) # LIST IN WINDOW
|
@@ -572,11 +621,12 @@ def w_d(ext = 0) # SHOW INFO IN @w_d and @w_p
|
|
572
621
|
list = @active.list
|
573
622
|
return if list.empty? # Skip if list is empty
|
574
623
|
id = list[@active.index][4]
|
624
|
+
@w_d.clr
|
575
625
|
@w_d.text = "#{list[@active.index][0]}\n\n"
|
576
626
|
@w_d.attr = Curses::A_BOLD
|
577
627
|
@w_d.write
|
578
628
|
@w_d.attr = 0
|
579
|
-
@w_d.text
|
629
|
+
@w_d.text = "Rating: " + list[@active.index][1].to_s.ljust(14) + "Genres: #{list[@active.index][3]}\n"
|
580
630
|
@w_d.write
|
581
631
|
return unless ext > 0 # Skip if no details are to be displayed
|
582
632
|
det = getomdb(id)
|
@@ -600,7 +650,7 @@ def w_d(ext = 0) # SHOW INFO IN @w_d and @w_p
|
|
600
650
|
imageshow("/tmp/imdb.jpg")
|
601
651
|
return unless ext > 1 # Skip if no outlets are to be displayed
|
602
652
|
otl.each{|o| outlets += "#{o} "}
|
603
|
-
@w_d.text
|
653
|
+
@w_d.text = "Outlets: " + outlets
|
604
654
|
@w_d.write
|
605
655
|
end
|
606
656
|
def imageshow(image)
|
@@ -716,10 +766,11 @@ end
|
|
716
766
|
loop do # OUTER LOOP - (catching refreshes via 'r')
|
717
767
|
@break = false # Initialize @break variable (set if user hits 'r')
|
718
768
|
begin # Create the windows/panels
|
719
|
-
Curses.stdscr.bg = 234 # Use for borders
|
720
|
-
Curses.stdscr.fill
|
721
769
|
maxx = Curses.cols
|
722
770
|
maxy = Curses.lines
|
771
|
+
init_pair(255, 0, 234)
|
772
|
+
maxy.times {Curses.stdscr.attron(color_pair(255)) {Curses.stdscr << " " * maxx}}
|
773
|
+
Curses.stdscr.refresh
|
723
774
|
# Curses::Window.new( h, w, y, x )
|
724
775
|
@w_t = Curses::Window.new( 1, maxx, 0, 0 )
|
725
776
|
@w_i = Curses::Window.new( maxy-2, 40, 1, 0 )
|
@@ -737,7 +788,6 @@ loop do # OUTER LOOP - (catching refreshes via 'r')
|
|
737
788
|
@w_p.fg, @w_p.bg = Wpfg, WIbg
|
738
789
|
@w_b.fg, @w_b.bg = Wbfg, Wbbg
|
739
790
|
[@w_i, @w_g, @w_m, @w_n].each{|w| w.index = 0}
|
740
|
-
@w_b.fill
|
741
791
|
@w_g.list = @genres
|
742
792
|
@w_b.update = true
|
743
793
|
@w_d.update = true
|
@@ -754,7 +804,7 @@ loop do # OUTER LOOP - (catching refreshes via 'r')
|
|
754
804
|
@search == '' ? @w_t.bg = WtSbg : @w_t.bg = WtSbgS
|
755
805
|
@w_t.attr = Curses::A_BOLD
|
756
806
|
end
|
757
|
-
@
|
807
|
+
@w_i.fill; @w_g.fill; @w_m.fill; @w_n.fill; @w_p.fill
|
758
808
|
w_t; w_list(@w_i); w_list(@w_g); w_list(@w_m); w_list(@w_n)
|
759
809
|
if @w_d.update
|
760
810
|
@w_d.fill
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imdb-terminal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -30,11 +30,25 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.3.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rest-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
33
47
|
description: 'Narrow down your preferences from a 1000 movies and almost 500 series.
|
34
48
|
Select a minimum IMDB rating, range of production years, genres you like and dislike
|
35
49
|
to get your preferred list. Get detailed information on movies and series and where
|
36
50
|
you can stream them. Even the movie poster in the terminal. New in 0.2: Added ''v''
|
37
|
-
to show version and RubyGem version. Code cleanup. 0.
|
51
|
+
to show version and RubyGem version. Code cleanup. 0.5: Fixed bug in viewing details'
|
38
52
|
email: g@isene.com
|
39
53
|
executables:
|
40
54
|
- imdb
|