m3uzi 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/m3uzi/version.rb +1 -1
  2. data/lib/m3uzi.rb +24 -6
  3. metadata +3 -3
data/lib/m3uzi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class M3Uzi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/m3uzi.rb CHANGED
@@ -10,11 +10,12 @@ class M3Uzi
10
10
  VALID_TAGS = %w{TARGETDURATION MEDIA-SEQUENCE ALLOW-CACHE STREAM-INF ENDLIST VERSION}
11
11
 
12
12
  attr_accessor :files
13
- attr_accessor :tags
13
+ attr_accessor :tags, :comments
14
14
 
15
15
  def initialize
16
16
  @files = []
17
17
  @tags = []
18
+ @comments = []
18
19
  end
19
20
 
20
21
 
@@ -50,21 +51,25 @@ class M3Uzi
50
51
  def write(path)
51
52
  f = ::File.open(path, "w")
52
53
  f << "#EXTM3U\n"
54
+ comments.each do |comment|
55
+ f << "##{comment}\n"
56
+ end
53
57
  tags.each do |tag|
54
58
  next if %w{M3U ENDLIST}.include?(tag.name.to_s.upcase)
55
- f << "#EXT-X-#{tag.name.to_s.upcase}"
59
+ if VALID_TAGS.include?(tag.name.to_s.upcase)
60
+ f << "#EXT-X-#{tag.name.to_s.upcase}"
61
+ else
62
+ f << "##{tag.name.to_s.upcase}"
63
+ end
56
64
  tag.value && f << ":#{tag.value}"
57
65
  f << "\n"
58
66
  end
59
- if !self[:targetduration]
60
- f << "#EXT-X-TARGETDURATION:#{files.map(&:duration).sum}\n"
61
- end
62
67
  files.each do |file|
63
68
  f << "#EXTINF:#{file.duration}"
64
69
  file.description && f << ", #{file.description}"
65
70
  f << "\n#{file.path}\n"
66
71
  end
67
- f << "#EXT-X-ENDLIST"
72
+ f << "#EXT-X-ENDLIST\n"
68
73
  f.close()
69
74
  end
70
75
 
@@ -108,6 +113,19 @@ class M3Uzi
108
113
  end
109
114
 
110
115
 
116
+ #-------------------------------------
117
+ # Comments
118
+ #-------------------------------------
119
+
120
+ def add_comment(comment)
121
+ @comments << comment
122
+ end
123
+
124
+ def <<(comment)
125
+ add_comment(comment)
126
+ end
127
+
128
+
111
129
  protected
112
130
 
113
131
  def self.type(line)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m3uzi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Arbini