youruby 1.0.7

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9707ba3e5cd0d65ff617ec9f66c005d7d0c3e10
4
+ data.tar.gz: 5aa2af92a98b9174fbbd0e4540ed88d2bbaead26
5
+ SHA512:
6
+ metadata.gz: 984d7e2793270b8f24eb87f02fc2efe46176552512921d6fd2588a236203f2c6e76d07920ef1b25985ec78e629b52f8b46643e690fb2cfae52f3db01a8bcc429
7
+ data.tar.gz: 16d5822734c8f151d3f999fe68b8711a2b4ca63e2d55692d8188e007ca4dabd82c77585e3c39b8c8650022c944121b964278f791bc8ee2ebe6eabf1d2be739b4
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+
5
+ script: 'rspec'
6
+
7
+ addons:
8
+ code_climate:
9
+ repo_token:45056479e65ea82635d5fe6a5aee63f6d50164a4e88be2877ca2a074807ac809
10
+
11
+ notifications:
12
+ email:
13
+ recipients:
14
+ - bruno.tripoloni@gmail.com
15
+ on_failure: change
16
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in youruby.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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,41 @@
1
+ # Youruby [![Build Status](https://travis-ci.org/btripoloni/youruby.svg?branch=master)](https://travis-ci.org/btripoloni/youruby) [![Code Climate](https://codeclimate.com/github/btripoloni/youruby/badges/gpa.svg)](https://codeclimate.com/github/btripoloni/youruby) [![Inline docs](http://inch-ci.org/github/btripoloni/youruby.svg?branch=master)](http://inch-ci.org/github/btripoloni/youruby) [![Project Status] (http://stillmaintained.com/btripoloni/youruby.png)](http://stillmaintained.com/btripoloni/youruby) [![Dependency Status](https://gemnasium.com/btripoloni/youruby.svg)](https://gemnasium.com/btripoloni/youruby)
2
+
3
+ Make donwloads of videos form Youtube using ruby
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'youruby'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install youruby
18
+
19
+ ## Usage
20
+
21
+ video_id = "xJkVQa_PMTY"
22
+ video = Youruby::Youtube.new(video_id)
23
+ video.download_video #make download of video.
24
+
25
+ Other methods
26
+ video.title
27
+ video.id
28
+ video.url
29
+ video.thumbnail(<quality>) #returns a hash
30
+
31
+ video.url("https://www.youtube.com/watch?v=UwPWLCVekGc") #set the id using the url of video.
32
+ video.path("make/downloads/here") #set the location of the video is downloaded
33
+
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/btripoloni/youruby/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
3
+ RSpec::Core::RakeTask.new
Binary file
@@ -0,0 +1,68 @@
1
+ require 'youruby/version'
2
+ require 'uri'
3
+ require 'cgi'
4
+
5
+ # the Youruby is a base of this gem
6
+ #
7
+ module Youruby
8
+ # Youtube Class
9
+ #
10
+ # @example
11
+ # Youruby::Youtube.new(id)
12
+ #
13
+ # @param id [String] the id of a video from Youtube
14
+ #
15
+ class Youtube
16
+ attr_reader :id, :location
17
+ root_path = File.expand_path(File.dirname(__FILE__))
18
+ yt_path = '../bin/youtube-dl'
19
+ YT_DL = File.join(root_path, yt_path)
20
+
21
+ def initialize(id)
22
+ @id = id
23
+ @location = 'temp/download'
24
+ end
25
+
26
+ def title
27
+ title = `#{YT_DL} --get-title #{url}`
28
+ title.delete("\n")
29
+ end
30
+
31
+ def file_path
32
+ File.join(@location, "#{title}-#{id}.mp4")
33
+ end
34
+
35
+ def url(url = nil)
36
+ if url
37
+ url = URI.parse url
38
+
39
+ url_parse = params(url.query)
40
+
41
+ @id = url_parse['v'].first
42
+
43
+ true
44
+ else
45
+ "http://youtube.com/watch?v=#{@id}"
46
+ end
47
+ end
48
+
49
+ def thumbnail(path)
50
+ "http://img.youtube.com/vi/#{@id}/#{path}.jpg"
51
+ end
52
+
53
+ def path(path)
54
+ @location = path
55
+ true
56
+ end
57
+
58
+ def download_video
59
+ system(YT_DL, '-o', file_path, url, '--no-progress')
60
+ end
61
+
62
+ private
63
+
64
+ def params(body)
65
+ CGI.parse(body)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module Youruby
2
+ VERSION = '1.0.7'
3
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'fakefs/spec_helpers'
3
+ require "codeclimate-test-reporter"
4
+ CodeClimate::TestReporter.start
5
+ require 'youruby'
6
+
7
+
8
+
9
+ describe Youruby do
10
+ include FakeFS::SpecHelpers
11
+ let(:video) { Youruby::Youtube.new('uaEJvYWc2ag') }
12
+ context 'Youtube'do
13
+ describe 'get' do
14
+ it '.title' do
15
+ expect(video.title).to eq('FFmpeg-slowmotion.1')
16
+ end
17
+
18
+ it '.id' do
19
+ expect(video.id).to eq('uaEJvYWc2ag')
20
+ end
21
+
22
+ it '.url' do
23
+ expect(video.url).to eq('http://youtube.com/watch?v=uaEJvYWc2ag')
24
+ end
25
+
26
+ it '.thumbnail' do
27
+ url = 'http://img.youtube.com/vi/uaEJvYWc2ag/default.jpg'
28
+ thumbnail = video.thumbnail('default')
29
+ expect(thumbnail).to eq(url)
30
+ end
31
+
32
+ it '.file_path' do
33
+ path = 'temp/download/FFmpeg-slowmotion.1-uaEJvYWc2ag.mp4'
34
+ expect(video.file_path).to eq(path)
35
+ end
36
+ end
37
+
38
+ describe 'download' do
39
+ it '.download_video' do
40
+ FakeFS do
41
+ video.download_video
42
+ File.exist? '#{video.get_title}-#{video.get_id}.mp4'
43
+ end
44
+ end
45
+
46
+ it '.download_preview'
47
+ end
48
+
49
+ describe 'set' do
50
+ it '.url' do
51
+ url = 'https://www.youtube.com/watch?v=lIzAlULvipk'
52
+ expect(video.url(url)).to eq(true)
53
+ end
54
+
55
+ it 'path' do
56
+ expect(video.path('/local/')).to eq(true)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,89 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ =end
89
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'youruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'youruby'
8
+ spec.version = Youruby::VERSION
9
+ spec.authors = ['Bruno Tripoloni']
10
+ spec.email = ['bruno.tripoloni@gmail.com']
11
+ spec.summary = %q{Make downloads of video from Youtube.}
12
+ spec.description = %q{Make downloads of video from Youtube}
13
+ spec.homepage = 'http://github.com/btripoloni/youruby'
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.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'fakefs'
25
+ spec.add_development_dependency 'codeclimate-test-reporter'
26
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: youruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Tripoloni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-22 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: 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
+ - !ruby/object:Gem::Dependency
56
+ name: fakefs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Make downloads of video from Youtube
84
+ email:
85
+ - bruno.tripoloni@gmail.com
86
+ executables:
87
+ - youtube-dl
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/youtube-dl
99
+ - lib/youruby.rb
100
+ - lib/youruby/version.rb
101
+ - spec/lib/youruby_spec.rb
102
+ - spec/spec_helper.rb
103
+ - youruby.gemspec
104
+ homepage: http://github.com/btripoloni/youruby
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Make downloads of video from Youtube.
128
+ test_files:
129
+ - spec/lib/youruby_spec.rb
130
+ - spec/spec_helper.rb