fc2_get 1.0.3 → 1.0.4
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/bin/fc2_get +9 -1
- data/lib/fc2_get.rb +8 -0
- data/lib/fc2_get/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 845e8532284d55147049c2bf4b9a6a6b6d4169df
|
4
|
+
data.tar.gz: 42aaae17c0102c543a04f5f2101662371966ee5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c02049c109a94c2e9a438095f8a4b2a08b5844a4d7cca98c71d16911eab4a387f04a43ccd9900a9c35b6eb216ba2e180dd988c134ffc61d7c9b74fd297e1e50
|
7
|
+
data.tar.gz: 82cedd78a53ad27fc355450081caba3c0f8ae243356335ab40505104d7eca77b602fa3b758422fedc522b3ee28af92d78460c81f5b1dd0a632881dc071482275
|
data/bin/fc2_get
CHANGED
@@ -3,7 +3,15 @@
|
|
3
3
|
require 'fc2_get'
|
4
4
|
|
5
5
|
if ARGV.size == 1
|
6
|
-
|
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
|
data/lib/fc2_get.rb
CHANGED
@@ -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|
|
data/lib/fc2_get/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|