airstream 0.1.0
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.
- data/bin/airimg +2 -0
- data/bin/airstream +147 -0
- metadata +50 -0
data/bin/airimg
ADDED
data/bin/airstream
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
PROGRAM_VERSION = "0.1.0"
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'airplay'
|
7
|
+
require 'ruby-progressbar'
|
8
|
+
require 'digest'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'yaml'
|
11
|
+
|
12
|
+
options = {
|
13
|
+
reciever: '192.168.1.8',
|
14
|
+
quiet: false,
|
15
|
+
verbose: false,
|
16
|
+
use_local_http: false,
|
17
|
+
http_path: '/var/www/html/airstream/',
|
18
|
+
http_url: 'http://192.168.1.2/airstream/'
|
19
|
+
}
|
20
|
+
|
21
|
+
CONFIG_FILE = File.join(ENV['HOME'], '.airstreamrc')
|
22
|
+
|
23
|
+
if File.exists? CONFIG_FILE
|
24
|
+
options_config = YAML.load_file(CONFIG_FILE)
|
25
|
+
options.merge!(options_config)
|
26
|
+
else
|
27
|
+
File.open(CONFIG_FILE,'w') { |file| YAML::dump(options,file) }
|
28
|
+
STDERR.puts "Initialized configuration file in #{CONFIG_FILE}"
|
29
|
+
end
|
30
|
+
|
31
|
+
option_parser = OptionParser.new do |opts|
|
32
|
+
executable_name = File.basename($PROGRAM_NAME)
|
33
|
+
opts.banner = "offer a video file to an airplay device
|
34
|
+
|
35
|
+
Usage: #{executable_name} [options] [url|path/]filename
|
36
|
+
|
37
|
+
Basic options: (configure default in ~/.airstreamrc)
|
38
|
+
"
|
39
|
+
|
40
|
+
opts.on("-o RECIEVER",
|
41
|
+
"the airplay-device ip-address or domain") do |reciever|
|
42
|
+
options[:reciever] = reciever
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-q","--quiet",
|
46
|
+
"prevent most of the output") do |quiet|
|
47
|
+
options[:quiet] = quiet
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("--verbose",
|
51
|
+
"additional output") do |verbose|
|
52
|
+
options[:verbose] = verbose
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("--enable-use-httpd",
|
56
|
+
"use httpd to offer local files") do |use_httpd|
|
57
|
+
options[:use_local_httpd] = true
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on("-u HTTP_URL",
|
61
|
+
"the local webserver url") do |http_url|
|
62
|
+
options[:http_url] = http_url
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("-p HTTP_PATH",
|
66
|
+
"the local webserver directory path") do |path|
|
67
|
+
options[:http_path] = path
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("-v", "--version",
|
71
|
+
"output version information then quit") do |path|
|
72
|
+
puts "airstream v" + PROGRAM_VERSION
|
73
|
+
exit 0
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
if ARGV.empty?
|
78
|
+
STDERR.puts "No arguments given"
|
79
|
+
STDERR.puts option_parser
|
80
|
+
exit 1
|
81
|
+
end
|
82
|
+
|
83
|
+
begin
|
84
|
+
option_parser.parse!
|
85
|
+
|
86
|
+
if options[:quiet]
|
87
|
+
# def puts(msg) # # psssst
|
88
|
+
# end
|
89
|
+
# def print(msg)
|
90
|
+
# # psssst
|
91
|
+
# end
|
92
|
+
end
|
93
|
+
|
94
|
+
unless options[:reciever]
|
95
|
+
STDERR.puts "No host given"
|
96
|
+
exit 68
|
97
|
+
end
|
98
|
+
|
99
|
+
node = Airplay::Server::Node.new(options[:reciever],
|
100
|
+
options[:reciever], options[:reciever], 7000)
|
101
|
+
ap = Airplay::Client.new node
|
102
|
+
ap.use node # does not work without that second assign
|
103
|
+
|
104
|
+
ARGV.each do |file|
|
105
|
+
if File.exists?(file) && options[:use_local_httpd]
|
106
|
+
# raise ArgumentError unless options[:use_local_httpd]
|
107
|
+
# raise ArgumentError unless options[:http_path]
|
108
|
+
# raise ArgumentError unless options[:http_url]
|
109
|
+
filename = Digest::MD5.hexdigest(File.basename(file, '.mp4')) + ".mp4"
|
110
|
+
|
111
|
+
puts "generated hash-filename for local webserver: #{filename}" if options[:verbose]
|
112
|
+
|
113
|
+
unless File.exists?(options[:http_path] + filename)
|
114
|
+
FileUtils.cp(file, options[:http_path] + filename)
|
115
|
+
puts "copied file to #{options[:http_path]}#{filename}" if options[:verbose]
|
116
|
+
end
|
117
|
+
puts "sending local file #{filename}"
|
118
|
+
ap.send_video options[:http_url] + filename
|
119
|
+
else
|
120
|
+
puts "sending remote file #{filename}"
|
121
|
+
ap.send_video file
|
122
|
+
end
|
123
|
+
print "loading"
|
124
|
+
while ap.scrub['position'] == 0
|
125
|
+
# do not wait a second to make user believie it is
|
126
|
+
# loading much faster... psychology is a bitch
|
127
|
+
sleep 0.8
|
128
|
+
print "."
|
129
|
+
end
|
130
|
+
|
131
|
+
pbar_options = {
|
132
|
+
title: File.basename(file, '.mp4'),
|
133
|
+
total: ap.scrub['duration'],
|
134
|
+
format: '%t %a |%b>>%i| %p%%'
|
135
|
+
}
|
136
|
+
pbar = ProgressBar.create(pbar_options)
|
137
|
+
while ap.scrub['position'] < ap.scrub['duration']
|
138
|
+
pbar.progress = ap.scrub['position']
|
139
|
+
sleep 1.0
|
140
|
+
end
|
141
|
+
pbar.finish
|
142
|
+
end
|
143
|
+
rescue OptionParser::InvalidArgument => ex
|
144
|
+
STDERR.puts ex.message
|
145
|
+
STDERR.puts option_parser
|
146
|
+
end
|
147
|
+
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: airstream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christoph Lipautz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! "airstream allows to stream video and image files to\n airplay-devices,
|
15
|
+
a webserver is needed for local video\n files"
|
16
|
+
email:
|
17
|
+
- christoph at lipautz.org
|
18
|
+
executables:
|
19
|
+
- airstream
|
20
|
+
- airimg
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- bin/airstream
|
25
|
+
- bin/airimg
|
26
|
+
homepage: http://www.lipautz.org/
|
27
|
+
licenses: []
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project: airstream
|
46
|
+
rubygems_version: 1.8.24
|
47
|
+
signing_key:
|
48
|
+
specification_version: 3
|
49
|
+
summary: A command line tool for streaming to airplay-devices
|
50
|
+
test_files: []
|