gaqzi-youtube-downloader 0.5.1 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README +43 -0
- data/youtube-downloader +23 -21
- metadata +4 -2
data/README
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Using some, for unix based systems, common tools to download movies
|
2
|
+
and optionally ripping the audio from them.
|
3
|
+
|
4
|
+
USAGE:
|
5
|
+
youtube-downloader <youtube-url> [command]
|
6
|
+
|
7
|
+
COMMANDS:
|
8
|
+
- audio
|
9
|
+
downloads the video to a fifo-pipe and start the processing directly
|
10
|
+
<3 mkfifo :)
|
11
|
+
- rip or all
|
12
|
+
rips the audio
|
13
|
+
|
14
|
+
With no command set it will download the video.
|
15
|
+
|
16
|
+
EDITING FILENAME:
|
17
|
+
This script is set to use the Ruby Readline library, I've not found a way to
|
18
|
+
add a default value to the line to be read in.
|
19
|
+
|
20
|
+
But I've added the default title toe Readline history buffer so press the
|
21
|
+
up arrow key on your keyboard to get it filled in so you can change it.
|
22
|
+
|
23
|
+
DEPENDENCIES:
|
24
|
+
- cURL, fetch or wget. We try to be smart and choose a good one
|
25
|
+
depending on the running system so this shouldn't be to big a deal.
|
26
|
+
- mplayer, for ripping the audio
|
27
|
+
- lame, for encoding the audio
|
28
|
+
- mkfifo, rm and touch ;)
|
29
|
+
|
30
|
+
CONFIGURATION:
|
31
|
+
In your home directory create a file named .youtube-downloader
|
32
|
+
with these values:
|
33
|
+
|
34
|
+
---
|
35
|
+
# To download the files to the current directory set to .
|
36
|
+
:download_dir: .
|
37
|
+
:music_dir: .
|
38
|
+
:temp_dir: /tmp
|
39
|
+
:file_extension: flv
|
40
|
+
|
41
|
+
# If we want the timestamp on the files to be time of download instead
|
42
|
+
# of time of the file
|
43
|
+
:touch: true
|
data/youtube-downloader
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$KCODE
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$KCODE='u'
|
3
3
|
require 'open-uri'
|
4
4
|
require 'ftools'
|
5
|
+
require 'yaml'
|
6
|
+
require 'readline'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
begin
|
9
|
+
ConfigYT = YAML::load_file(File.join(ENV['HOME'], '.youtube-downloader'))
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
STDERR.puts "No configuration file found, please copy one."
|
12
|
+
STDERR.puts " cp #{File.dirname(__FILE__)}/.youtube-downloader ~/"
|
13
|
+
exit 1
|
14
|
+
end
|
14
15
|
|
15
16
|
|
16
17
|
if ARGV.empty? or ARGV[0].match(/(-h)|((--)?help)/i)
|
@@ -28,7 +29,7 @@ end
|
|
28
29
|
|
29
30
|
Video = Struct.new(:title, :video_id, :id) do
|
30
31
|
def to_s
|
31
|
-
"http://youtube.com/get_video.php?t=#{id}&video_id=#{video_id}"
|
32
|
+
"http://youtube.com/get_video.php?t=#{id}&video_id=#{video_id}&fmt=18"
|
32
33
|
end
|
33
34
|
|
34
35
|
def empty?
|
@@ -61,14 +62,15 @@ rescue Exception => e
|
|
61
62
|
exit 1
|
62
63
|
end
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
puts 'To edit filename press up arrow'
|
66
|
+
Readline::HISTORY.push the_vid.title
|
67
|
+
name = Readline::readline("Filename: [#{the_vid.title}] ") #STDIN.gets.strip
|
66
68
|
name = if name.empty?
|
67
69
|
the_vid.title
|
68
70
|
else
|
69
71
|
name
|
70
72
|
end.gsub(/(['" &;<>|$#!])/, '\\\\\1') # Quote these so we can pass to shell
|
71
|
-
the_file = "#{
|
73
|
+
the_file = "#{ConfigYT[:download_dir]}/#{name}.#{ConfigYT[:file_extension]}"
|
72
74
|
|
73
75
|
download_command = case ENV['OSTYPE']
|
74
76
|
when 'darwin' # Mac OS X
|
@@ -80,14 +82,14 @@ download_command = case ENV['OSTYPE']
|
|
80
82
|
end
|
81
83
|
|
82
84
|
def rip_audio(file, name)
|
83
|
-
`/usr/bin/env mkfifo #{
|
84
|
-
IO.popen("/usr/bin/env lame -b 160 #{
|
85
|
-
`/usr/bin/env mplayer #{file} -ao pcm:fast:file=#{
|
86
|
-
`/usr/bin/env rm #{
|
85
|
+
`/usr/bin/env mkfifo #{ConfigYT[:temp_dir]}/#{name}`
|
86
|
+
IO.popen("/usr/bin/env lame -b 160 #{ConfigYT[:temp_dir]}/#{name} #{ConfigYT[:music_dir]}/#{name}.mp3")
|
87
|
+
`/usr/bin/env mplayer #{file} -ao pcm:fast:file=#{ConfigYT[:temp_dir]}/#{name} -vc null -vo null`
|
88
|
+
`/usr/bin/env rm #{ConfigYT[:temp_dir]}/#{name}`
|
87
89
|
end
|
88
90
|
|
89
91
|
def remove(name)
|
90
|
-
`/usr/bin/env rm #{
|
92
|
+
`/usr/bin/env rm #{the_file}`
|
91
93
|
end
|
92
94
|
|
93
95
|
case ARGV[1]
|
@@ -105,8 +107,8 @@ when /(all)|(rip)/i # Both audio and video
|
|
105
107
|
`#{download_command}`
|
106
108
|
rip_audio(the_file, name)
|
107
109
|
|
108
|
-
`/usr/bin/env touch #{
|
110
|
+
`/usr/bin/env touch #{the_file}` if ConfigYT[:touch]
|
109
111
|
else
|
110
112
|
`#{download_command}`
|
111
|
-
`/usr/bin/env touch #{
|
113
|
+
`/usr/bin/env touch #{the_file}` if ConfigYT[:touch]
|
112
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaqzi-youtube-downloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.6"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Bj\xC3\xB6rn Andersson"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: .
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-07 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,6 +23,8 @@ extra_rdoc_files: []
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
- youtube-downloader
|
26
|
+
- .youtube-downloader
|
27
|
+
- README
|
26
28
|
has_rdoc: false
|
27
29
|
homepage: http://github.com/ba/youtube-downloader
|
28
30
|
post_install_message:
|