aavimeodl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/aavimeodl.gemspec +36 -0
- data/bin/aavimeodl +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/aavimeodl.rb +9 -0
- data/lib/aavimeodl/AVD.rb +154 -0
- data/lib/aavimeodl/version.rb +3 -0
- data/pkg/aavimeodl-0.1.0.gem +0 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d59cf03b05055e61250b8771bfc134e67a2923b4
|
4
|
+
data.tar.gz: 8a80175d3876f2f6e34541caf559e286241c105e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15f5f20969b66b9f55c26fae70b05e2087021e4ea5dec240ba161fb526d72d099d6b95b68ae5619fab6eea7ffc6f53124800ccbf2d06268287ee1efe45e22970
|
7
|
+
data.tar.gz: 42fc89983cf982d3eaa5c73594ec7f28b42e756fc54e2d5c64ae50a65dc653df93f2b1a9482f712047c241f6d07a51aa667f404304498c9393bf08dbf6a263b3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
aavimeodl (0.1.0)
|
5
|
+
youtube-dl.rb
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
byebug (9.1.0)
|
11
|
+
climate_control (0.2.0)
|
12
|
+
cocaine (0.5.8)
|
13
|
+
climate_control (>= 0.0.3, < 1.0)
|
14
|
+
rake (10.5.0)
|
15
|
+
youtube-dl.rb (0.3.1.2016.09.11.1)
|
16
|
+
cocaine (>= 0.5.4)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
aavimeodl!
|
23
|
+
bundler (~> 1.16)
|
24
|
+
byebug (>= 1.0)
|
25
|
+
rake (~> 10.0)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 candyapplecorn
|
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,39 @@
|
|
1
|
+
# Aavimeodl
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aavimeodl`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'aavimeodl'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install aavimeodl
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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](http://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aavimeodl.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/aavimeodl.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "aavimeodl/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aavimeodl"
|
8
|
+
spec.version = Aavimeodl::VERSION
|
9
|
+
spec.authors = ["candyapplecorn"]
|
10
|
+
spec.email = ["candyapplecorn@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Downloads private App Academy videos from Vimeo}
|
13
|
+
spec.homepage = "http://github.com/candyapplecorn/aa-vimeo-downloader/tree/youtube-dl_ruby_bindings"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "bin"
|
29
|
+
spec.executables = ['aavimeodl']
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "byebug", ">=1.0"
|
35
|
+
spec.add_runtime_dependency "youtube-dl.rb"
|
36
|
+
end
|
data/bin/aavimeodl
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "aavimeodl"
|
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/lib/aavimeodl.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'io/console'
|
3
|
+
require 'pty'
|
4
|
+
# No installation! Wew!
|
5
|
+
require 'youtube-dl'
|
6
|
+
|
7
|
+
class GitRaw
|
8
|
+
attr_reader :body
|
9
|
+
def initialize(url)
|
10
|
+
@body = open(url).map(&:chomp)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class LinkParser
|
15
|
+
attr_reader :links
|
16
|
+
|
17
|
+
def initialize(raw, creds)
|
18
|
+
unparsed_links = narrow_to_week_section(raw.body.dup, creds.day)
|
19
|
+
to_hash(unparsed_links)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def narrow_to_week_section(body, target)
|
25
|
+
links = []
|
26
|
+
|
27
|
+
unless target =~ /all/i
|
28
|
+
body.shift until body.first =~ Regexp.new("[^\\[#]#{target}", 'i')
|
29
|
+
links << body.shift until body.first =~ /homeworks|additional resources|projects/i
|
30
|
+
end
|
31
|
+
|
32
|
+
body = links.select! { |l| l =~ /vimeo/ }
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_hash(unparsed_links)
|
36
|
+
@links = Hash.new do |h, k|
|
37
|
+
k =~ /(\[.*\]).*(http.*)/
|
38
|
+
h["#{h.count + 1}: #{$1}"] = $2
|
39
|
+
end
|
40
|
+
|
41
|
+
unparsed_links.each { |unparsed| @links[unparsed] }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# should be able to remove this once binding works correctly
|
46
|
+
def has_youtube_dl?
|
47
|
+
if `which youtube-dl` =~ /^$/
|
48
|
+
print <<~HEREDOC
|
49
|
+
The dependency 'youtube_dl' is not installed.
|
50
|
+
To install this program, see
|
51
|
+
https://rg3.github.io/youtube-dl/download.html
|
52
|
+
|
53
|
+
Are you using OSX or Linux and would like to
|
54
|
+
install youtube_dl automatically?
|
55
|
+
HEREDOC
|
56
|
+
|
57
|
+
print "[Y/N]: "
|
58
|
+
|
59
|
+
if STDIN.gets =~ /y/i
|
60
|
+
raise "Install failed; please install manually" unless install_youtube_dl
|
61
|
+
return true
|
62
|
+
else
|
63
|
+
abort('Install youtube_dl to use this program')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def install_youtube_dl
|
69
|
+
`sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl`
|
70
|
+
`sudo chmod a+rx /usr/local/bin/youtube-dl`
|
71
|
+
`which youtube-dl` =~ /^$/
|
72
|
+
end
|
73
|
+
|
74
|
+
class Credentials
|
75
|
+
attr_reader :day, :url, :vimeo_password
|
76
|
+
def initialize
|
77
|
+
@day = ARGV.find { |a| a =~ /w\d+d\d+|all/i }
|
78
|
+
@url = ARGV.find { |a| a =~ /raw.githubusercontent/ }
|
79
|
+
|
80
|
+
abort("Must provide a URL to a README.md RAW") unless @url
|
81
|
+
abort("Must provide a day like 'w4d1' OR '--all'") unless @day
|
82
|
+
|
83
|
+
@day = @day.upcase
|
84
|
+
@vimeo_password = get_vimeo_password
|
85
|
+
p ''
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def get_vimeo_password
|
91
|
+
print "Please enter the password to access these Vimeo videos:\n> "
|
92
|
+
STDIN.noecho(&:gets).chomp
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def make_video_dir(creds, links)
|
97
|
+
vdirname = "#{creds.day}_videos"
|
98
|
+
Dir.mkdir vdirname unless Dir.exists?(vdirname)
|
99
|
+
Dir.chdir vdirname
|
100
|
+
p "Created the directory #{vdirname}"
|
101
|
+
|
102
|
+
links.each do |name, link|
|
103
|
+
if Dir.entries('.').find { |e| e.index name }
|
104
|
+
puts "#{name} already exists; continuing to next video"
|
105
|
+
else
|
106
|
+
get_video(name, link, creds.vimeo_password)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
p "#{vdirname} successfully created with #{Dir.entries('.').reject { |e| e =~ /^\./ }.count} videos"
|
111
|
+
|
112
|
+
print `ls -1`
|
113
|
+
end
|
114
|
+
|
115
|
+
# Replace this with ruby binding
|
116
|
+
def get_video(name, link, pass)
|
117
|
+
title = "#{name}.%(ext)s"
|
118
|
+
command = %{youtube-dl --video-password "#{pass}" -o "#{title}" #{link}}
|
119
|
+
|
120
|
+
YoutubeDL.download link, {
|
121
|
+
"video-password": pass,
|
122
|
+
"o": title
|
123
|
+
}
|
124
|
+
|
125
|
+
# begin
|
126
|
+
# PTY.spawn(command) do |stdout, _stdin, _pid|
|
127
|
+
# begin
|
128
|
+
# stdout.each { |line| print line }
|
129
|
+
# rescue Errno::EIO
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
# rescue PTY::ChildExited
|
133
|
+
# puts "The child process exited!"
|
134
|
+
# end
|
135
|
+
end
|
136
|
+
|
137
|
+
class Aavimeodl::AVD
|
138
|
+
def initialize
|
139
|
+
creds = Credentials.new
|
140
|
+
raw = GitRaw.new creds.url
|
141
|
+
links = LinkParser.new(raw, creds)
|
142
|
+
make_video_dir(creds, links.links)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
if $PROGRAM_NAME == __FILE__
|
147
|
+
#has_youtube_dl? # This will go since ruby binding should work
|
148
|
+
# creds = Credentials.new
|
149
|
+
# raw = GitRaw.new creds.url
|
150
|
+
# links = LinkParser.new(raw, creds)
|
151
|
+
# make_video_dir(creds, links.links)
|
152
|
+
Aavimeodl::AVD.new
|
153
|
+
end
|
154
|
+
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aavimeodl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- candyapplecorn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: youtube-dl.rb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- candyapplecorn@gmail.com
|
72
|
+
executables:
|
73
|
+
- aavimeodl
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- aavimeodl.gemspec
|
83
|
+
- bin/aavimeodl
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/aavimeodl.rb
|
87
|
+
- lib/aavimeodl/AVD.rb
|
88
|
+
- lib/aavimeodl/version.rb
|
89
|
+
- pkg/aavimeodl-0.1.0.gem
|
90
|
+
homepage: http://github.com/candyapplecorn/aa-vimeo-downloader/tree/youtube-dl_ruby_bindings
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
allowed_push_host: https://rubygems.org
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.11
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Downloads private App Academy videos from Vimeo
|
115
|
+
test_files: []
|
116
|
+
has_rdoc:
|