172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# File 'lib/command/convert.rb', line 172
def convert_novels(argv)
tagname_to_ids(argv)
argv.each.with_index(1) do |target, i|
Helper.print_horizontal_rule if i > 1
if @basename
@basename << " (#{i})" if argv.length > 1
@output_filename = @basename + @ext
end
if File.file?(target.to_s)
@argument_target_type = :file
res = convert_txt(target)
else
@argument_target_type = :novel
unless Downloader.novel_exists?(target)
error "#{target} は存在しません"
next
end
res = NovelConverter.convert(target, {
output_filename: @output_filename,
display_inspector: @options["inspect"],
ignore_force: @options["ignore-force"],
})
@novel_data = Downloader.get_data_by_target(target)
end
next unless res
@converted_txt_path = res[:converted_txt_path]
@use_dakuten_font = res[:use_dakuten_font]
ebook_file = hook_call(:convert_txt_to_ebook_file)
next if ebook_file.nil?
if ebook_file
copied_file_path = copy_to_converted_file(ebook_file)
if copied_file_path
puts copied_file_path.encode(Encoding::UTF_8) + " へコピーしました"
end
if @device && @device.physical_support? &&
@device.connecting? && File.extname(ebook_file) == @device.ebook_file_ext
if @argument_target_type == :novel
if Send.execute!([@device.name, target]) > 0
@@sending_error_list << ebook_file
end
else
puts @device.name + "へ送信しています"
copy_to_path = nil
begin
copy_to_path = @device.copy_to_documents(ebook_file)
rescue Device::SendFailure
end
if copy_to_path
puts copy_to_path.encode(Encoding::UTF_8) + " へコピーしました"
else
error "送信に失敗しました"
@@sending_error_list << ebook_file
end
end
end
end
if @options["no-open"].! && Narou.web?.!
Helper.open_directory(File.dirname(@converted_txt_path), "小説の保存フォルダを開きますか")
end
end
rescue Interrupt
puts
puts "変換を中断しました"
exit Narou::EXIT_ERROR_CODE
end
|