audiostream 0.1.11 → 0.1.12
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/lib/audiostream/cli.rb +32 -2
- data/lib/audiostream/time.rb +0 -2
- data/lib/audiostream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ee69009ca5646e4bc2a21a55503b462eced91f
|
4
|
+
data.tar.gz: a6d60220d73bfe946a7ed783fef56d05b68d26fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6347b03da91450adfa985cbc8d0348f431da5eb0aacfdabd7975e9d958ae4253e6833a73e5af2c1c024d4f00918faad636afece8be1384cf2ae3fa3a4526f8a1
|
7
|
+
data.tar.gz: e30ce93a52101f76ae72655add8570181c94df1a4a51ba3077415af09b92f7d9a3f90465a2504a1c12492d4fa4266e7daad6fdae74ad698dbb5676a32b4df85e
|
data/lib/audiostream/cli.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require 'audiostream/
|
1
|
+
require 'audiostream/helpers'
|
2
2
|
require 'thor'
|
3
3
|
|
4
4
|
module AudioStream
|
5
5
|
class CLI < Thor
|
6
6
|
include Thor::Actions
|
7
|
+
include AudioStream::Helpers
|
7
8
|
|
8
9
|
default_task :banner
|
9
10
|
|
@@ -25,6 +26,35 @@ Licenced for usage and distribution under a BSD version 2 Licence.
|
|
25
26
|
puts AudioStream::VERSION
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
desc "time", "Display the play time of an audio file."
|
30
|
+
method_option :playlist, :aliases => "-p", :desc => "m3u playlist to parse"
|
31
|
+
|
32
|
+
def time
|
33
|
+
|
34
|
+
help(:time) if options[:playlist].nil?
|
35
|
+
@filepath = "#{options[:playlist]}"
|
36
|
+
|
37
|
+
if File.exists?(@filepath) then
|
38
|
+
File.open(@filepath).each do |item|
|
39
|
+
@item=item.chomp
|
40
|
+
|
41
|
+
next if /^#EXT(M3U|INF:).*$/.match(@item)
|
42
|
+
if File.exists?(@item) then
|
43
|
+
@total_time << playtime(@item)
|
44
|
+
puts "#{@item}: #{playtime(@item)}"
|
45
|
+
else
|
46
|
+
puts "Error: File #{@item} not found"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "Playlist could not be loaded."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def playtime(path)
|
57
|
+
Time.at(mp3(path).length).gmtime.strftime('%R:%S')
|
58
|
+
end
|
29
59
|
end
|
30
60
|
end
|
data/lib/audiostream/time.rb
CHANGED
data/lib/audiostream/version.rb
CHANGED