offliberty 1.0.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 +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/bin/off +45 -0
- data/lib/offliberty.rb +23 -0
- data/lib/offliberty/helpers/connection.rb +16 -0
- data/lib/offliberty/version.rb +3 -0
- data/offliberty.gemspec +25 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2db4c432ddf0400a0423dfccf6d99df240ae4e95
|
4
|
+
data.tar.gz: eab9e7d6af089cbaf660eabd065f35460b355262
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b776c33d30787efb00831efc9c57983c2c25c6b7b29c575dad0b69bb060499f708a6d9b7767f9d3a79edeb9c4ea94e859e8feae98ddc16a71b10c614f8e98eb
|
7
|
+
data.tar.gz: c9b5671494436d860e37499f5f85c2e0b1aca5371771f5df3d2f13d51fa0fcf8c829b2ecb1ea10b7025bea15a8a1e20336a9eca794080212961f5a63a3653cde
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Radu-Bogdan Croitoru
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Offliberty
|
2
|
+
|
3
|
+
A simple interface to the offliberty.com download service.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'offliberty'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install offliberty
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### From ruby
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'offliberty'
|
27
|
+
|
28
|
+
song = Offliberty::Off.new("https://www.youtube.com/watch?v=A4GhUglZ5NU")
|
29
|
+
song.offliberate # Get the download link
|
30
|
+
song.download # Download the song near this ruby script
|
31
|
+
```
|
32
|
+
|
33
|
+
### From terminal
|
34
|
+
|
35
|
+
```sh
|
36
|
+
$ off https://www.youtube.com/watch?v=A4GhUglZ5NU
|
37
|
+
```
|
38
|
+
|
39
|
+
Or with a textfile with multiple links
|
40
|
+
```sh
|
41
|
+
$ cat example
|
42
|
+
https://www.youtube.com/watch?v=uiGpv-UeiDI
|
43
|
+
not link
|
44
|
+
https://www.youtube.com/watch?v=oHowqKYSXNI
|
45
|
+
random text
|
46
|
+
$ off example
|
47
|
+
Requesting...
|
48
|
+
Downloading...
|
49
|
+
Finished!
|
50
|
+
Requesting...
|
51
|
+
Downloading...
|
52
|
+
Finished!
|
53
|
+
```
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it ( https://github.com/radubogdan/ruby-offliberty/fork )
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/off
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'offliberty'
|
4
|
+
|
5
|
+
def help
|
6
|
+
puts "\nSimple CLI App for offliberty.com download service"
|
7
|
+
puts "\nUSAGE:"
|
8
|
+
puts " $ off <youtube-link> - Download song in current directory"
|
9
|
+
puts " $ off <file-with-youtube-links> - Download all songs from file to current directory"
|
10
|
+
puts "\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_url? url
|
14
|
+
reg = /^https?:\/\//
|
15
|
+
url.match(reg)
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV.length != 1
|
19
|
+
help
|
20
|
+
else
|
21
|
+
arg = ARGV.pop
|
22
|
+
|
23
|
+
if is_url?(arg)
|
24
|
+
puts "Requesting..."
|
25
|
+
song = Offliberty::Off.new(arg)
|
26
|
+
puts "Downloading..."
|
27
|
+
song.download
|
28
|
+
elsif File.exist?(arg)
|
29
|
+
f = File.open(arg, "r")
|
30
|
+
|
31
|
+
f.each_line do |link|
|
32
|
+
if is_url?(link)
|
33
|
+
puts "Requesting..."
|
34
|
+
song = Offliberty::Off.new(link)
|
35
|
+
puts "Downloading..."
|
36
|
+
song.download
|
37
|
+
puts "Finished!"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
f.close
|
42
|
+
else
|
43
|
+
help
|
44
|
+
end
|
45
|
+
end
|
data/lib/offliberty.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "offliberty/version"
|
2
|
+
require "offliberty/helpers/connection"
|
3
|
+
require "mechanize"
|
4
|
+
|
5
|
+
module Offliberty
|
6
|
+
class Off
|
7
|
+
def initialize song_url
|
8
|
+
@page = Offliberty::Helpers::Connection.new(song_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def offliberate
|
12
|
+
res = @page.form.submit
|
13
|
+
song_url = res.links.fetch(0).href
|
14
|
+
end
|
15
|
+
|
16
|
+
def download
|
17
|
+
song_url = offliberate
|
18
|
+
file = @page.agent.get(song_url)
|
19
|
+
filename = file.filename.gsub("_-_from_YouTube", "").gsub("_", " ")
|
20
|
+
file.save(filename)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Offliberty
|
2
|
+
module Helpers
|
3
|
+
class Connection
|
4
|
+
attr_reader :form, :agent
|
5
|
+
|
6
|
+
def initialize song_url
|
7
|
+
@agent = Mechanize.new
|
8
|
+
@agent.user_agent_alias = 'Mac Safari'
|
9
|
+
@page = @agent.get("http://offliberty.com")
|
10
|
+
@form = @page.forms.fetch(0)
|
11
|
+
@form.action = "http://offliberty.com/off54.php"
|
12
|
+
@form.track = song_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/offliberty.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'offliberty/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "offliberty"
|
8
|
+
spec.version = Offliberty::VERSION
|
9
|
+
spec.authors = ["Radu-Bogdan Croitoru"]
|
10
|
+
spec.email = ["croitoruradubogdan@gmail.com"]
|
11
|
+
spec.summary = %q{A simple interface to the offliberty.com download service.}
|
12
|
+
spec.description = %q{Get the download link of any youtube song, or download the song just passing the youtube URL using offliberty.com online service}
|
13
|
+
spec.homepage = "https://github.com/radubogdan/ruby-offliberty"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "mechanize"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: offliberty
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Radu-Bogdan Croitoru
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Get the download link of any youtube song, or download the song just
|
56
|
+
passing the youtube URL using offliberty.com online service
|
57
|
+
email:
|
58
|
+
- croitoruradubogdan@gmail.com
|
59
|
+
executables:
|
60
|
+
- 'off'
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/off
|
70
|
+
- lib/offliberty.rb
|
71
|
+
- lib/offliberty/helpers/connection.rb
|
72
|
+
- lib/offliberty/version.rb
|
73
|
+
- offliberty.gemspec
|
74
|
+
homepage: https://github.com/radubogdan/ruby-offliberty
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.14
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A simple interface to the offliberty.com download service.
|
98
|
+
test_files: []
|