in_our_time 0.3.2 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf0d05644a0136dc6303c04a2f5337f9f0120b40
4
- data.tar.gz: 164058d08b3fa8ed5c712b93b907a209afb00790
3
+ metadata.gz: 2cf2c996c094b425c9b23dfdc1d333be877ad11b
4
+ data.tar.gz: 27014f8d06c891f07bcb92db25325718d08affc6
5
5
  SHA512:
6
- metadata.gz: 8090701ea1243be0213807a7b10540b6d6b1e5c5a28a3a73e069d4f99f62c560f40c74c05fb0064870b03b57b2163c8f77be5c650667bc6a0928a246249d0290
7
- data.tar.gz: 070414c04c8b5722e226e41e0b179107ac97fd0defe7424a9b9a19077055c76dc30c4ce11082c3b569e0ee869b9a4375792609d5eb65dc9383ae36dc88e34d27
6
+ metadata.gz: c124de122df9bc9ac02db4c35461e48ca010a3d99a806e222ef5ec5108512e2a4ff9b931afc1b741c38a99f4a86dd24f1f4a9e97176792850bacb6bc74db8c67
7
+ data.tar.gz: e6b1afc628991379da911fdcd8a4a6cd051859c05f396e085b765658779758d3e35f119d63d47721148caef008fd7c58c01f24f49661690d09ea945586d0e626
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/in_our_time.svg)](https://badge.fury.io/rb/in_our_time)
2
+
1
3
  ## In Our Time
2
4
 
3
5
  Select, automatically download, and play **BBC In Our Time** podcasts easily, from the command line.
@@ -8,9 +10,13 @@ Podcast is archived locally for offline access in the future.
8
10
 
9
11
  Regularly checks for new podcasts.
10
12
 
11
- ![compile image](https://raw.githubusercontent.com/mjago/In_Our_Time/master/light_theme.png)
13
+ - Light Theme
14
+
15
+ ![compile image](https://raw.githubusercontent.com/mjago/In_Our_Time/master/images/light_theme.png)
16
+
17
+ - Dark Theme
12
18
 
13
- ![compile image](https://raw.githubusercontent.com/mjago/In_Our_Time/master/dark_theme.png)
19
+ ![compile image](https://raw.githubusercontent.com/mjago/In_Our_Time/master/images/dark_theme.png)
14
20
 
15
21
  ## Installation:
16
22
 
@@ -24,7 +30,7 @@ Config can be found at '~/.in_our_time/config.yml'
24
30
 
25
31
  ## mp3 player:
26
32
 
27
- By default uses **afplay** as the media player but gains **Forward skip**, **Reverse Skip**, **Pause** and **Resume** controls when used with - [mpg123](https://www.mpg123.de/). Install **mpg123** and modify the config.yml file to use **mpg123**:
33
+ By default uses **afplay** as the media player but gains **Forward skip**, **Reverse Skip**, **Pause** and **Resume** controls when used with [mpg123](https://www.mpg123.de/). Install **mpg123** and modify the config.yml file to use **mpg123**:
28
34
 
29
35
  ```sh
30
36
  :mpg_player: :mpg123
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.4
File without changes
File without changes
data/lib/iot/iot.rb CHANGED
@@ -48,61 +48,65 @@ class InOurTime
48
48
  end
49
49
 
50
50
  def run
51
- loop do
52
- str = ''
51
+ Thread.new do
53
52
  loop do
54
- str = STDIN.getch
55
- if str == "\e"
56
- @mode = :escape
57
- else
58
- case @mode
59
- when :escape
60
- if str == "["
61
- @mode = :escape_2
62
- else
53
+ str = ''
54
+ loop do
55
+ str = STDIN.getch
56
+ if str == "\e"
57
+ @mode = :escape
58
+ else
59
+ case @mode
60
+ when :escape
61
+ if str == "["
62
+ @mode = :escape_2
63
+ else
64
+ @mode = :normal
65
+ end
66
+ when :escape_2
67
+ @event = :previous if str == "A"
68
+ @event = :next if str == "B"
69
+ @event = :page_forward if str == "C"
70
+ @event = :previous if str == "D"
63
71
  @mode = :normal
64
- end
65
- when :escape_2
66
- @event = :previous if str == "A"
67
- @event = :next if str == "B"
68
- @event = :page_forward if str == "C"
69
- @event = :previous if str == "D"
70
- @mode = :normal
71
72
 
72
- else
73
- break if @event == :no_event
73
+ else
74
+ break if @event == :no_event
75
+ end
74
76
  end
77
+ ke_events
75
78
  end
76
- ke_events
77
- end
78
79
 
79
- case str
80
- when "\e"
81
- @mode = :escape
82
- when "l",'L'
83
- @event = :list
84
- when ' '
85
- @event = :page_forward
86
- when "q",'Q', "\u0003", "\u0004"
87
- @event = :quit
88
- when 'p', 'P'
89
- @event = :pause
90
- when 'f', 'F'
91
- @event = :forward
92
- when 'r', 'R'
93
- @event = :rewind
94
- when 's', 'S'
95
- @event = :sort
96
- when 'x', 'X', "\r"
97
- @event = :play
98
- when 'i', 'I'
99
- @event = :info
100
- when '?', 'h'
101
- @event = :help
102
- else
103
- @event = :no_event
80
+ case str
81
+ when "\e"
82
+ @mode = :escape
83
+ when "l",'L'
84
+ @event = :list
85
+ when "u",'U'
86
+ @event = :update
87
+ when ' '
88
+ @event = :page_forward
89
+ when "q",'Q', "\u0003", "\u0004"
90
+ @event = :quit
91
+ when 'p', 'P'
92
+ @event = :pause
93
+ when 'f', 'F'
94
+ @event = :forward
95
+ when 'r', 'R'
96
+ @event = :rewind
97
+ when 's', 'S'
98
+ @event = :sort
99
+ when 'x', 'X', "\r"
100
+ @event = :play
101
+ when 'i', 'I'
102
+ @event = :info
103
+ when '?', 'h'
104
+ @event = :help
105
+ else
106
+ @event = :no_event
107
+ end
108
+ ke_events
104
109
  end
105
- ke_events
106
110
  end
107
111
  end
108
112
  end
@@ -113,9 +117,11 @@ class InOurTime
113
117
  end
114
118
 
115
119
  def run
116
- loop do
117
- sleep 1
118
- @flag = true
120
+ Thread.new do
121
+ loop do
122
+ sleep 1
123
+ @flag = true
124
+ end
119
125
  end
120
126
  end
121
127
 
@@ -127,7 +133,6 @@ class InOurTime
127
133
 
128
134
  def initialize
129
135
  @programs, @selected = [], 0
130
- @lock = Mutex.new
131
136
  setup
132
137
  load_config
133
138
  load_version
@@ -260,7 +265,7 @@ class InOurTime
260
265
 
261
266
  def filename_from_title title
262
267
  temp = title.gsub(/[^0-9a-z ]/i, '').gsub(' ', '_').strip + '.mp3'
263
- File.join(File.join IN_OUR_TIME, AUDIO_DIRECTORY, temp.downcase)
268
+ File.join IN_OUR_TIME, AUDIO_DIRECTORY, temp.downcase
264
269
  end
265
270
 
266
271
  def download_audio program, addr
@@ -280,27 +285,27 @@ class InOurTime
280
285
 
281
286
  def have_locally? title
282
287
  filename = filename_from_title(title)
283
- if File.exists?(filename)
284
- return true
285
- end
286
- false
288
+ File.exists?(filename) ? true : false
287
289
  end
288
290
 
289
291
  def rss_files
290
292
  local_rss.map{|f| File.join IN_OUR_TIME, RSS_DIRECTORY, f }
291
293
  end
292
294
 
293
- def check_remote
294
- if update_remote?
295
- iot_print "Checking rss feeds ", @system_colour
296
- local_rss.length.times do |count|
297
- iot_print '.', @system_colour
298
- fetch_uri rss_addresses[count], rss_files[count]
299
- end
300
- iot_puts
301
- @config[:last_update] = now
302
- save_config
295
+ def update
296
+ clear
297
+ iot_print "Checking rss feeds ", @system_colour
298
+ local_rss.length.times do |count|
299
+ iot_print '.', @system_colour
300
+ fetch_uri rss_addresses[count], rss_files[count]
303
301
  end
302
+ iot_puts
303
+ @config[:last_update] = now
304
+ save_config
305
+ end
306
+
307
+ def check_remote
308
+ update if update_remote?
304
309
  end
305
310
 
306
311
  def uniquify_programs
@@ -337,11 +342,7 @@ class InOurTime
337
342
  end
338
343
 
339
344
  def select_program title
340
- @programs.each do |pr|
341
- if pr[:title].strip == title.strip
342
- return pr
343
- end
344
- end
345
+ @programs.map{|pr| return pr if(pr[:title].strip == title.strip)}
345
346
  nil
346
347
  end
347
348
 
@@ -401,9 +402,7 @@ class InOurTime
401
402
  end
402
403
 
403
404
  def clear
404
- @lock.synchronize do
405
- system 'clear' or system 'cls'
406
- end
405
+ system 'clear' or system 'cls'
407
406
  end
408
407
 
409
408
  def print_error_and_delay message
@@ -590,6 +589,7 @@ class InOurTime
590
589
  iot_puts " Play/Stop - X or Enter ", @system_colour
591
590
  iot_puts " Sort - S ", @system_colour
592
591
  iot_puts " List Top - L ", @system_colour
592
+ iot_puts " Update - U ", @system_colour
593
593
  iot_puts " Info - I ", @system_colour
594
594
  iot_puts " Help - H ", @system_colour
595
595
  iot_puts " Quit - Q ", @system_colour
@@ -730,19 +730,11 @@ class InOurTime
730
730
  end
731
731
 
732
732
  def run
733
- ip = ''
734
- @tic = Tic.new
735
- @tic_thread = Thread.new do
736
- @tic.run
737
- end
733
+ ip, action = '', :unknown
734
+ @tic, @key = Tic.new, KeyboardEvents.new
735
+ @tic.run
736
+ @key.run
738
737
 
739
- @key = KeyboardEvents.new
740
- key_thread = Thread.new do
741
- @key.run
742
- end
743
- # sleep 0.015
744
-
745
- action = :unknown
746
738
  redraw
747
739
  loop do
748
740
 
@@ -762,12 +754,8 @@ class InOurTime
762
754
 
763
755
  action =
764
756
  case ip
765
- when :pause
766
- pause
767
- when :forward
768
- forward
769
- when :rewind
770
- rewind
757
+ when :pause, :forward, :rewind
758
+ self.send ip
771
759
  when :list
772
760
  @line_count = 0
773
761
  @selected = 0
@@ -803,6 +791,13 @@ class InOurTime
803
791
  end
804
792
  when :sort
805
793
  sort
794
+ when :update
795
+ update
796
+ parse_rss
797
+ sort_titles
798
+ @line_count = 0
799
+ @selected = 0
800
+ display_list :next_page
806
801
  when :info
807
802
  info
808
803
  when :help
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in_our_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martyn Jago
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oga
@@ -67,11 +67,11 @@ files:
67
67
  - VERSION
68
68
  - bin/iot
69
69
  - config.yml
70
- - dark_theme.png
70
+ - images/dark_theme.png
71
+ - images/light_theme.png
71
72
  - in_our_time.gemspec
72
73
  - lib/in_our_time.rb
73
74
  - lib/iot/iot.rb
74
- - light_theme.png
75
75
  homepage: https://github.com/mjago/In_Our_Time
76
76
  licenses:
77
77
  - MIT
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.6.6
95
+ rubygems_version: 2.6.7
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Select, play, and download BBC 'In Our Time' podcasts - all from the command