fc2_get 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 332df27458da08111154a8f4321af49baec178d2
4
- data.tar.gz: 12494ab256bd65cc7d0aaa9f4e00dda1fb3abf4f
3
+ metadata.gz: 845e8532284d55147049c2bf4b9a6a6b6d4169df
4
+ data.tar.gz: 42aaae17c0102c543a04f5f2101662371966ee5b
5
5
  SHA512:
6
- metadata.gz: d3b3d1f7f416e72db5a72a168fe1864ac2fd3b7dc27ff43872776b8e106c1f655fb4106b161ac216f217d7be22025eebb75943d675ff72235f1713236245b4ae
7
- data.tar.gz: cf6f968bb40c2ede64b282a51109ee7e62695c3f2a997120cbf963e2b4a697e2c3c4cee8f9e7d02e7e60eb403795e0a9a79bb45e005d4a1bfb0427c7a0816b17
6
+ metadata.gz: 2c02049c109a94c2e9a438095f8a4b2a08b5844a4d7cca98c71d16911eab4a387f04a43ccd9900a9c35b6eb216ba2e180dd988c134ffc61d7c9b74fd297e1e50
7
+ data.tar.gz: 82cedd78a53ad27fc355450081caba3c0f8ae243356335ab40505104d7eca77b602fa3b758422fedc522b3ee28af92d78460c81f5b1dd0a632881dc071482275
@@ -3,7 +3,15 @@
3
3
  require 'fc2_get'
4
4
 
5
5
  if ARGV.size == 1
6
- Fc2Get.download ARGV[0]
6
+ begin
7
+ Fc2Get.download ARGV[0]
8
+ rescue Fc2Get::FileExists
9
+ print "overwrite file? (y/N) "
10
+ if $stdin.gets.chop!.downcase == 'y'
11
+ File.unlink $!.path
12
+ Fc2Get.download ARGV[0]
13
+ end
14
+ end
7
15
  else
8
16
  puts 'Usage: fc2_get VIDEO_ID'
9
17
  end
@@ -4,6 +4,13 @@ require 'net/http'
4
4
  require 'fc2_get/version'
5
5
 
6
6
  module Fc2Get
7
+ class FileExists < RuntimeError
8
+ attr_reader :path
9
+ def initialize msg, path
10
+ super msg
11
+ @path = path
12
+ end
13
+ end
7
14
  module_function
8
15
  def mimi(video_id)
9
16
  Digest::MD5.hexdigest(video_id + '_gGddgPfeaf_gzyr')
@@ -26,6 +33,7 @@ module Fc2Get
26
33
  video_uri = download_uri(video_id)
27
34
  file_path = File.directory?(path) ?
28
35
  File.expand_path(File.basename(video_uri.path), path) : path
36
+ raise FileExists.new "path: #{file_path}", file_path if File.exist? file_path
29
37
  Net::HTTP.get_response(video_uri) do |res|
30
38
  size, total = 0, res.header['Content-Length'].to_i
31
39
  open file_path, 'w' do |io|
@@ -1,3 +1,3 @@
1
1
  module Fc2Get
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fc2_get
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jian Weihang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler