aucast 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +9 -0
- data/aucast.gemspec +45 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/aucast +9 -0
- data/lib/aucast/cli.rb +114 -0
- data/lib/aucast/endpoint.rb +33 -0
- data/lib/aucast/file_upload.rb +29 -0
- data/lib/aucast/version.rb +3 -0
- data/lib/aucast/youtube_dl.rb +61 -0
- data/lib/aucast.rb +8 -0
- metadata +178 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b5e50db77764f71621e86334c0889878a2427168b274b0144901e258ccff6d31
|
|
4
|
+
data.tar.gz: 2691cdc1f251d63de6790ed786294f96c0206d401b000b2c129a368e341132e2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a791c5f40dc8192fb4b461f17e29bcd091a5ed10ef8a5c0e441190a3aa01c7bf29c155d9f79a888beef859c9bbfb7e0e36032d7ef238baf6e26854badc2b0809
|
|
7
|
+
data.tar.gz: cb210c7e09e846462bad833091377714a0062fde4c4a38ccbad811073c53c8ce1f99547da615f19301f0c5d4f6445385066db864b2adcd2fa3ab0026db3fb7d9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at bruno.wernimont@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
aucast (0.1.0)
|
|
5
|
+
rest-client (~> 2.0)
|
|
6
|
+
thor (~> 0.20)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
addressable (2.5.2)
|
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
13
|
+
ansi (1.5.0)
|
|
14
|
+
builder (3.2.3)
|
|
15
|
+
byebug (10.0.2)
|
|
16
|
+
crack (0.4.3)
|
|
17
|
+
safe_yaml (~> 1.0.0)
|
|
18
|
+
domain_name (0.5.20180417)
|
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
20
|
+
hashdiff (0.3.7)
|
|
21
|
+
http-cookie (1.0.3)
|
|
22
|
+
domain_name (~> 0.5)
|
|
23
|
+
mime-types (3.1)
|
|
24
|
+
mime-types-data (~> 3.2015)
|
|
25
|
+
mime-types-data (3.2016.0521)
|
|
26
|
+
minitest (5.11.3)
|
|
27
|
+
minitest-reporters (1.1.19)
|
|
28
|
+
ansi
|
|
29
|
+
builder
|
|
30
|
+
minitest (>= 5.0)
|
|
31
|
+
ruby-progressbar
|
|
32
|
+
netrc (0.11.0)
|
|
33
|
+
public_suffix (3.0.2)
|
|
34
|
+
rake (10.5.0)
|
|
35
|
+
rest-client (2.0.2)
|
|
36
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
37
|
+
mime-types (>= 1.16, < 4.0)
|
|
38
|
+
netrc (~> 0.8)
|
|
39
|
+
ruby-progressbar (1.9.0)
|
|
40
|
+
safe_yaml (1.0.4)
|
|
41
|
+
thor (0.20.0)
|
|
42
|
+
unf (0.1.4)
|
|
43
|
+
unf_ext
|
|
44
|
+
unf_ext (0.0.7.5)
|
|
45
|
+
webmock (3.3.0)
|
|
46
|
+
addressable (>= 2.3.6)
|
|
47
|
+
crack (>= 0.3.2)
|
|
48
|
+
hashdiff
|
|
49
|
+
|
|
50
|
+
PLATFORMS
|
|
51
|
+
ruby
|
|
52
|
+
|
|
53
|
+
DEPENDENCIES
|
|
54
|
+
aucast!
|
|
55
|
+
bundler (~> 1.16)
|
|
56
|
+
byebug
|
|
57
|
+
minitest (~> 5.11)
|
|
58
|
+
minitest-reporters (>= 1.1)
|
|
59
|
+
rake (~> 10.0)
|
|
60
|
+
webmock (>= 3.0)
|
|
61
|
+
|
|
62
|
+
BUNDLED WITH
|
|
63
|
+
1.16.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Bruno Wernimont
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all 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,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Podcast
|
|
2
|
+
|
|
3
|
+
Ruby gem command line tool to upload audio file and youtube video to [aucast](https://aucast.io) app.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install it with:
|
|
8
|
+
|
|
9
|
+
$ gem install aucast
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
$ aucast
|
|
14
|
+
|
|
15
|
+
Commands:
|
|
16
|
+
aucast help [COMMAND] # Describe available commands or one specific command
|
|
17
|
+
aucast setup # Create a setup config file
|
|
18
|
+
aucast upload # Upload audio file(s) (mp3, m4a, http, ...) to Aucast
|
|
19
|
+
aucast copy # Copy file(s) to your Aucast inbox dir
|
|
20
|
+
aucast version
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
-a, [--address=ADDRESS] # phone ip address or bonjour service name to reach your phone
|
|
24
|
+
|
|
25
|
+
$ aucast upload *.mp3
|
|
26
|
+
$ aucast upload *.mp3 -a fpg128.local
|
|
27
|
+
$ aucast upload podcast.mp3
|
|
28
|
+
$ aucast upload https://www.youtube.com/watch?v=W01L70IGBgE
|
|
29
|
+
$ aucast copy podcast.mp3
|
|
30
|
+
$ aucast copy *.mp3
|
|
31
|
+
$ aucast copy https://www.youtube.com/watch?v=W01L70IGBgE
|
|
32
|
+
|
|
33
|
+
## Youtube-dl
|
|
34
|
+
|
|
35
|
+
Aucast use [youtube-dl](https://github.com/ytdl-org/youtube-dl) if you provide a web link, it will use it to download and convert video to audio.
|
|
36
|
+
|
|
37
|
+
## Copyright
|
|
38
|
+
|
|
39
|
+
We are not responsible of any violation of copyrighted content.
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
44
|
+
|
|
45
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/brunow/podcast. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
54
|
+
|
|
55
|
+
## Code of Conduct
|
|
56
|
+
|
|
57
|
+
Everyone interacting in the Podcast project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/brunow/podcast/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/aucast.gemspec
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "aucast/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "aucast"
|
|
8
|
+
spec.version = Aucast::VERSION
|
|
9
|
+
spec.authors = ["Bruno Wernimont"]
|
|
10
|
+
spec.email = ["contact@aucast.io"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Upload audio file and video media URL to Aucast iOS app.}
|
|
13
|
+
spec.description = %q{The CLI for uploading audio and video URL to Aucast iOS app, that support youtube-dl.}
|
|
14
|
+
spec.homepage = "https://aucast.io"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
32
|
+
spec.executables = ["aucast"]
|
|
33
|
+
spec.require_paths = ["lib"]
|
|
34
|
+
|
|
35
|
+
spec.add_dependency "thor", '~> 0.20'
|
|
36
|
+
spec.add_dependency "rest-client", '~> 2.0'
|
|
37
|
+
|
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
40
|
+
spec.add_development_dependency "minitest", "~> 5.11"
|
|
41
|
+
spec.add_development_dependency "minitest-reporters", ">= 1.1"
|
|
42
|
+
spec.add_development_dependency "webmock", ">= 3.0"
|
|
43
|
+
spec.add_development_dependency "byebug"
|
|
44
|
+
|
|
45
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "aucast"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/aucast
ADDED
data/lib/aucast/cli.rb
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
require 'aucast/file_upload'
|
|
4
|
+
require 'aucast/endpoint'
|
|
5
|
+
require 'aucast/youtube_dl'
|
|
6
|
+
require 'uri'
|
|
7
|
+
|
|
8
|
+
CONFIG_FILENAME = ".aucast.yml"
|
|
9
|
+
|
|
10
|
+
module Aucast
|
|
11
|
+
class Cli < Thor
|
|
12
|
+
|
|
13
|
+
def self.exit_on_failure?
|
|
14
|
+
true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc 'setup', 'Setup CLI'
|
|
18
|
+
def setup
|
|
19
|
+
yaml = {
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
server_address = ask("Type your Aucast bonjour webserver name (leave blank if you don't want to use it): ")
|
|
23
|
+
|
|
24
|
+
if server_address.length > 0
|
|
25
|
+
yaml["address"] = server_address
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
copy_to_path = ask("Type your inbox dir (leave blank if you doesn't want to use it): ", path: true)
|
|
29
|
+
|
|
30
|
+
if copy_to_path.length > 0
|
|
31
|
+
yaml["copy_to"] = copy_to_path
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
if yaml.count == 0
|
|
35
|
+
say("Exit, nothing to write.")
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
file_path = File.join(Dir.home, "/#{CONFIG_FILENAME}")
|
|
40
|
+
File.write(file_path, yaml.to_yaml)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
desc 'upload', 'Upload file(s) to Aucast'
|
|
44
|
+
option :address, type: :string, aliases: "-a", desc: "phone ip address or bonjour service name to reach your phone"
|
|
45
|
+
def upload(*args)
|
|
46
|
+
args.each do |arg|
|
|
47
|
+
if arg =~ URI::regexp
|
|
48
|
+
youtube = YoutubeDl.new(arg)
|
|
49
|
+
upload_file(youtube)
|
|
50
|
+
else
|
|
51
|
+
file = FileUpload.new(arg)
|
|
52
|
+
upload_file(file)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc 'copy', 'Copy file(s) to a specified path'
|
|
58
|
+
option :destination, type: :string, aliases: "-d", desc: "the destination where to copy file"
|
|
59
|
+
def copy(*args)
|
|
60
|
+
destination_dir = options[:copy_to] || options[:destination]
|
|
61
|
+
|
|
62
|
+
unless Dir.exist?(destination_dir)
|
|
63
|
+
say("The dir used to copy file doesn't exist (#{destination_dir})", :red)
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
args.each do |arg|
|
|
68
|
+
if arg =~ URI::regexp
|
|
69
|
+
youtube = YoutubeDl.new(arg)
|
|
70
|
+
youtube.copy(destination_dir)
|
|
71
|
+
else
|
|
72
|
+
FileUtils.cp(arg, destination_dir)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
say("Successfully copied #{arg}", :green)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
desc 'version', 'Print Rpush version'
|
|
80
|
+
def version
|
|
81
|
+
puts Aucast::VERSION
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def upload_file(uploadable)
|
|
87
|
+
endpoint = Endpoint.new("http://#{options[:address]}")
|
|
88
|
+
|
|
89
|
+
say("Uploading...")
|
|
90
|
+
|
|
91
|
+
begin
|
|
92
|
+
ret = uploadable.upload(endpoint)
|
|
93
|
+
rescue => e
|
|
94
|
+
say(e.message, :red)
|
|
95
|
+
return
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if ret
|
|
99
|
+
say("Successfully uploaded #{uploadable.filename}", :green)
|
|
100
|
+
else
|
|
101
|
+
say(ret, :red)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def options
|
|
106
|
+
original_options = super
|
|
107
|
+
config_path = File.join(Dir.home, "/#{CONFIG_FILENAME}")
|
|
108
|
+
return original_options unless ::File.file?(config_path)
|
|
109
|
+
defaults = ::YAML::load_file(config_path) || {}
|
|
110
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'rest-client'
|
|
2
|
+
|
|
3
|
+
module Aucast
|
|
4
|
+
# Endpoint for Aucast rest api
|
|
5
|
+
class Endpoint
|
|
6
|
+
|
|
7
|
+
# Class initializer
|
|
8
|
+
# Params:
|
|
9
|
+
# - endpoint_url: endpoint url without scheme (ex: work-iphone.local or 192.128.1.10)
|
|
10
|
+
def initialize(endpoint_url)
|
|
11
|
+
@endpoint_url = endpoint_url
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Upload a file
|
|
15
|
+
# Params:
|
|
16
|
+
# - file_path: ~/Documents/english_first_leson.mp3
|
|
17
|
+
def upload(file_path)
|
|
18
|
+
file = File.open(file_path, 'r')
|
|
19
|
+
|
|
20
|
+
params = { "multipart" => true, "files[]" => file }
|
|
21
|
+
response = RestClient.post "#{@endpoint_url}/upload", params
|
|
22
|
+
|
|
23
|
+
case response.code
|
|
24
|
+
when 400
|
|
25
|
+
return { error: parse_json(response.to_str) }
|
|
26
|
+
when 200
|
|
27
|
+
return true
|
|
28
|
+
else
|
|
29
|
+
raise "Invalid response #{response.to_str} received."
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'aucast/endpoint'
|
|
2
|
+
|
|
3
|
+
module Aucast
|
|
4
|
+
# Upload a file to Aucast webservice
|
|
5
|
+
class FileUpload
|
|
6
|
+
def initialize(file_path)
|
|
7
|
+
@file_path = file_path
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def filename
|
|
11
|
+
@file_path.split("/").last
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def upload(endpoint)
|
|
15
|
+
ret = endpoint.upload(@file_path)
|
|
16
|
+
|
|
17
|
+
if ret
|
|
18
|
+
true
|
|
19
|
+
elsif ret.is_a? Hash and ret[:error]
|
|
20
|
+
ret[:error]
|
|
21
|
+
elsif ret.is_a? String
|
|
22
|
+
ret
|
|
23
|
+
else
|
|
24
|
+
nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'aucast/file_upload'
|
|
2
|
+
|
|
3
|
+
module Aucast
|
|
4
|
+
|
|
5
|
+
class YoutubeDl
|
|
6
|
+
def initialize(url)
|
|
7
|
+
@url = url
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def filename
|
|
11
|
+
@url
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def copy(destination)
|
|
15
|
+
tmpdir = Dir.mktmpdir
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
download_video(@url, tmpdir)
|
|
19
|
+
file_path = find_audio_in_tmpdir(tmpdir)
|
|
20
|
+
FileUtils.cp(file_path, destination)
|
|
21
|
+
ensure
|
|
22
|
+
FileUtils.remove_entry_secure tmpdir
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def upload(endpoint)
|
|
27
|
+
tmpdir = Dir.mktmpdir
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
download_video(@url, tmpdir)
|
|
31
|
+
file_path = find_audio_in_tmpdir(tmpdir)
|
|
32
|
+
file_uploader = FileUpload.new(file_path)
|
|
33
|
+
file_uploader.upload(endpoint)
|
|
34
|
+
ensure
|
|
35
|
+
FileUtils.remove_entry_secure tmpdir
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
protected
|
|
40
|
+
|
|
41
|
+
def find_audio_in_tmpdir(tmpdir)
|
|
42
|
+
Dir
|
|
43
|
+
.entries(tmpdir)
|
|
44
|
+
.map { |f| File.join(tmpdir, f) }
|
|
45
|
+
.select { |f| File.file?(f) }
|
|
46
|
+
.first
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def download_video(url, outdir)
|
|
50
|
+
system <<-SH
|
|
51
|
+
cd #{outdir} && \
|
|
52
|
+
youtube-dl \
|
|
53
|
+
--extract-audio \
|
|
54
|
+
--audio-format mp3 \
|
|
55
|
+
--audio-quality 0 \
|
|
56
|
+
#{url}
|
|
57
|
+
SH
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
data/lib/aucast.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: aucast
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bruno Wernimont
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.20'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.20'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rest-client
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.16'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.16'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: minitest
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '5.11'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '5.11'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: minitest-reporters
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.1'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.1'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: byebug
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
description: The CLI for uploading audio and video URL to Aucast iOS app, that support
|
|
126
|
+
youtube-dl.
|
|
127
|
+
email:
|
|
128
|
+
- contact@aucast.io
|
|
129
|
+
executables:
|
|
130
|
+
- aucast
|
|
131
|
+
extensions: []
|
|
132
|
+
extra_rdoc_files: []
|
|
133
|
+
files:
|
|
134
|
+
- ".gitignore"
|
|
135
|
+
- ".rspec"
|
|
136
|
+
- ".travis.yml"
|
|
137
|
+
- CODE_OF_CONDUCT.md
|
|
138
|
+
- Gemfile
|
|
139
|
+
- Gemfile.lock
|
|
140
|
+
- LICENSE.txt
|
|
141
|
+
- README.md
|
|
142
|
+
- Rakefile
|
|
143
|
+
- aucast.gemspec
|
|
144
|
+
- bin/console
|
|
145
|
+
- bin/setup
|
|
146
|
+
- exe/aucast
|
|
147
|
+
- lib/aucast.rb
|
|
148
|
+
- lib/aucast/cli.rb
|
|
149
|
+
- lib/aucast/endpoint.rb
|
|
150
|
+
- lib/aucast/file_upload.rb
|
|
151
|
+
- lib/aucast/version.rb
|
|
152
|
+
- lib/aucast/youtube_dl.rb
|
|
153
|
+
homepage: https://aucast.io
|
|
154
|
+
licenses:
|
|
155
|
+
- MIT
|
|
156
|
+
metadata:
|
|
157
|
+
allowed_push_host: https://rubygems.org
|
|
158
|
+
post_install_message:
|
|
159
|
+
rdoc_options: []
|
|
160
|
+
require_paths:
|
|
161
|
+
- lib
|
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
|
+
requirements:
|
|
169
|
+
- - ">="
|
|
170
|
+
- !ruby/object:Gem::Version
|
|
171
|
+
version: '0'
|
|
172
|
+
requirements: []
|
|
173
|
+
rubyforge_project:
|
|
174
|
+
rubygems_version: 2.7.7
|
|
175
|
+
signing_key:
|
|
176
|
+
specification_version: 4
|
|
177
|
+
summary: Upload audio file and video media URL to Aucast iOS app.
|
|
178
|
+
test_files: []
|