fc2_get 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8621962be78ac5f1b86f58cf5029d408626a04be
4
+ data.tar.gz: 3419648aad70410fbda2d3f14aac8d4506414d32
5
+ SHA512:
6
+ metadata.gz: b14efaf88e1f24d993a22eb07395651ecc4b86497fe0fa16ffe8c368bdabec572ad167a9b0dc8ec7f76372692dee5ca6db4e93a2d07d93dff93f27e5905e8009
7
+ data.tar.gz: b7e732d25b297ae390b60312119c28f871ce9e81644bc83edefd4fe1deee3de39fd9cfb1d660dd1f505f09bddc93237c9f9782be12953468fc9fe44476c62d55
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fc2_get.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jian Weihang
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ # Installation
2
+
3
+ $ gem install fc2_get
4
+
5
+ # Usage
6
+
7
+ $ fc2_get VIDEO_ID
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fc2_get'
4
+
5
+ if ARGV.size == 1
6
+ Fc2Get.download ARGV[0]
7
+ else
8
+ puts "Usage: #{__FILE__} VIDEO_ID"
9
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fc2_get/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fc2_get"
8
+ spec.version = Fc2Get::VERSION
9
+ spec.authors = ["Jian Weihang"]
10
+ spec.email = ["tonytonyjan@gmail.com"]
11
+ spec.summary = "FC2 video downloader."
12
+ spec.description = "FC2 video downloader."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,40 @@
1
+ require 'digest'
2
+ require 'open-uri'
3
+ require 'net/http'
4
+ require 'fc2_get/version'
5
+
6
+ module Fc2Get
7
+ module_function
8
+ def mimi(video_id)
9
+ Digest::MD5.hexdigest(video_id + '_gGddgPfeaf_gzyr')
10
+ end
11
+
12
+ def params_uri video_id
13
+ URI("http://video.fc2.com/ginfo.php?mimi=#{mimi(video_id)}&upid=#{video_id}")
14
+ end
15
+
16
+ def decode_params params_str
17
+ Hash[params_str.scan(/([^=]+)=([^&]*)&?/)]
18
+ end
19
+
20
+ def download_uri video_id
21
+ params = decode_params(open(params_uri(video_id)).read)
22
+ URI("#{params['filepath']}?mid=#{params['mid']}")
23
+ end
24
+
25
+ def download video_id, path = '.'
26
+ video_uri = download_uri(video_id)
27
+ file_path = File.directory?(path) ?
28
+ File.expand_path(File.basename(video_uri.path), path) : path
29
+ Net::HTTP.get_response(video_uri) do |res|
30
+ size, total = 0, res.header['Content-Length'].to_i
31
+ open file_path, 'w' do |io|
32
+ res.read_body do |chunk|
33
+ io.write chunk
34
+ size += chunk.size
35
+ print "%d%% done (%d of %d)\r" % [(size * 100) / total, size, total]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Fc2Get
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fc2Get do
4
+ it 'has a version number' do
5
+ expect(Fc2Get::VERSION).not_to be nil
6
+ end
7
+
8
+ it '#mimi' do
9
+ expect(Fc2Get.mimi('20140528bpRKSJWR'))
10
+ .to eq 'c5e51ed4de1f4e6246b851bef4a210de'
11
+ end
12
+
13
+ it '#decode_params' do
14
+ expect(Fc2Get.decode_params('a=1&b=2&c=哈哈&d=&e='))
15
+ .to eq 'a' => '1', 'b' => '2', 'c' => '哈哈', 'd' => '', 'e' => ''
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'fc2_get'
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fc2_get
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jian Weihang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: FC2 video downloader.
56
+ email:
57
+ - tonytonyjan@gmail.com
58
+ executables:
59
+ - fc2_get
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/fc2_get
71
+ - fc2_get.gemspec
72
+ - lib/fc2_get.rb
73
+ - lib/fc2_get/version.rb
74
+ - spec/fc2_get_spec.rb
75
+ - spec/spec_helper.rb
76
+ homepage: ''
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.4
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: FC2 video downloader.
100
+ test_files:
101
+ - spec/fc2_get_spec.rb
102
+ - spec/spec_helper.rb