Skip to content

Commit

Permalink
error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
yayugu committed Jun 5, 2015
1 parent 284fab1 commit 59c8e3a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/niconico_live/downloading.rb
Expand Up @@ -61,7 +61,12 @@ def reservation
# <NoMethodError: undefined method `inner_text' for nil:NilClass>
# lib/niconico/live/api.rb:60:in `get'

# ignore & force reload
Rails.logger.warn "reservation failed. but try continue"
Rails.logger.warn e.class
Rails.logger.warn e.inspect
Rails.logger.warn e.backtrace.join("\n")

# force reload
sleep 5
@l.get(true)
end
Expand Down Expand Up @@ -97,13 +102,14 @@ def _download
infos = @l.rtmpdump_infos(path)
infos.each do |info|
full_file_path = info[:file_path]
exit_status = rtmpdump_with_resume(info)
[exit_status, output] = rtmpdump_with_resume(info)
unless exit_status.success?
Rails.logger.error "rtmpdump failed: #{@l.id}, #{full_file_path} but continue other file download"
Rails.logger.warn "rtmpdump failed: #{@l.id}, #{full_file_path} but continue other file download"
Rails.logger.warn output
next
end
unless Main::check_file_size(full_file_path)
Rails.logger.error "downloaded file is not valid: #{@l.id}, #{full_file_path} but continue other file download"
Rails.logger.warn "downloaded file is not valid: #{@l.id}, #{full_file_path} but continue other file download"
next
end
Main::move_to_archive_dir(CH_NAME, @l.opens_at, full_file_path)
Expand All @@ -118,12 +124,12 @@ def rtmpdump_with_resume(info)
exit_status, output = Main::shell_exec(rtmpdump_command(info, false))
10.times do
if exit_status.exitstatus != 2 # 2 means 'Incomplete transfer, resuming may get further. '
return exit_status
return [exit_status, output]
end
sleep 5
exit_status, output = Main::shell_exec(rtmpdump_command(info, true))
end
exit_status
[exit_status, output]
end

def rtmpdump_command(info, resume = false)
Expand Down

0 comments on commit 59c8e3a

Please sign in to comment.