in_our_time 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -5
- data/VERSION +1 -1
- data/lib/iot/iot.rb +141 -45
- 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: ed0b5b221412272a4878b2d8d4292a55785cc1c1
|
4
|
+
data.tar.gz: 3381834d2955875c617f2d5ad97fe5ec89cabba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 718ce0b3cc69e71799797625f28d101d2e030aa2818a5b85e2dd07521703a4619597ae9527c3ea0bfbbc22f1ad76be8b460f613c007f2dd81fd9f3a9e2f6584e
|
7
|
+
data.tar.gz: 94eccc73c95354135426ab82920b27c03fc9240ca4ea2eb9a2acd6aa6d4d61c8895ceb139fba4caf81f3b2859020d2eb35879993507ef0deb6501e50c8609b22
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
## In Our Time
|
2
2
|
|
3
|
-
Select,
|
3
|
+
Select, automatically download, and play **BBC In Our Time** podcasts easily, from the command line.
|
4
4
|
|
5
|
-
|
5
|
+
- [BBC In Our Time](http://www.bbc.co.uk/programmes/b006qykl).
|
6
6
|
|
7
|
-
|
7
|
+
Podcast is archived locally for offline access in the future.
|
8
|
+
|
9
|
+
Regularly checks for new podcasts.
|
8
10
|
|
9
11
|
![compile image](https://raw.githubusercontent.com/mjago/In_Our_Time/master/light_theme.png)
|
10
12
|
|
@@ -16,12 +18,24 @@ Checks regularly for new podcasts and adds to the list.
|
|
16
18
|
gem install in_our_time
|
17
19
|
iot
|
18
20
|
```
|
19
|
-
|
20
21
|
## Config:
|
21
22
|
|
22
23
|
Config can be found at '~/.in_our_time/config.yml'
|
23
24
|
|
24
25
|
## mp3 player:
|
25
26
|
|
26
|
-
By default uses **afplay**
|
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**:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
:mpg_player: :mpg123
|
31
|
+
```
|
27
32
|
|
33
|
+
## Command line options:
|
34
|
+
Version:
|
35
|
+
```sh
|
36
|
+
iot --version
|
37
|
+
```
|
38
|
+
Help:
|
39
|
+
```sh
|
40
|
+
iot --help
|
41
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/iot/iot.rb
CHANGED
@@ -6,6 +6,7 @@ require 'yaml'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'colorize'
|
8
8
|
require 'oga'
|
9
|
+
require 'pty'
|
9
10
|
|
10
11
|
class InOurTime
|
11
12
|
|
@@ -14,6 +15,7 @@ class InOurTime
|
|
14
15
|
CONFIG_DIR = '.in_our_time'
|
15
16
|
CONFIG_NAME = 'config.yml'
|
16
17
|
IN_OUR_TIME = File.join ROOT, CONFIG_DIR
|
18
|
+
VERSION = File.join HERE, '..','..','VERSION'
|
17
19
|
DEFAULT_CONFIG = File.join HERE, '..','..',CONFIG_NAME
|
18
20
|
CONFIG = File.join IN_OUR_TIME,CONFIG_NAME
|
19
21
|
UPDATE_INTERVAL = 604800
|
@@ -64,9 +66,11 @@ class InOurTime
|
|
64
66
|
when "q",'Q', "\u0003", "\u0004"
|
65
67
|
:quit
|
66
68
|
when 'p', 'P'
|
67
|
-
:
|
68
|
-
when '
|
69
|
-
:
|
69
|
+
:pause
|
70
|
+
when 'f', 'F'
|
71
|
+
:forward
|
72
|
+
when 'r', 'R'
|
73
|
+
:rewind
|
70
74
|
when 's', 'S'
|
71
75
|
:stop
|
72
76
|
when 'x', 'X', "\r"
|
@@ -85,12 +89,20 @@ class InOurTime
|
|
85
89
|
@programs, @selected = [], 0
|
86
90
|
setup
|
87
91
|
load_config
|
92
|
+
load_version
|
93
|
+
load_help_maybe
|
94
|
+
display_version
|
88
95
|
check_remote
|
89
96
|
parse_rss
|
90
97
|
sort_titles
|
98
|
+
version_display_wait
|
91
99
|
run
|
92
100
|
end
|
93
101
|
|
102
|
+
def version_display_wait
|
103
|
+
sleep 0.01 while Time.now - @start_time < 1
|
104
|
+
end
|
105
|
+
|
94
106
|
def iot_print x, col = @text_colour
|
95
107
|
print x.colorize col if @config[:colour]
|
96
108
|
print x unless @config[:colour]
|
@@ -106,6 +118,7 @@ class InOurTime
|
|
106
118
|
end
|
107
119
|
|
108
120
|
def setup
|
121
|
+
@start_time = Time.now
|
109
122
|
iot = IN_OUR_TIME
|
110
123
|
audio = File.join iot, AUDIO_DIRECTORY
|
111
124
|
pages = File.join iot, RSS_DIRECTORY
|
@@ -117,6 +130,17 @@ class InOurTime
|
|
117
130
|
end
|
118
131
|
end
|
119
132
|
|
133
|
+
def display_version
|
134
|
+
clear
|
135
|
+
iot_print("Loading ", @system_colour) unless ARGV[0] == '-v' || ARGV[0] == '--version'
|
136
|
+
iot_puts "In Our Time Player (#{@version})", @system_colour
|
137
|
+
exit 0 if ARGV[0] == '-v' || ARGV[0] == '--version'
|
138
|
+
end
|
139
|
+
|
140
|
+
def load_version
|
141
|
+
File.open(VERSION) {|f| @version = f.readline.strip}
|
142
|
+
end
|
143
|
+
|
120
144
|
def update_remote?
|
121
145
|
now - @config[:update_interval] > @config[:last_update]
|
122
146
|
end
|
@@ -276,28 +300,23 @@ class InOurTime
|
|
276
300
|
def pre_delay
|
277
301
|
x = DateTime.strptime("Mon, 20 Jun 2016", '%a, %d %b %Y')
|
278
302
|
y = DateTime.strptime(date, '%a, %d %b %Y')
|
279
|
-
y < x
|
303
|
+
if y < x
|
304
|
+
return '410' unless @playing == 'Abelard and Heloise'
|
305
|
+
'0' if @playing == 'Abelard and Heloise'
|
306
|
+
else
|
307
|
+
'435'
|
308
|
+
end
|
280
309
|
end
|
281
310
|
|
282
311
|
def player_cmd
|
283
312
|
case @config[:mpg_player]
|
284
313
|
when :mpg123
|
285
|
-
"mpg123 -
|
314
|
+
"mpg123 --remote-err -Cqk#{pre_delay}"
|
286
315
|
else
|
287
316
|
"afplay"
|
288
317
|
end
|
289
318
|
end
|
290
319
|
|
291
|
-
def kill_cmd
|
292
|
-
"killall " +
|
293
|
-
case @config[:mpg_player]
|
294
|
-
when :mpg123
|
295
|
-
"mpg123"
|
296
|
-
else
|
297
|
-
"afplay"
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
320
|
def clear
|
302
321
|
system 'clear' or system 'cls'
|
303
322
|
end
|
@@ -340,19 +359,62 @@ class InOurTime
|
|
340
359
|
end
|
341
360
|
end
|
342
361
|
unless @no_play
|
343
|
-
@
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
end
|
362
|
+
@playing = prg[:title]
|
363
|
+
window_title prg[:title]
|
364
|
+
@cmd = player_cmd + ' ' + filename_from_title(@playing)
|
365
|
+
@messages = []
|
366
|
+
@p_out, @p_in, @pid = PTY.spawn(@cmd)
|
349
367
|
end
|
350
368
|
@no_play = nil
|
351
369
|
end
|
352
370
|
|
371
|
+
def window_title title = ''
|
372
|
+
puts "\"\033]0;#{title}\007"
|
373
|
+
end
|
374
|
+
|
375
|
+
def reset
|
376
|
+
@pid, @playing, @paused = nil, nil, nil
|
377
|
+
window_title
|
378
|
+
display_list :same_page
|
379
|
+
end
|
380
|
+
|
381
|
+
def write_player str
|
382
|
+
begin
|
383
|
+
@p_in.puts str
|
384
|
+
rescue Errno::EIO
|
385
|
+
reset
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
def pause
|
390
|
+
if control_play?
|
391
|
+
@paused = @paused ? false : true
|
392
|
+
write_player " "
|
393
|
+
display_list :same_page
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
def control_play?
|
398
|
+
if @config[:mpg_player] == :mpg123
|
399
|
+
if @playing
|
400
|
+
true
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
def forward
|
406
|
+
write_player ":" if control_play?
|
407
|
+
end
|
408
|
+
|
409
|
+
def rewind
|
410
|
+
write_player ";" if control_play?
|
411
|
+
end
|
412
|
+
|
353
413
|
def print_playing_maybe
|
354
414
|
if @playing
|
355
|
-
|
415
|
+
iot_print("\nPlaying: ", @count_colour) unless @paused
|
416
|
+
iot_print("\nPaused: ", @count_colour) if @paused
|
417
|
+
iot_puts @playing, @selection_colour
|
356
418
|
elsif @started.nil?
|
357
419
|
@started = true
|
358
420
|
iot_puts "\n? or h for instructions", @text_colour
|
@@ -361,11 +423,18 @@ class InOurTime
|
|
361
423
|
end
|
362
424
|
end
|
363
425
|
|
426
|
+
def kill_cmd
|
427
|
+
"killall " +
|
428
|
+
@config[:mpg_player].to_s
|
429
|
+
end
|
430
|
+
|
364
431
|
def kill_audio
|
365
432
|
if @playing
|
366
|
-
|
367
|
-
|
368
|
-
|
433
|
+
if @pid.is_a? Fixnum
|
434
|
+
Process.kill('QUIT', @pid)
|
435
|
+
sleep 0.2
|
436
|
+
reset
|
437
|
+
end
|
369
438
|
end
|
370
439
|
end
|
371
440
|
|
@@ -407,7 +476,7 @@ class InOurTime
|
|
407
476
|
def display_list action
|
408
477
|
clear
|
409
478
|
case action
|
410
|
-
when :
|
479
|
+
when :next_page
|
411
480
|
draw_page
|
412
481
|
when :previous_page
|
413
482
|
if @line_count > 0
|
@@ -423,25 +492,32 @@ class InOurTime
|
|
423
492
|
end
|
424
493
|
end
|
425
494
|
|
495
|
+
def load_help_maybe
|
496
|
+
if ARGV[0] == '-h' || ARGV[0] == '--help' || ARGV[0] == '-?'
|
497
|
+
help
|
498
|
+
exit 0
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
426
502
|
def help
|
427
503
|
unless @help
|
428
504
|
clear
|
429
|
-
iot_puts " In Our Time Player (
|
430
|
-
iot_puts "
|
431
|
-
iot_puts "
|
432
|
-
iot_puts "
|
433
|
-
iot_puts "
|
434
|
-
iot_puts "
|
435
|
-
iot_puts "
|
436
|
-
iot_puts "
|
437
|
-
iot_puts "
|
438
|
-
iot_puts "
|
439
|
-
iot_puts "
|
440
|
-
iot_puts "
|
441
|
-
iot_puts "
|
442
|
-
iot_puts "
|
443
|
-
iot_puts "
|
444
|
-
|
505
|
+
iot_puts " In Our Time Player (#{@version})"
|
506
|
+
iot_puts " Next - N or Down Key ", @system_colour
|
507
|
+
iot_puts " Previous - P or Up Key ", @system_colour
|
508
|
+
iot_puts " Next Page - SPACE ", @system_colour
|
509
|
+
iot_puts " Play - X or Enter ", @system_colour
|
510
|
+
iot_puts " Stop - S ", @system_colour
|
511
|
+
iot_puts " List Page 1 - L ", @system_colour
|
512
|
+
iot_puts " Info - I ", @system_colour
|
513
|
+
iot_puts " Help - H ", @system_colour
|
514
|
+
iot_puts " Quit - Q ", @system_colour
|
515
|
+
iot_puts " mpg123 Controls: ", @system_colour
|
516
|
+
iot_puts " Pause/Resume - P ", @system_colour
|
517
|
+
iot_puts " Forward Skip - F ", @system_colour
|
518
|
+
iot_puts " Reverse Skip - R ", @system_colour
|
519
|
+
iot_puts " ", @system_colour
|
520
|
+
iot_puts "Config: #{CONFIG}" , @system_colour
|
445
521
|
print_playing_maybe
|
446
522
|
@help = true
|
447
523
|
else
|
@@ -566,18 +642,38 @@ class InOurTime
|
|
566
642
|
end
|
567
643
|
|
568
644
|
ip = key.input
|
645
|
+
|
646
|
+
if @pid.is_a? Fixnum
|
647
|
+
begin
|
648
|
+
write_player( "\e")
|
649
|
+
if @pid.is_a? Fixnum
|
650
|
+
Process.kill 0, @pid
|
651
|
+
end
|
652
|
+
rescue Errno::ESRCH
|
653
|
+
reset
|
654
|
+
end
|
655
|
+
else
|
656
|
+
@pid = nil
|
657
|
+
end
|
658
|
+
|
569
659
|
@info = nil unless ip == :info
|
570
660
|
@help = nil unless ip == :help
|
571
661
|
|
572
662
|
action =
|
573
663
|
case ip
|
664
|
+
when :pause
|
665
|
+
pause
|
666
|
+
when :forward
|
667
|
+
forward
|
668
|
+
when :rewind
|
669
|
+
rewind
|
574
670
|
when :list
|
575
671
|
@line_count = 0
|
576
672
|
@selected = 0
|
577
|
-
display_list :
|
673
|
+
display_list :next_page
|
578
674
|
when :page_forward
|
579
675
|
@selected = @line_count
|
580
|
-
display_list :
|
676
|
+
display_list :next_page
|
581
677
|
when :previous
|
582
678
|
@selected -= 1 if @selected > 0
|
583
679
|
if @selected >= @line_count -
|
@@ -591,7 +687,7 @@ class InOurTime
|
|
591
687
|
if @selected <= @line_count - 1
|
592
688
|
display_list :same_page
|
593
689
|
else
|
594
|
-
display_list :
|
690
|
+
display_list :next_page
|
595
691
|
end
|
596
692
|
when :play
|
597
693
|
kill_audio
|
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.
|
4
|
+
version: 0.3.1
|
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-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oga
|