mdisc 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ffacdc06c21ea64668d433820057b7b0badbd4e
4
- data.tar.gz: 355417e17dc4b9b457e31e79642024f5c9139f7a
3
+ metadata.gz: 517516d1caae450b750f38cc40ba6f3c59589378
4
+ data.tar.gz: 2f76a77f18bd3db546c4b0af4fe02b44eaf9516f
5
5
  SHA512:
6
- metadata.gz: fa69a50b93d1239aae16df330ec40263c7b9ff2cebf2344e8edd3329474549890320ed2afeca52574602ec6c9df7a0be588312017734cba71c4124333bcddd6e
7
- data.tar.gz: ffb47f0891021dd3dac34b9c76ddee8e9b4f3391e9a6875cb827a83c9ab55257cf06cf370d5ec5971e1c9052edcb7479dbf6e813ad664654242b44a1580a62e9
6
+ metadata.gz: 017a94632c0254a20c380fa84cb3175d6c6a14c794ce109328d9f336c75d9acc6bbf7ecdcb9db35bdaf96bb5e4ce62d7e09c61adf49ff767b9c4a8cfc0dc1bad
7
+ data.tar.gz: 88c70d888f818e60a16d64c939cf9b7f77c044c2b3358ddf6c0d6fbcbb1b5a4993a925dffe316992cc215f6708792cbcd25f3c6323b542bac45b60060b4f7764
data/lib/mdisc/menu.rb CHANGED
@@ -39,7 +39,7 @@ class Menu
39
39
  @offset = 0
40
40
  @index = 0
41
41
  @present_songs = []
42
- @step = 20
42
+ @step = 25
43
43
  @stack = []
44
44
  @userid = nil
45
45
  @username = nil
data/lib/mdisc/player.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'open4'
2
2
 
3
+ # FIXME: There is something wrong...
4
+
3
5
  class Player
4
6
  WAIT_TIME = 0.5
5
7
 
@@ -25,7 +27,9 @@ class Player
25
27
  ui.build_playinfo(item['song_name'], item['artist'])
26
28
 
27
29
  @thread = Thread.new do
28
- @mp3id, stdin, stdout, stderr = Open4::popen4('mpg123', item['mp3_url'])
30
+ # Add input option: --continue,
31
+ # play a song continuously in case the network becomes offline occasionally.
32
+ @mp3id, stdin, stdout, stderr = Open4::popen4('mpg123', '--continue', item['mp3_url'])
29
33
  Process::waitpid2 @mp3id
30
34
 
31
35
  if @playing_flag
data/lib/mdisc/screen.rb CHANGED
@@ -8,7 +8,7 @@ class Screen
8
8
  Curses.init_screen
9
9
  Curses.start_color
10
10
  Curses.cbreak
11
- Curses.stdscr.keypad true
11
+ Curses.stdscr.keypad(true)
12
12
  Curses.init_pair(1, Curses::COLOR_BLUE, Curses::COLOR_BLACK)
13
13
  Curses.init_pair(2, Curses::COLOR_CYAN, Curses::COLOR_BLACK)
14
14
  Curses.init_pair(3, Curses::COLOR_RED, Curses::COLOR_BLACK)
@@ -21,8 +21,8 @@ class Screen
21
21
  color = Curses.color_pair num
22
22
  @draw.setpos(y, x)
23
23
  @draw.clrtoeol
24
- @draw.attrset(color)
25
- @draw.addstr(string)
24
+ @draw.attrset color
25
+ @draw.addstr(strip_invalid(string))
26
26
  end
27
27
 
28
28
  def clear(top, bottom)
@@ -47,4 +47,15 @@ class Screen
47
47
  def setpos(*args)
48
48
  @draw.setpos *args
49
49
  end
50
+
51
+ private
52
+
53
+ def strip_invalid(str)
54
+ # Clean emoji.
55
+ str = str.gsub(/[\u{00A9}\u{00AE}\u{203C}\u{2049}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{27BF}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F31F}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}\u{1F68C}-\u{1F6C5}]/, "").strip
56
+
57
+ # Remove unnecessary charactors to prevent bad UI layout.
58
+ # More info about regex and Unicode: http://www.regular-expressions.info/unicode.html
59
+ str = str.gsub(/[\p{M}\p{Po}\p{So}]/, "").strip
60
+ end
50
61
  end
data/lib/mdisc/ui.rb CHANGED
@@ -31,10 +31,8 @@ class Ui
31
31
 
32
32
  SCREEN_HEIGHT = 40
33
33
  SCREEN_WIDTH = 80
34
- SCREEN_TOP = 0
35
- SCREEN_LEFT = 0
36
34
 
37
- PLAYER_X = 4
35
+ PLAYER_X = 6
38
36
  PLAYER_TITLE_Y = 4
39
37
  PLAYER_STATUS_Y = 5
40
38
  PLAYER_CONTENT_Y = 7
@@ -50,9 +48,9 @@ class Ui
50
48
 
51
49
  def build_playinfo(song_name, artist, pause = false)
52
50
  if pause
53
- screen.line(PLAYER_STATUS_Y, PLAYER_NOTE_X, '', 3)
51
+ screen.line(PLAYER_STATUS_Y, PLAYER_NOTE_X, 'S', 3)
54
52
  else
55
- screen.line(PLAYER_STATUS_Y, PLAYER_NOTE_X, '', 3)
53
+ screen.line(PLAYER_STATUS_Y, PLAYER_NOTE_X, 'P', 3)
56
54
  end
57
55
 
58
56
  sn = pretty(song_name, 0, 28)
@@ -82,47 +80,47 @@ class Ui
82
80
  case datatype
83
81
  when 'main'
84
82
  show(entries, index, offset, datalist) do |i, datalist|
85
- "#{i}. #{datalist[i]}"
83
+ "#{i} #{datalist[i]}"
86
84
  end
87
85
 
88
- screen.line(PLAYER_INFO_Y, PLAYER_X, 'Crafted with by cosmtrek', 3)
86
+ screen.line(PLAYER_INFO_Y, PLAYER_X, 'Crafted with <3 by cosmtrek', 3)
89
87
 
90
88
  when 'songs'
91
89
  show(entries, index, offset, datalist) do |i, datalist|
92
90
  sn = pretty(datalist[i]['song_name'], 0, 28)
93
91
  at = pretty(datalist[i]['artist'], 0, 24)
94
- "#{i}. #{sn} - #{at}"
92
+ "#{i} #{sn} - #{at}"
95
93
  end
96
94
 
97
95
  when 'artists'
98
96
  show(entries, index, offset, datalist) do |i, datalist|
99
97
  an = pretty(datalist[i]['artists_name'], 0, 28)
100
- "#{i}. #{an}"
98
+ "#{i} #{an}"
101
99
  end
102
100
 
103
101
  when 'albums'
104
102
  show(entries, index, offset, datalist) do |i, datalist|
105
103
  al = pretty(datalist[i]['albums_name'], 0, 28)
106
104
  an = pretty(datalist[i]['artists_name'], 0, 24)
107
- "#{i}. #{al} - #{an}"
105
+ "#{i} #{al} - #{an}"
108
106
  end
109
107
 
110
108
  when 'playlists'
111
109
  show(entries, index, offset, datalist) do |i, datalist|
112
110
  pn = pretty(datalist[i]['playlists_name'], 0, 28);
113
111
  cn = pretty(datalist[i]['creator_name'], 0, 24);
114
- "#{i}. #{pn} - #{cn}"
112
+ "#{i} #{pn}"
115
113
  end
116
114
 
117
115
  when 'djchannels'
118
116
  show(entries, index, offset, datalist) do |i, datalist|
119
117
  sn = pretty(datalist[i][0]['song_name'], 0, 28)
120
- "#{i}. #{sn}"
118
+ "#{i} #{sn}"
121
119
  end
122
120
 
123
121
  when 'help'
124
122
  entries.each do |i|
125
- info = "#{i}. #{datalist[i][0]} #{datalist[i][1]} #{datalist[i][2]}"
123
+ info = "#{i} #{datalist[i][0]} #{datalist[i][1]} #{datalist[i][2]}"
126
124
  screen.line(i-offset+PLAYER_CONTENT_Y, PLAYER_X, info)
127
125
  end
128
126
  end
@@ -250,7 +248,7 @@ class Ui
250
248
 
251
249
  def highlight_or_not(i, index, offset, info)
252
250
  if i == index
253
- highlight = " #{info}"
251
+ highlight = "=> #{info}"
254
252
  screen.line(i-offset+PLAYER_CONTENT_Y, PLAYER_POINTER_X, highlight, 2)
255
253
  else
256
254
  screen.line(i-offset+PLAYER_CONTENT_Y, PLAYER_X, info)
data/lib/mdisc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mdisc
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdisc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler