ted_talk 0.0.4 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,7 @@ TedTalk helps download TED talk video and covert it to a slowed down MP3 with pa
6
6
 
7
7
  ## Installation
8
8
 
9
- TedTalk requires [FFmpeg](http://ffmpeg.org/) and [SoX](http://sox.sourceforge.net/) **with LAME support** [important], as well as [TagLib](http://taglib.github.com/) audio meta-data library installed to the system
9
+ TedTalk requires [FFmpeg](http://ffmpeg.org/) and [SoX](http://sox.sourceforge.net/) with LAME support, as well as [TagLib](http://taglib.github.com/) audio meta-data library installed to the system
10
10
 
11
11
  $ gem install ted_talk
12
12
 
@@ -54,5 +54,4 @@ TedTalk requires [FFmpeg](http://ffmpeg.org/) and [SoX](http://sox.sourceforge.n
54
54
  --speed, -s <f>: Speed of output file [0.1 - 100] (default: 1.0)
55
55
  --silence, -i <f>: Length (secondes) of a pause added to each utterance
56
56
  [0.1 - 120] (default: 0.0)
57
- --video, -v: Save not only audio but also the original video
58
57
  --help, -h: Show this message
@@ -26,13 +26,13 @@ global_opts = Trollop::options do
26
26
  banner <<-EOS
27
27
  TedTalk helps download TED talk video and covert it to a slowed down MP3 with pauses that is helpful for English learning
28
28
 
29
- Basic usage: ted_talk desc <option> - show TED Talk description(s)
30
- ted_talk exec <option> - download and convert a TED Talk video
31
- ted_talk delete - delete cache folder
29
+ Basic usage: tedtalk desc <option> - show TED Talk description(s)
30
+ tedtalk exec <option> - download and convert a TED Talk video
31
+ tedtalk delete - delete cache folder
32
32
 
33
33
  For details about <option>, type:
34
- ted_talk desc -h
35
- or ted_talk exec -h
34
+ tedtalk desc -h
35
+ or tedtalk exec -h
36
36
 
37
37
  [global options]:
38
38
  EOS
@@ -89,7 +89,6 @@ EOS
89
89
  opt :outdir, "Directory for file output", :default=> "./"
90
90
  opt :speed, "Speed of output file [0.1 - 100]", :default => 1.0
91
91
  opt :silence, "Length (secondes) of a pause added to each utterance [0.1 - 120]", :default => 0.0
92
- opt :video, "Save not only audio but also the original video", :default => false
93
92
  end
94
93
 
95
94
  Trollop::die :outdir, "must be an existing directory" unless File::ftype(exec_opts[:outdir]) == "directory"
@@ -101,10 +100,9 @@ EOS
101
100
  outdir = exec_opts[:outdir]
102
101
  speed = exec_opts[:speed]
103
102
  silence = exec_opts[:silence]
104
- video = exec_opts[:video]
105
103
 
106
104
  tedtalk = TedTalk::Converter.new(source_url)
107
- tedtalk.execute(outdir, lang, speed, silence, video)
105
+ tedtalk.execute(outdir, lang, speed, silence)
108
106
  when "delete"
109
107
  TedTalk.delete_cache
110
108
  else
@@ -114,8 +114,8 @@ module TedTalk
114
114
  end
115
115
  @lang = lang
116
116
  if lang != "en"
117
- @titles[lang] = get_title(lang) rescue ""
118
- @descriptions[lang] = get_description(lang) rescue ""
117
+ @titles[lang] = get_title(lang)
118
+ @descriptions[lang] = get_description(lang)
119
119
  @lang_name = @language_hash[@lang]
120
120
  end
121
121
  end
@@ -125,7 +125,7 @@ module TedTalk
125
125
  unless @descriptions[lang]
126
126
  lang = "en"
127
127
  end
128
- puts "\nTitle:\n" + @titles["en"]
128
+ puts "\nTitle:\n" + @titles["en"]
129
129
  puts @titles[lang] if lang != "en"
130
130
  puts ""
131
131
  puts "Description:\n" + @descriptions[lang]
@@ -137,7 +137,7 @@ module TedTalk
137
137
  end
138
138
  end
139
139
 
140
- def execute(outdir = "./", lang = "en", speed = 1, silence = 0, video = false)
140
+ def execute(outdir = "./", lang = "en", speed = 1, silence = 0)
141
141
  puts "TedTalk is prepararing for the process"
142
142
  @outdir = File.join(outdir, @ted_id + "-" + @basename)
143
143
  Dir.mkdir(@outdir) unless File.exists?(@outdir)
@@ -148,15 +148,12 @@ module TedTalk
148
148
  get_captions("en")
149
149
  setup_lang(lang)
150
150
  get_captions(lang)
151
- video_filepath = get_binary(@video_url)
151
+ video_filepath = get_binary(@video_url)
152
152
  wav_filepath = get_wav(video_filepath)
153
153
  outfile = @outdir + "/" + @basename + "-result.mp3"
154
154
  speakslow = SpeakSlow::Converter.new(wav_filepath, outfile)
155
155
  speakslow.execute(speed, silence)
156
- write_info(outfile)
157
- if video
158
- `cp #{video_filepath} #{@outdir + "/"}`
159
- end
156
+ write_info(outfile)
160
157
  end
161
158
 
162
159
  def get_title(lang)
@@ -170,8 +167,9 @@ module TedTalk
170
167
  lang_url = "http://www.ted.com/talks/lang/#{lang}/" + @url_basename
171
168
  html = get_html(lang_url)
172
169
  lang_doc = Nokogiri::HTML(html)
173
- result = lang_doc.xpath("//meta[@name='description']").first.attribute("content").value.strip
174
- return result || ""
170
+ temp = lang_doc.xpath("//meta[@name='description']").first.attribute("content").value.strip
171
+ /\ATED Talks\s*(.+)\z/ =~ temp
172
+ $1 rescue temp ""
175
173
  end
176
174
 
177
175
  def get_captions(lang = "en")
@@ -237,10 +235,10 @@ module TedTalk
237
235
  tag.title += " [x#{@speed}]" if @speed and @speed != 1
238
236
  tag.genre = "Talk"
239
237
 
240
- caption_text = @titles["en"] || ""
238
+ caption_text = @titles["en"] + "\n"
241
239
  caption_text << @titles[@lang] + "\n" if @titles[@lang]
242
240
  caption_text << "--------------------\n"
243
- caption_text << @descriptions["en"] + "\n" if @descriptions["en"]
241
+ caption_text << @descriptions["en"] + "\n"
244
242
  caption_text << @descriptions[@lang] + "\n" if @descriptions[@lang]
245
243
  caption_text << "\n"
246
244
  @captions["en"].each_with_index do |c, index|
@@ -1,3 +1,3 @@
1
1
  module TedTalk
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ted_talk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-24 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70364332347800 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70364332347800
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: progressbar
27
- requirement: &70364332347380 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70364332347380
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: json
38
- requirement: &70364332346960 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70364332346960
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: taglib-ruby
49
- requirement: &70364328200660 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70364328200660
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: nokogiri
60
- requirement: &70364328199120 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70364328199120
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: speak_slow
71
- requirement: &70364328198040 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70364328198040
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: trollop
82
- requirement: &70364328196340 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,7 +117,12 @@ dependencies:
87
117
  version: '0'
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *70364328196340
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  description: TedTalk helps download TED talk video and covert it to a slowed down
92
127
  MP3 with pauses that is useful for English learning
93
128
  email:
@@ -129,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
164
  version: '0'
130
165
  requirements: []
131
166
  rubyforge_project:
132
- rubygems_version: 1.8.17
167
+ rubygems_version: 1.8.24
133
168
  signing_key:
134
169
  specification_version: 3
135
170
  summary: TED talk downloader and converter for English learners