ytripper 0.0.1
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 +7 -0
- data/bin/ytripper +5 -0
- data/lib/ytripper.rb +51 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c09f26407e63e3dec5acc37a968f431fea85e6b8e0199ff88c8c6759f32a50e5
|
4
|
+
data.tar.gz: b8a55b59cf75c8e4b4b88a6626263dfa81d5c88fb2c1059df31a4b2208397225
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cac60f4a7ae51af32a5e93391b3f69842dfa6b715816e48d106a8274d58811437a8ce7ba29df8478c4fc39b516170f074730ece6c98aa539a95dd1576eb328d8
|
7
|
+
data.tar.gz: 7370aa5ed01028c1686135f112ed19d78dd5be7eb7db1ce521f3ef179ecf8852a7ed4d865b411f26c0b19c67e476f122f4ddf9957f98af5a1f0f80e2b1d9471b
|
data/bin/ytripper
ADDED
data/lib/ytripper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'uri'
|
3
|
+
require 'ytsearch'
|
4
|
+
|
5
|
+
class YouTubeRipper
|
6
|
+
def self.rip
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |parser|
|
9
|
+
parser.on("-i", "--input-file FILE", "Specify the input FILE") do |input_file|
|
10
|
+
options[:i] = input_file
|
11
|
+
end
|
12
|
+
|
13
|
+
parser.on("-o", "--output-directory DIRECTORY", "Specify the output DIRECTORY") do |output_directory|
|
14
|
+
options[:o] = output_directory
|
15
|
+
end
|
16
|
+
|
17
|
+
parser.on("-f", "--output-format FORMAT", "Specify the output FORMAT") do |format|
|
18
|
+
options[:f] = format
|
19
|
+
end
|
20
|
+
end.parse!
|
21
|
+
|
22
|
+
raise OptionParser::MissingArgument if options[:i].nil?
|
23
|
+
raise OptionParser::MissingArgument if options[:o].nil?
|
24
|
+
raise OptionParser::MissingArgument if options[:f].nil?
|
25
|
+
|
26
|
+
list = File.open(options[:i]).read.split("\n")
|
27
|
+
|
28
|
+
list.each do |item|
|
29
|
+
qoptions = {
|
30
|
+
"q" => URI.encode_www_form_component(item),
|
31
|
+
"part" => "snippet"
|
32
|
+
}
|
33
|
+
|
34
|
+
videoId = YoutubeSearch.search(qoptions)['items'][0]['id']['videoId']
|
35
|
+
url = "https://www.youtube.com/watch?v=#{videoId}"
|
36
|
+
|
37
|
+
format = options[:f]
|
38
|
+
|
39
|
+
case format
|
40
|
+
when 'mp3'
|
41
|
+
command = "youtube-dl --extract-audio --audio-format mp3 -o '#{options[:o]}/%(title)s.%(ext)s' #{url}"
|
42
|
+
when 'mp4'
|
43
|
+
command = "youtube-dl -f 137+140 -o '#{options[:o]}/%(title)s.%(ext)s' #{url}"
|
44
|
+
end
|
45
|
+
|
46
|
+
if defined?(command)
|
47
|
+
system(command)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ytripper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timothy de Jongh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Batch download YouTube videos
|
14
|
+
email: icetimux@gmail.com
|
15
|
+
executables:
|
16
|
+
- ytripper
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/ytripper
|
21
|
+
- lib/ytripper.rb
|
22
|
+
homepage: http://icetimux.net
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.1.4
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: YouTube Ripper
|
45
|
+
test_files: []
|