libretto 2.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 635b4bbaa32e920082ede1c03d797315c7ab2882
4
+ data.tar.gz: 906da9bc886473450047dcdc10cf7bab228dc1d9
5
+ SHA512:
6
+ metadata.gz: 65e1501b3efc5bfd14c410a358483254c7c3d5eb16e684a78e63101df33546da368e21cd80fce50053e217b00a7be38168be41831da670bf48164238311b8d62
7
+ data.tar.gz: 704a46115e2f849cd8d078a05778fd3deb17bc1828afdaa842a222850cb319658f2c2e9cc88e98d88157aac24d8a1a6088ff75a2632f9d1a6c583111ffa05a11
Binary file
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in libretto.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Josh
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.
@@ -0,0 +1,54 @@
1
+ libretto
2
+ ========
3
+
4
+ a CLI for obtaining lyrics through [azlyrics](http://www.azlyrics.com/).
5
+
6
+ installing
7
+ ---------
8
+
9
+ ```bash
10
+ $ gem install libretto
11
+ ```
12
+
13
+ usage
14
+ -----
15
+
16
+ You can get the lyrics displayed in your terminal pretty easily
17
+
18
+ ```bash
19
+ $ libretto "The Only Place" "Best Coast"
20
+ ```
21
+
22
+ You can also open the lyrics page instead of having it print in your terminal
23
+
24
+ ```bash
25
+ $ libretto "I’m a Cuckoo" "Belle And Sebastian" -o
26
+ ```
27
+
28
+ Or, if for whatever reason you want to, you can just have the URL of the lyrics page
29
+ printed in your terminal - [also..](#also)
30
+
31
+ ```bash
32
+ $ libretto "White Room" "Cream" -url
33
+ ```
34
+
35
+ You can also check how many times a certain word is said in a song
36
+
37
+ ```bash
38
+ $ libretto "Sweatpants" "Childish Gambino" "nigga"
39
+ ```
40
+
41
+ thing i should probably add
42
+ ----------------------------
43
+
44
+ - [ ] if the URL does not actually exist,
45
+ tell the user
46
+
47
+ also..
48
+ ------
49
+
50
+ i'm still working on it, but if you attempt to
51
+ get a song's URL with `-url` and the lyrics
52
+ are not available for that song, you will
53
+ get an error, as well as what the URL would be
54
+ if the song existed
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/libretto'
@@ -0,0 +1,102 @@
1
+ require_relative 'libretto/version'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'launchy'
5
+ require 'rainbow'
6
+
7
+ module Libretto
8
+ song = ARGV[0]
9
+ artist = ARGV[1]
10
+ argument = ARGV[2]
11
+
12
+ def error (error="")
13
+ print Rainbow("Error: ").inverse.red
14
+ print error
15
+ print " "
16
+ end
17
+
18
+ def exit
19
+ Process.exit(0)
20
+ end
21
+
22
+ case ARGV[0]
23
+ when "-v"
24
+ puts "libretto v#{Libretto::VERSION}"
25
+ when "-h"
26
+ Launchy.open("http://github.com/trommel/libretto")
27
+ else
28
+ unless song.nil? or artist.nil?
29
+
30
+ finalartist = artist.downcase.gsub " ", ""
31
+ finalsong = song.downcase.gsub " ", ""
32
+ finalsong.gsub! "-", ""
33
+ finalartist.gsub! "-", ""
34
+ finalsong.gsub! "'", ""
35
+ finalartist.gsub! "'", ""
36
+ root_url = 'http://www.azlyrics.com/lyrics/'
37
+ url = "#{root_url}#{finalartist}/#{finalsong}.html"
38
+ page_content = Net::HTTP.get(URI.parse(url))
39
+
40
+ begin
41
+ page_content.gsub! "<br />", ""
42
+ page_content.gsub! "<i>", ""
43
+ page_content.gsub! "</i>", ""
44
+ almostfinal = page_content.partition("<!-- start of lyrics -->").last
45
+ remove = 0..(almostfinal.index('<!-- end of lyrics -->'))
46
+ final = almostfinal.slice(remove).gsub! "<", ""
47
+ red_song = Rainbow(song.capitalize).underline.red
48
+ red_artist = Rainbow(artist.capitalize).underline.red
49
+ info = "#{red_song} #{Rainbow("-").blue} #{red_artist}"
50
+ lyrics = Rainbow(final).green
51
+ rescue
52
+ puts Rainbow("Unknown Error").inverse.red
53
+ end
54
+
55
+ if ! argument.nil?
56
+ case argument
57
+ when "-url"
58
+ begin
59
+ root_url = 'http://www.azlyrics.com/lyrics/'
60
+ url = "#{root_url}#{finalartist}/#{finalsong}.html"
61
+ puts Rainbow(url).underline.green
62
+ exit
63
+ rescue
64
+ does_not_exist = Rainbow("This song does not exist on")
65
+ url = Rainbow("azlyrics.com").underline.red
66
+ puts "#{does_not_exist} #{url}"
67
+ exit
68
+ end
69
+ when "-o"
70
+ root_url = 'http://www.azlyrics.com/lyrics/'
71
+ url = "#{root_url}#{finalartist}/#{finalsong}.html"
72
+ puts Launchy.open(url)
73
+ exit
74
+ else
75
+ begin
76
+ green_argument = Rainbow(argument).green
77
+ this_amount = lyrics.downcase.split(argument).size - 1
78
+ this_amount_colored = Rainbow(this_amount).red
79
+ puts "#{green_argument} is said #{this_amount_colored} times"
80
+ exit
81
+ rescue
82
+ green_song = Rainbow(song).green
83
+ puts "#{green_song} is #{Rainbow("not an available song").red}"
84
+ exit
85
+ end
86
+ end
87
+ end
88
+ begin
89
+ puts
90
+ puts info
91
+ puts Rainbow(lyrics).green
92
+ rescue
93
+ green_song = Rainbow(song).green
94
+ blue_artist = Rainbow(artist).blue
95
+ not_found = Rainbow('not found :(').red
96
+ puts "#{green_song} by #{blue_artist} was #{not_found}"
97
+ end
98
+ else
99
+ puts Rainbow("You need to specify a song and artist").red
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,3 @@
1
+ module Libretto
2
+ VERSION = '2.0'
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/libretto/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Josh']
6
+ gem.email = ['joshception@icloud.com']
7
+ gem.description = %q{get lyrics, easy.}
8
+ gem.summary = %q{a CLI for obtaining lyrics through azlyrics.}
9
+ gem.homepage = 'https://github.com/trommel/libretto'
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = ['libretto']
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = 'libretto'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Libretto::VERSION
17
+
18
+ gem.add_development_dependency "bundler", "~> 1.6"
19
+ gem.add_development_dependency "rake"
20
+ gem.add_dependency 'launchy', '>= 2.4'
21
+ gem.add_dependency 'rainbow', '>= 2.0'
22
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libretto
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.0'
5
+ platform: ruby
6
+ authors:
7
+ - Josh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-11 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: launchy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rainbow
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ description: get lyrics, easy.
70
+ email:
71
+ - joshception@icloud.com
72
+ executables:
73
+ - libretto
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".DS_Store"
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/libretto
84
+ - lib/libretto.rb
85
+ - lib/libretto/version.rb
86
+ - libretto.gemspec
87
+ homepage: https://github.com/trommel/libretto
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: a CLI for obtaining lyrics through azlyrics.
110
+ test_files: []