JVCGet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eec474eceaace8174dfcf80e0acb8b9105807fdd
4
+ data.tar.gz: d4af98a4e2001df6b7455cbe5e711910150f549e
5
+ SHA512:
6
+ metadata.gz: cae1ad018e49f291b4610cac4276d4a96f41d517b992e2b2489b4b26aa1cc5bbed451530518c51256e557836f60c321ec72cd2708d62c0b531a60d714620d546
7
+ data.tar.gz: 4256e13e57f34fd4cb143776e292ef74943f199e86d87a36da0afa48407757bdd9468bffdd870fdf29719f607358149b36608471ccd8f222b2d2133682dcbd9e
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in JVCGet.gemspec
4
+ gemspec
data/JVCGet.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'JVCGet/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "JVCGet"
8
+ spec.version = JVCGet::VERSION
9
+ spec.authors = ["Yann David"]
10
+ spec.email = ["davidyann88@gmail.com"]
11
+
12
+ spec.summary = %q{Download a 'Chronique' video to your PC or just get the URL.}
13
+ spec.description = %q{JVC Player suck balls! Using this you can either download the VIDEO (not recommended)or just get the link to listen straight from your browser but without using JVC Player.}
14
+ spec.homepage = "http://typositoire.github.io/JVCGet/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ # spec.bindir = "exe"
27
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.executables = ["jvcget"]
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_runtime_dependency 'rest-client'
32
+ spec.add_runtime_dependency 'nokogiri'
33
+ spec.add_runtime_dependency 'colorize'
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.10"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rspec"
38
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Yann David
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # JVCGet
2
+ JVC Player suck balls! Using this you can either download the VIDEO (not recommended)or just get the link to listen straight from your browser but without using JVC Player.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'JVCGet'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install JVCGet
19
+
20
+ ## Usage
21
+
22
+ ```
23
+ Options:
24
+ -u, --url [URL] URL of the JVC Chronique.
25
+ -q, --quality [1080|720|400|272] Video Quality to download. Defaults to 1080.
26
+ -o [/path/to/save/video], Path where you want to download the video. Defaults to ..
27
+ --output
28
+ -n, --no_download Do not download video just output URL. Defaults to false
29
+ -d, --debug Run in debug mode
30
+ -h, --help Display help
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Typositoire/JVCGet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "JVCGet"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/jvcget ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "JVCGet"
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/JVCGet.rb ADDED
@@ -0,0 +1,43 @@
1
+ require "JVCGet/version"
2
+ require 'json'
3
+ require 'logger'
4
+ require 'rest-client'
5
+ require 'nokogiri'
6
+ require 'OptsParser'
7
+ require 'JVCVideo'
8
+
9
+ module JVCGet
10
+ op = OptsParser.new
11
+ options = op.get_options!(ARGV)
12
+
13
+ STDOUT.sync = true
14
+
15
+ logger = Logger.new($stdout)
16
+
17
+ logger.info("Abort with Ctrl-C".colorize(:red))
18
+ logger.info("Getting page.".colorize(:green))
19
+ page = Nokogiri::HTML(RestClient.get(options[:url]))
20
+
21
+ logger.info("Finding video URL.".colorize(:green))
22
+ videometa = page.css('meta').select{ | m | m['itemprop'] == "contentUrl"}
23
+
24
+ videometa.each do |info|
25
+ logger.info("Found URL".colorize(:green))
26
+ video_url_builder = JVCVideo.new(info['content'], options[:output], logger, options[:no_download])
27
+
28
+ case options[:quality]
29
+ when '1080'
30
+ logger.info('Extracting video!'.colorize(:green))
31
+ video_url_builder.get1080
32
+ logger.info('Done')
33
+ when '720'
34
+ video_url_builder.get720
35
+ when '400'
36
+ video_url_builder.get400
37
+ when '272'
38
+ video_url_builder.get272
39
+ else
40
+ logger.error("Nothing?".colorize(:red))
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module JVCGet
2
+ VERSION = "0.1.0"
3
+ end
data/lib/JVCVideo.rb ADDED
@@ -0,0 +1,59 @@
1
+ require 'uri'
2
+ require 'open-uri'
3
+ require 'colorize'
4
+
5
+ class JVCVideo
6
+ def initialize(url, output, logger, no_download)
7
+ @no_download = no_download
8
+ @logger = logger
9
+ @logger.info("Initializing URL Builder.".colorize(:green))
10
+ @url_parts = url.split(".")
11
+ @output = output
12
+ end
13
+
14
+ def save_video(url)
15
+ filename = URI(url).path.split('/').last
16
+
17
+ if ::File.exist?(::File.join(@output, filename))
18
+ @logger.warn("File already exist.. Adding random number in path".colorize(:yellow))
19
+ fullpath = ::File.join(@output, "#{rand(5000).to_s}-#{filename}")
20
+ else
21
+ fullpath = ::File.join(@output, filename)
22
+ end
23
+
24
+ @logger.info("Saving #{filename} to #{fullpath}...".colorize(:green))
25
+
26
+ open(fullpath, 'wb') do |file|
27
+ file.print open(url).read
28
+ end
29
+
30
+ @logger.info('Done!'.colorize(:green))
31
+ end
32
+
33
+ def get1080
34
+ url = "http://video1080.jeuxvideo.#{@url_parts[2]}.mp4"
35
+ @logger.info("Final url: #{url}".colorize(:green))
36
+ save_video(url) unless @no_download
37
+ end
38
+
39
+ def get720
40
+ url = "http://video720.jeuxvideo.#{@url_parts[2]}.mp4"
41
+ url.gsub!('1080p', '720p')
42
+ @logger.info("Final url: #{url}".colorize(:green))
43
+ save_video(url) unless @no_download
44
+ end
45
+
46
+ def get400
47
+ url = "http://videohq.jeuxvideo.#{@url_parts[2]}.mp4"
48
+ url.gsub!('1080p', 'high')
49
+ logger.info("Final url: #{url}".colorize(:green))
50
+ save_video(url) unless @no_download
51
+ end
52
+
53
+ def get272
54
+ url = "http://video.jeuxvideo.#{@url_parts[2]}.mp4"
55
+ url.gsub!('1080p', 'low')
56
+ @logger.info("Final url: #{url}".colorize(:green))
57
+ save_video(url) unless @no_download
58
+ end
59
+ end
data/lib/OptsParser.rb ADDED
@@ -0,0 +1,62 @@
1
+ require 'optparse'
2
+
3
+ class OptsParser
4
+ def get_options!(argv)
5
+
6
+ # defaults
7
+ options = {}
8
+ options[:action] = :perform
9
+ options[:quality] = '1080'
10
+ options[:output] = ::File.join(".")
11
+ options[:no_download] = false
12
+
13
+ parser = OptionParser.new do |opts|
14
+ opts.banner = [
15
+ 'JVCGet: Get video link for JVC Chronique or download them.',
16
+ ''
17
+ ].join("\n")
18
+
19
+ opts.separator 'Options:'
20
+
21
+ # More examples at http://apidock.com/ruby/OptionParser or in our
22
+ # other scripts.
23
+ opts.on('-u', '--url [URL]', "URL of the JVC Chronique.") do |value|
24
+ options[:url] = value
25
+ end
26
+
27
+ opts.on('-q', '--quality [1080|720|400|272]', "Video Quality to download. Defaults to #{options[:quality]}.") do |value|
28
+ options[:quality] = value
29
+ end
30
+
31
+ opts.on('-o', '--output [/path/to/save/video]', "Path where you want to download the video.") do |value|
32
+ options[:output] = value
33
+ end
34
+
35
+ opts.on('-n', '--no_download', "Do not download video just output URL. Defaults to #{options[:no_download]}") do |_value|
36
+ options[:no_download] = true
37
+ end
38
+
39
+ opts.on_tail('-d', '--debug', 'Run in debug mode') do |_n|
40
+ ENV['DEBUG'] = 'true'
41
+ end
42
+
43
+ opts.on_tail('-h', '--help', 'Display help') do |_n|
44
+ options[:action] = :help
45
+ end
46
+ end
47
+
48
+ parser.parse!(argv)
49
+
50
+ if :help == options[:action]
51
+ puts parser.to_s
52
+ exit
53
+ else
54
+ unless options[:url]
55
+ puts '--url is mandatory.'
56
+ puts parser.to_s
57
+ abort
58
+ end
59
+ end
60
+ options
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: JVCGet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yann David
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: JVC Player suck balls! Using this you can either download the VIDEO (not
98
+ recommended)or just get the link to listen straight from your browser but without
99
+ using JVC Player.
100
+ email:
101
+ - davidyann88@gmail.com
102
+ executables:
103
+ - jvcget
104
+ extensions: []
105
+ extra_rdoc_files: []
106
+ files:
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
+ - CODE_OF_CONDUCT.md
111
+ - Gemfile
112
+ - JVCGet.gemspec
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - bin/jvcget
118
+ - bin/setup
119
+ - lib/JVCGet.rb
120
+ - lib/JVCGet/version.rb
121
+ - lib/JVCVideo.rb
122
+ - lib/OptsParser.rb
123
+ homepage: http://typositoire.github.io/JVCGet/
124
+ licenses:
125
+ - MIT
126
+ metadata:
127
+ allowed_push_host: https://rubygems.org
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.4.6
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Download a 'Chronique' video to your PC or just get the URL.
148
+ test_files: []