subconvtr 0.0.8 → 0.0.9
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/subconvtr.rb +50 -31
- 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: a45f46b6fe63745c7d3e26240a02b25ffd88344e
|
|
4
|
+
data.tar.gz: fd3b93ff9f2e01f2604aa2e210dcb124bf081251
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ab0cb5121757aa4312a08cb5c9d0b7651ce8c5e7ea821f37a2da8489332c4575e8669b51b6ddec900d0930dd4c01593bb3558a6e51c33a76e3e0202c2ac58f8
|
|
7
|
+
data.tar.gz: 0ff9b0d6b70faf04fc0788b2e2e8eeef55769ef6310d573a5bbbbd45c6a12fb7d99d42bf37a1dc30a0e0761c036d06fa111e470aa5cebaf9fbe376c83c5aab28
|
data/lib/subconvtr.rb
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
module Subconvtr
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
|
|
3
|
+
class Monitor
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
end
|
|
7
|
+
# Converts the target file from windows-1254 to utf-8 encoding.
|
|
8
|
+
def run
|
|
9
|
+
|
|
10
|
+
output = `ls | grep -E ".srt"`.split("\n")
|
|
11
|
+
|
|
12
|
+
# puts output
|
|
13
|
+
output.each do |current|
|
|
14
|
+
if !(`file -I "#{current}"`.include? "charset=utf-8")
|
|
15
|
+
puts `file -I "#{current}"`
|
|
16
|
+
`iconv -f windows-1254 -t utf-8 "#{current}" > temp24124eqqweqwrfsdf.srt && mv temp24124eqqweqwrfsdf.srt "#{current}"`
|
|
17
|
+
puts `file -I "#{current}"`
|
|
18
|
+
else
|
|
19
|
+
# print '.'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
sleep 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.start
|
|
27
|
+
loop do
|
|
28
|
+
self.new.run
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
# trapping the ctrl+c exit
|
|
35
|
+
trap "SIGINT" do
|
|
36
|
+
puts ""
|
|
37
|
+
puts "Exiting"
|
|
38
|
+
puts "......."
|
|
39
|
+
puts "See you next time 🐰"
|
|
40
|
+
puts ""
|
|
41
|
+
exit 130
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
puts `pwd`
|
|
45
|
+
puts 'Folder above is being watched 🤓'
|
|
46
|
+
puts 'Observing for .srt files, i.e. ones having windows-1254 charset will be converted into utf-8'
|
|
47
|
+
puts 'Files will be analyzed before conversion 🚀'
|
|
48
|
+
puts ''
|
|
49
|
+
puts 'Press Ctrl+C to exit'
|
|
50
|
+
|
|
51
|
+
Subconvtr::Monitor.start
|
|
52
|
+
|