youtube_dl 0.0.1 → 0.0.2

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: d3bcd6585df33a5d991f6ca9f353a2a3301b9730
4
- data.tar.gz: b04fde80b8a88014b947d85712710856efb41d34
3
+ metadata.gz: f68e3a9e4534f88ca0a6de0b465d1f3e7da6cc69
4
+ data.tar.gz: 4173cf3310078ba93200996d885d9e43a419caa5
5
5
  SHA512:
6
- metadata.gz: de8dcd152cd2e4a7d3ad0bb858bba7bacb56fd835427d6d77b5c7529e5cf1bebb187e4250ecb279c30615a487b0fd6a21d98d7ce9ea8726d3111eb1f8f6ec8c2
7
- data.tar.gz: c5bc012d02e35eff3c78f690f4df88c67630a9a39429d140573ff084eb64342d1a545b59058eafd3f59b2347b4b63a26e296d9f4731f7022059a5a55b19ab43f
6
+ metadata.gz: c20f848020ff23fc66b0411980e0f5a8b1de0c732113f77d01d69bdd6c39acafcbfbe65a776a350dc20e6d9552d882739453d6b03fbd31cadbd18a1db3e6f27e
7
+ data.tar.gz: a66a9c042f5de4b0764b04aa7c134700f24c985093ab530fb2e8f74a7b802f4c18c0f495faf546facafa655396d7a7e903a0b714210e4ab15d65f247541082ef
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ rdoc/
3
+ coverage/
4
+ pkg/
5
+ .rvmrc
6
+ *.rbc
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 jadonsapna11
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # youtube-dl gem
2
+
3
+ This is a youtube-dl video downloader wrapper.
4
+
5
+ ## Usage
6
+ >> youtube = YoutubeDl::YoutubeVideo.new("http://www.youtube.com/watch?v=zzG4K2m_j5U")
7
+ >> video = youtube.download_video
8
+ => "tmp/downloads/zzG4K2m_j5U.mp4"
9
+ >> preview = youtube.download_preview
10
+ => "tmp/downloads/zzG4K2m_j5U.jpg"
11
+
12
+ ## Changelog
13
+
14
+ ### 0.0.2
15
+ Update youtube-dl script to last binary version. This update fixed download from youtube error.
16
+
17
+ ### 0.0.1
18
+ Initial release.
data/bin/youtube-dl ADDED
Binary file
data/lib/youtube_dl.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'uri'
4
+ require 'cgi'
5
+
6
+ module YoutubeDl
7
+ class YoutubeVideo
8
+ YOUTUBE_DL = File.join(File.expand_path(File.dirname(__FILE__)), "../bin/youtube-dl")
9
+
10
+ FORMATS = {18 => {ext: "mp4"}}
11
+
12
+ def initialize(page_uri, options = {})
13
+ @uri = URI.parse page_uri
14
+ @location = options[:location] || "tmp/downloads" # default path
15
+ @format = options[:format] || 18 # default format
16
+ end
17
+
18
+ def video_id
19
+ params(@uri.query)['v'].first
20
+ end
21
+
22
+ def title
23
+ extended_info_body['title'].first if extended_info.code == 200
24
+ end
25
+
26
+ def extended_info
27
+ @video_info ||= HTTParty.get("http://www.youtube.com/get_video_info?video_id=#{video_id}&el=detailpage")
28
+ end
29
+
30
+ def download_video(options = {})
31
+ `#{YOUTUBE_DL} -q --no-progress -o "#{video_filename}" -f #{options[:format] || @format} "#{@uri.to_s}"`
32
+ video_filename if File.exist?(video_filename)
33
+ end
34
+
35
+ def download_preview(options = {})
36
+ link = if !extended_info_body["iurlsd"].blank?
37
+ extended_info_body["iurlsd"].first
38
+ else
39
+ extended_info_body["thumbnail_url"].first
40
+ end
41
+ `wget -O "#{preview_filename}" "#{link}"`
42
+ preview_filename if File.exist?(preview_filename)
43
+ end
44
+
45
+ def preview_filename
46
+ File.join(@location, "#{video_id}.jpg")
47
+ end
48
+
49
+ def video_filename
50
+ File.join(@location, "#{video_id}.#{FORMATS[@format][:ext]}")
51
+ end
52
+
53
+ def extended_info_body
54
+ params(extended_info.body)
55
+ end
56
+
57
+ private
58
+
59
+ def params(body)
60
+ CGI.parse(body)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module YoutubeDl
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/youtube_dl/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Sapna Jadon"]
6
+ gem.email = ["jadon.sapna11@gmail.com"]
7
+ gem.description = %q{Youtube video downloader}
8
+ gem.summary = %q{This is a wrapper for youtube_dl}
9
+ gem.homepage = ''
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = [
13
+ ".gitignore",
14
+ "LICENSE",
15
+ "README.md",
16
+ "lib/youtube_dl.rb",
17
+ "lib/youtube_dl/version.rb",
18
+ "youtube_dl.gemspec",
19
+ "bin/youtube-dl",
20
+ ]
21
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+
23
+ gem.name = "youtube_dl"
24
+ gem.require_paths = ['lib']
25
+ gem.version = YoutubeDl::VERSION
26
+
27
+ gem.add_dependency "httparty"
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_dl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sapna Jadon
@@ -27,10 +27,18 @@ dependencies:
27
27
  description: Youtube video downloader
28
28
  email:
29
29
  - jadon.sapna11@gmail.com
30
- executables: []
30
+ executables:
31
+ - youtube-dl
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
- files: []
34
+ files:
35
+ - .gitignore
36
+ - LICENSE
37
+ - README.md
38
+ - lib/youtube_dl.rb
39
+ - lib/youtube_dl/version.rb
40
+ - youtube_dl.gemspec
41
+ - bin/youtube-dl
34
42
  homepage: ''
35
43
  licenses: []
36
44
  metadata: {}